]> henry.ined.fr Git - .git/commitdiff
Change of gif to png.
authorN. Brouard <brouard@ined.fr>
Fri, 24 May 2002 13:00:54 +0000 (13:00 +0000)
committerN. Brouard <brouard@ined.fr>
Fri, 24 May 2002 13:00:54 +0000 (13:00 +0000)
Clarify some of the outputs.
Add a new graph: pij*YEARM/stepm in order to get pseudo-incidence per
year.

src/imach.c

index e00b7e65aa3112c88f90d0e6c186901b9f9b9a5e..f542babfde29966fc4da2e04e85237fc17a920f4 100644 (file)
@@ -1665,7 +1665,7 @@ void evsij(char fileres[], double ***eij, double x[], int nlstate, int stepm, in
       for(j=1;j<=nlstate*2;j++)\r
        varhe[i][j][(int)age] =0.;\r
 \r
-     printf("%d||",(int)age);fflush(stdout);\r
+     printf("%d|",(int)age);fflush(stdout);\r
     for(h=0;h<=nhstepm-1;h++){\r
       for(k=0;k<=nhstepm-1;k++){\r
        matprod2(dnewm,trgradg[h],1,nlstate*2,1,npar,1,npar,matcov);\r
@@ -1724,7 +1724,7 @@ void varevsij(char fileres[], double ***vareij, double **matcov, double x[], dou
   double age,agelim, hf;\r
   int theta;\r
 \r
-   fprintf(ficresvij,"# Covariances of life expectancies\n");\r
+  fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n#  (weighted average of eij where weights are the stable prevalence in health states i\n");\r
   fprintf(ficresvij,"# Age");\r
   for(i=1; i<=nlstate;i++)\r
     for(j=1; j<=nlstate;j++)\r
@@ -1859,7 +1859,7 @@ void varprevlim(char fileres[], double **varpl, double **matcov, double x[], dou
   double age,agelim;\r
   int theta;\r
    \r
-  fprintf(ficresvpl,"# Standard deviation of prevalences limit\n");\r
+  fprintf(ficresvpl,"# Standard deviation of prevalence's limit\n");\r
   fprintf(ficresvpl,"# Age");\r
   for(i=1; i<=nlstate;i++)\r
       fprintf(ficresvpl," %1d-%1d",i,i);\r
@@ -2061,10 +2061,12 @@ fprintf(ficresprob,"#One-step probabilities and standard deviation in parenthese
 \r
 /******************* Printing html file ***********/\r
 void printinghtml(char fileres[], char title[], char datafile[], int firstpass, \\r
- int lastpass, int stepm, int weightopt, char model[],\\r
- int imx,int jmin, int jmax, double jmeanint,char optionfile[], \\r
- char optionfilehtm[],char rfileres[], char optionfilegnuplot[],\\r
- char version[], int popforecast, int estepm ){\r
+                 int lastpass, int stepm, int weightopt, char model[],\\r
+                 int imx,int jmin, int jmax, double jmeanint,char optionfile[], \\r
+                 char optionfilehtm[],char rfileres[], char optionfilegnuplot[],\\r
+                 char version[], int popforecast, int estepm ,/* \ */\r
+                 double jprev1, double mprev1,double anprev1, \\r
+                 double jprev2, double mprev2,double anprev2){\r
   int jj1, k1, i1, cpt;\r
   FILE *fichtm;\r
   /*char optionfilehtm[FILENAMELENGTH];*/\r
@@ -2075,26 +2077,30 @@ void printinghtml(char fileres[], char title[], char datafile[], int firstpass,
     printf("Problem with %s \n",optionfilehtm), exit(0);\r
   }\r
 \r
- fprintf(fichtm,"<body> <font size=\"2\">%s </font> <hr size=\"2\" color=\"#EC5E5E\"> \n\r
 fprintf(fichtm,"<body> <font size=\"2\">%s </font> <hr size=\"2\" color=\"#EC5E5E\"> \n\r
 Title=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br>\n\r
 \n\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>Outputs files<br>\n\r
+<hr  size=\"2\" color=\"#EC5E5E\">\r
+ <ul><li>Parameter files<br>\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>\n\r
- - Observed prevalence in each state: <a href=\"p%s\">p%s</a> <br>\n\r
- - Stationary prevalence in each state: <a href=\"pl%s\">pl%s</a> <br>\n\r
- - Transition probabilities: <a href=\"pij%s\">pij%s</a><br>\n\r
- - Life expectancies by age and initial health status (estepm=%2d months): <a href=\"e%s\">e%s</a> <br>\n",version,title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,optionfilegnuplot,optionfilegnuplot,fileres,fileres,fileres,fileres,fileres,fileres,estepm,fileres,fileres);\r
-\r
- fprintf(fichtm,"\n\r
- - Parameter file with estimated parameters and the 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
- - Variances of life expectancies by age and initial health status (estepm=%d months): <a href=\"v%s\">v%s</a><br>\n \r
- - Health expectancies with their variances: <a href=\"t%s\">t%s</a> <br>\n\r
- - Standard deviation of stationary prevalences: <a href=\"vpl%s\">vpl%s</a> <br>\n",rfileres,rfileres,fileres,fileres, estepm, fileres,fileres,fileres,fileres,fileres,fileres);\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
+\r
+   fprintf(fichtm,"<ul><li>Result files (first order: no variance)<br>\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
+ - Life expectancies by age and initial health status (estepm=%2d months): \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
+ - 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
+ - Variances and covariances of life expectancies by age and initial health status (estepm=%d months): <a href=\"v%s\">v%s</a><br>\n \r
+ - Health expectancies with their variances (no covariance): <a href=\"t%s\">t%s</a> <br>\n\r
+ - Standard deviation of stable prevalences: <a href=\"vpl%s\">vpl%s</a> <br>\n",rfileres,rfileres,fileres,fileres, estepm, fileres,fileres,fileres,fileres,fileres,fileres);\r
 \r
  if(popforecast==1) fprintf(fichtm,"\n\r
  - Prevalences forecasting: <a href=\"f%s\">f%s</a> <br>\n\r
@@ -2117,10 +2123,15 @@ fprintf(fichtm," <li>Graphs</li><p>");
           fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtab[jj1][cpt]]);\r
         fprintf(fichtm," ************\n<hr size=\"2\" color=\"#EC5E5E\">");\r
        }\r
-       fprintf(fichtm,"<br>- Probabilities: pe%s%d.png<br>\r
-<img src=\"pe%s%d.png\">",strtok(optionfile, "."),jj1,strtok(optionfile, "."),jj1);     \r
+       /* Pij */\r
+       fprintf(fichtm,"<br>- Pij or Conditional probabilities to be observed in state j being in state i %d (stepm) months before: pe%s%d1.png<br>\r
+<img src=\"pe%s%d1.png\">",strtok(optionfile, "."),jj1,stepm,strtok(optionfile, "."),jj1);     \r
+       /* Quasi-incidences */\r
+       fprintf(fichtm,"<br>- Pij or Conditional probabilities to be observed in state j being in state i %d (stepm) months before but expressed in per year i.e. quasi incidences if stepm is small and probabilities too: pe%s%d2.png<br>\r
+<img src=\"pe%s%d2.png\">",strtok(optionfile, "."),jj1,stepm,strtok(optionfile, "."),jj1);     \r
+       /* Stable prevalence in each health state */\r
        for(cpt=1; cpt<nlstate;cpt++){\r
-        fprintf(fichtm,"<br>- Prevalence of disability : p%s%d%d.png<br>\r
+        fprintf(fichtm,"<br>- Stable prevalence in each health state : p%s%d%d.png<br>\r
 <img src=\"p%s%d%d.png\">",strtok(optionfile, "."),cpt,jj1,strtok(optionfile, "."),cpt,jj1);\r
        }\r
     for(cpt=1; cpt<=nlstate;cpt++) {\r
@@ -2145,7 +2156,7 @@ fclose(fichtm);
 void printinggnuplot(char fileres[],char optionfilefiname[],char optionfile[],char optionfilegnuplot[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){\r
 \r
   int m,cpt,k1,i,k,j,jk,k2,k3,ij,l;\r
-\r
+  int ng;\r
   strcpy(optionfilegnuplot,optionfilefiname);\r
   strcat(optionfilegnuplot,".gp.txt");\r
   if((ficgp=fopen(optionfilegnuplot,"w"))==NULL) {\r
@@ -2162,11 +2173,11 @@ m=pow(2,cptcoveff);
    for (k1=1; k1<= m ; k1 ++) {\r
 \r
 #ifdef windows\r
-     fprintf(ficgp,"\nset out \"v%s%d%d.png\" \n\n",strtok(optionfile, "."),cpt,k1);\r
+     fprintf(ficgp,"\nset out \"v%s%d%d.png\" \n",strtok(optionfile, "."),cpt,k1);\r
      fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter png small\nset size 0.65,0.65\nplot [%.f:%.f] \"vpl%s\" every :::%d::%d u 1:2 \"\%%lf",ageminpar,fage,fileres,k1-1,k1-1);\r
 #endif\r
 #ifdef unix\r
-fprintf(ficgp,"\nset out \"v%s%d%d.png\" \n\n",strtok(optionfile, "."),cpt,k1);\r
+fprintf(ficgp,"\nset out \"v%s%d%d.png\" \n",strtok(optionfile, "."),cpt,k1);\r
 fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nplot [%.f:%.f] \"vpl%s\" u 1:2 \"\%%lf",ageminpar,fage,fileres);\r
 #endif\r
 \r
@@ -2193,7 +2204,7 @@ fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65\n");
   /*2 eme*/\r
 \r
   for (k1=1; k1<= m ; k1 ++) { \r
-    fprintf(ficgp,"\nset out \"e%s%d.png\" \n\n",strtok(optionfile, "."),k1);\r
+    fprintf(ficgp,"\nset out \"e%s%d.png\" \n",strtok(optionfile, "."),k1);\r
     fprintf(ficgp,"set ylabel \"Years\" \nset ter png small\nset size 0.65,0.65\nplot [%.f:%.f] ",ageminpar,fage);\r
     \r
     for (i=1; i<= nlstate+1 ; i ++) {\r
@@ -2226,7 +2237,7 @@ fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65\n");
   for (k1=1; k1<= m ; k1 ++) { \r
     for (cpt=1; cpt<= nlstate ; cpt ++) {\r
       k=2+nlstate*(2*cpt-2);\r
-      fprintf(ficgp,"\nset out \"exp%s%d%d.png\" \n\n",strtok(optionfile, "."),cpt,k1);\r
+      fprintf(ficgp,"\nset out \"exp%s%d%d.png\" \n",strtok(optionfile, "."),cpt,k1);\r
       fprintf(ficgp,"set ter png small\nset size 0.65,0.65\nplot [%.f:%.f] \"e%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",ageminpar,fage,fileres,k1-1,k1-1,k,cpt);\r
       /*fprintf(ficgp,",\"e%s\" every :::%d::%d u 1:($%d-2*$%d) \"\%%lf ",fileres,k1-1,k1-1,k,k+1);\r
  for (i=1; i<= nlstate*2 ; i ++) fprintf(ficgp,"\%%lf (\%%lf) ");\r
@@ -2247,7 +2258,7 @@ fprintf(ficgp,"\" t \"e%d1\" w l",cpt);
     for (k1=1; k1<= m ; k1 ++) { \r
     for (cpt=1; cpt<nlstate ; cpt ++) {\r
       k=3;\r
-      fprintf(ficgp,"set out \"p%s%d%d.png\" \n\n",strtok(optionfile, "."),cpt,k1);\r
+      fprintf(ficgp,"\nset out \"p%s%d%d.png\" \n",strtok(optionfile, "."),cpt,k1);\r
       fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter png small\nset size 0.65,0.65\nplot [%.f:%.f] \"pij%s\" u ($1==%d ? ($3):1/0):($%d/($%d",ageminpar,agemaxpar,fileres,k1,k+cpt+1,k+1);\r
 \r
       for (i=1; i< nlstate ; i ++)\r
@@ -2278,47 +2289,55 @@ fprintf(ficgp,"\" t \"e%d1\" w l",cpt);
     }\r
    }\r
 \r
-   for(jk=1; jk <=m; jk++) {\r
-     fprintf(ficgp,"\nset out \"pe%s%d.png\" \n\n",strtok(optionfile, "."),jk); \r
-     fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65\nset log y\nplot  [%.f:%.f] ",ageminpar,agemaxpar);\r
-     i=1;\r
-     for(k2=1; k2<=nlstate; k2++) {\r
-       k3=i;\r
-       for(k=1; k<=(nlstate+ndeath); k++) {\r
-        if (k != k2){\r
-          fprintf(ficgp," exp(p%d+p%d*x",i,i+1);\r
-          ij=1;\r
-          for(j=3; j <=ncovmodel; j++) {\r
-            if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) {\r
-              fprintf(ficgp,"+p%d*%d*x",i+j-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);\r
-              ij++;\r
-            }\r
+   for(ng=1; ng<=2;ng++){ /* Number of graphics: first is probabilities second is incidence per year*/\r
+     for(jk=1; jk <=m; jk++) {\r
+       fprintf(ficgp,"\nset out \"pe%s%d%d.png\" \n",strtok(optionfile, "."),jk,ng); \r
+       if (ng==2)\r
+        fprintf(ficgp,"\nset ylabel \"Quasi-incidence per year\"\n");\r
+       else\r
+        fprintf(ficgp,"\nset title \"Probability\"\n");\r
+       fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65\nset log y\nplot  [%.f:%.f] ",ageminpar,agemaxpar);\r
+       i=1;\r
+       for(k2=1; k2<=nlstate; k2++) {\r
+        k3=i;\r
+        for(k=1; k<=(nlstate+ndeath); k++) {\r
+          if (k != k2){\r
+            if(ng==2)\r
+              fprintf(ficgp," %f*exp(p%d+p%d*x",stepm/YEARM,i,i+1);\r
             else\r
-              fprintf(ficgp,"+p%d*%d",i+j-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]);\r
-          }\r
-          fprintf(ficgp,")/(1");\r
-          \r
-          for(k1=1; k1 <=nlstate; k1++){   \r
-            fprintf(ficgp,"+exp(p%d+p%d*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1);\r
+              fprintf(ficgp," exp(p%d+p%d*x",i,i+1);\r
             ij=1;\r
-            for(j=3; j <=ncovmodel; j++){\r
+            for(j=3; j <=ncovmodel; j++) {\r
               if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) {\r
-                fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);\r
+                fprintf(ficgp,"+p%d*%d*x",i+j-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);\r
                 ij++;\r
               }\r
               else\r
-                fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][j-2]]);\r
+                fprintf(ficgp,"+p%d*%d",i+j-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]);\r
             }\r
-            fprintf(ficgp,")");\r
+            fprintf(ficgp,")/(1");\r
+            \r
+            for(k1=1; k1 <=nlstate; k1++){   \r
+              fprintf(ficgp,"+exp(p%d+p%d*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1);\r
+              ij=1;\r
+              for(j=3; j <=ncovmodel; j++){\r
+                if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) {\r
+                  fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);\r
+                  ij++;\r
+                }\r
+                else\r
+                  fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][j-2]]);\r
+              }\r
+              fprintf(ficgp,")");\r
+            }\r
+            fprintf(ficgp,") t \"p%d%d\" ", k2,k);\r
+            if ((k+k2)!= (nlstate*2+ndeath)) fprintf(ficgp,",");\r
+            i=i+ncovmodel;\r
           }\r
-          fprintf(ficgp,") t \"p%d%d\" ", k2,k);\r
-          if ((k+k2)!= (nlstate*2+ndeath)) fprintf(ficgp,",");\r
-          i=i+ncovmodel;\r
         }\r
        }\r
      }\r
    }\r
-   \r
    fclose(ficgp);\r
 }  /* end gnuplot */\r
 \r
@@ -3266,7 +3285,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){
 \r
 /*--------- index.htm --------*/\r
 \r
-  printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm,rfileres,optionfilegnuplot,version,popforecast,estepm);\r
+  printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm,rfileres,optionfilegnuplot,version,popforecast,estepm,jprev1,mprev1,anprev1,jprev2,mprev2,anprev2);\r
 \r
   \r
   /*--------------- Prevalence limit --------------*/\r