char version[80]="Imach version 0.8h, May 2002, INED-EUROREVES ";\r
int erreur; /* Error number */\r
int nvar;\r
-int cptcovn, cptcovage=0, cptcoveff=0,cptcov;\r
+int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov;\r
int npar=NPARMAX;\r
int nlstate=2; /* Number of live states */\r
int ndeath=1; /* Number of dead states */\r
/************ Variance of one-step probabilities ******************/\r
void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax)\r
{\r
- int i, j, i1, k1, l1;\r
+ int i, j=0, i1, k1, l1, t, tj;\r
int k2, l2, j1, z1;\r
int k=0,l, cptcode;\r
int first=1;\r
exit(0);\r
}\r
else{\r
- fprintf(fichtm,"\n<H2> Computing matrix of variance-covariance of step probabilities</h2>\n");\r
- fprintf(fichtm,"\n<br> We have drawn ellipsoids of confidence around the p<inf>ij</inf>, p<inf>kl</inf> to understand the covariance between two incidences. They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n");\r
+ fprintf(fichtm,"\n<li><h4> Computing matrix of variance-covariance of step probabilities</h4></li>\n");\r
+ fprintf(fichtm,"\nWe have drawn ellipsoids of confidence around the p<inf>ij</inf>, p<inf>kl</inf> to understand the covariance between two incidences. They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n");\r
fprintf(fichtm,"\n<br> We have drawn x'cov<sup>-1</sup>x = 4 where x is the column vector (pij,pkl). It means that if pij and pkl where uncorrelated the (2X2) matrix would have been (1/(var pij), 0 , 0, 1/(var pkl)), and the confidence interval would be 2 standard deviations wide on each axis. <br> When both incidences are correlated we diagonalised the inverse of the covariance matrix and made the appropriate rotation.<br> \n");\r
\r
}\r
+\r
+ \r
cov[1]=1;\r
- j=cptcoveff;\r
- if (cptcovn<1) {j=1;ncodemax[1]=1;}\r
+ tj=cptcoveff;\r
+ if (cptcovn<1) {tj=1;ncodemax[1]=1;}\r
j1=0;\r
- for(k1=1; k1<=1;k1++){\r
- for(i1=1; i1<=ncodemax[k1];i1++){ \r
- j1++;\r
-\r
- if (cptcovn>0) {\r
- fprintf(ficresprob, "\n#********** Variable "); \r
- fprintf(ficresprobcov, "\n#********** Variable "); \r
- fprintf(ficgp, "\n#********** Variable "); \r
- fprintf(fichtm, "\n<h4>********** Variable</h4>\n "); \r
- fprintf(ficresprobcor, "\n#********** Variable "); \r
- for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
- fprintf(ficresprob, "**********\n#");\r
- for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
- fprintf(ficresprobcov, "**********\n#");\r
- for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
- fprintf(ficgp, "**********\n#");\r
- for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, "# V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
- fprintf(ficgp, "**********\n#");\r
- for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
- fprintf(fichtm, "**********\n#");\r
- }\r
- \r
+ for(t=1; t<=tj;t++){\r
+ for(i1=1; i1<=ncodemax[t];i1++){ \r
+ j1++;\r
+ \r
+ if (cptcovn>0) {\r
+ fprintf(ficresprob, "\n#********** Variable "); \r
+ for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
+ fprintf(ficresprob, "**********\n#");\r
+ fprintf(ficresprobcov, "\n#********** Variable "); \r
+ for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
+ fprintf(ficresprobcov, "**********\n#");\r
+ \r
+ fprintf(ficgp, "\n#********** Variable "); \r
+ for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, "# V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
+ fprintf(ficgp, "**********\n#");\r
+ \r
+ \r
+ fprintf(fichtm, "\n<hr size=\"2\" color=\"#EC5E5E\">********** Variable "); \r
+ for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
+ fprintf(fichtm, "**********\n<hr size=\"2\" color=\"#EC5E5E\">");\r
+ \r
+ fprintf(ficresprobcor, "\n#********** Variable "); \r
+ for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);\r
+ fprintf(ficgp, "**********\n#"); \r
+ }\r
+ \r
for (age=bage; age<=fage; age ++){ \r
cov[2]=age;\r
for (k=1; k<=cptcovn;k++) {\r
fprintf(ficgp,"\nset parametric;set nolabel");\r
fprintf(ficgp,"\nset log y;set log x; set xlabel \"p%1d%1d (year-1)\";set ylabel \"p%1d%1d (year-1)\"",k2,l2,k1,l1);\r
fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65");\r
- fprintf(fichtm,"\n<br>Ellipsoids of confidence cov(p%1d%1d,p%1d%1d) expressed in year<sup>-1</sup> :<a href=\"varpijgr%s%1d%1d-%1d%1d.png\">varpijgr%s%1d%1d-%1d%1d.png</A>, ",k2,l2,k1,l1,optionfilefiname,k2,l2,k1,l1,optionfilefiname,k2,l2,k1,l1);\r
- fprintf(fichtm,"\n<br><img src=\"varpijgr%s%1d%1d-%1d%1d.png\">, ",optionfilefiname,k2,l2,k1,l1);\r
- fprintf(ficgp,"\nset out \"varpijgr%s%1d%1d-%1d%1d.png\"",optionfilefiname,k2,l2,k1,l1);\r
+ fprintf(fichtm,"\n<br>Ellipsoids of confidence cov(p%1d%1d,p%1d%1d) expressed in year<sup>-1</sup> :<a href=\"varpijgr%s%d%1d%1d-%1d%1d.png\">varpijgr%s%d%1d%1d-%1d%1d.png</A>, ",k2,l2,k1,l1,optionfilefiname, j1,k2,l2,k1,l1,optionfilefiname, j1,k2,l2,k1,l1);\r
+ fprintf(fichtm,"\n<br><img src=\"varpijgr%s%d%1d%1d-%1d%1d.png\"> ",optionfilefiname, j1,k2,l2,k1,l1);\r
+ fprintf(ficgp,"\nset out \"varpijgr%s%d%1d%1d-%1d%1d.png\"",optionfilefiname, j1,k2,l2,k1,l1);\r
fprintf(ficgp,"\nset label \"%d\" at %11.3e,%11.3e center",(int) age, mu2,mu1);\r
fprintf(ficgp,"\n# Age %d, p%1d%1d - p%1d%1d",(int) age, k2,l2,k1,l1);\r
fprintf(ficgp,"\nplot [-pi:pi] %11.3e+ %.3f*(%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)), %11.3e +%.3f*(-%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)) t \"%d\"",\\r
}/* if first */\r
} /* age mod 5 */\r
} /* end loop age */\r
- fprintf(ficgp,"\nset out \"varpijgr%s%1d%1d-%1d%1d.png\";replot;",optionfilefiname,k2,l2,k1,l1);\r
+ fprintf(ficgp,"\nset out \"varpijgr%s%d%1d%1d-%1d%1d.png\";replot;",optionfilefiname, j1,k2,l2,k1,l1);\r
first=1;\r
} /*l12 */\r
} /* k12 */\r
printf("Problem with %s \n",optionfilehtm), exit(0);\r
}\r
\r
- fprintf(fichtm,"<ul><li>Result files (first order: no variance)<br>\n\r
+ fprintf(fichtm,"<ul><li><h4>Result files (first order: no variance)</h4>\n\r
- Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"p%s\">p%s</a> <br>\n\r
- Estimated transition probabilities over %d (stepm) months: <a href=\"pij%s\">pij%s</a><br>\n\r
- Stable prevalence in each health state: <a href=\"pl%s\">pl%s</a> <br>\n\r
<a href=\"e%s\">e%s</a> <br>\n</li>", \\r
jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,fileres,fileres,stepm,fileres,fileres,fileres,fileres,estepm,fileres,fileres);\r
\r
- fprintf(fichtm,"\n<li> Result files (second order: variances)<br>\n\r
+ fprintf(fichtm,"\n<br><li><h4> Result files (second order: variances)</h4>\n\r
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n\r
- Variance of one-step probabilities: <a href=\"prob%s\">prob%s</a> <br>\n\r
- Variance-covariance of one-step probabilities: <a href=\"probcov%s\">probcov%s</a> <br>\n\r
<br>",fileres,fileres,fileres,fileres);\r
else \r
fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=%s (instead of .)<br><br></li>\n",popforecast, stepm, model);\r
-fprintf(fichtm," <li>Graphs</li><p>");\r
+fprintf(fichtm," <li><b>Graphs</b></li><p>");\r
\r
m=cptcoveff;\r
if (cptcovn < 1) {m=1;ncodemax[1]=1;}\r
Total number of observations=%d <br>\n\r
Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n\r
<hr size=\"2\" color=\"#EC5E5E\">\r
- <ul><li>Parameter files<br>\n\r
+ <ul><li><h4>Parameter files</h4>\n\r
- Copy of the parameter file: <a href=\"o%s\">o%s</a><br>\n\r
- - Gnuplot file name: <a href=\"%s\">%s</a><br></ul>\n",version,title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,optionfilegnuplot,optionfilegnuplot);\r
+ - Gnuplot file name: <a href=\"%s\">%s</a></ul>\n",version,title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,optionfilegnuplot,optionfilegnuplot);\r
fclose(fichtm);\r
\r
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,jprev1,mprev1,anprev1,jprev2,mprev2,anprev2);\r
agelim=AGESUP;\r
hstepm=stepsize*YEARM; /* Every year of age */\r
hstepm=hstepm/stepm; /* Typically 2 years, = 2/6 months = 4 */ \r
- \r
+\r
+ /* hstepm=1; aff par mois*/\r
+\r
k=0;\r
for(cptcov=1;cptcov<=i1;cptcov++){\r
for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){\r
for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */\r
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */ \r
nhstepm = nhstepm/hstepm; /* Typically 40/4=10 */\r
+\r
+ /* nhstepm=nhstepm*YEARM; aff par mois*/\r
+\r
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
oldm=oldms;savm=savms;\r
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); \r
fprintf(ficrespij," %1d-%1d",i,j);\r
fprintf(ficrespij,"\n");\r
for (h=0; h<=nhstepm; h++){\r
- fprintf(ficrespij,"%d %.0f %.0f",k,agedeb, agedeb+ h*hstepm/YEARM*stepm );\r
+ fprintf(ficrespij,"%d %f %f",k,agedeb, agedeb+ h*hstepm/YEARM*stepm );\r
for(i=1; i<=nlstate;i++)\r
for(j=1; j<=nlstate+ndeath;j++)\r
fprintf(ficrespij," %.5f", p3mat[i][j][h]);\r