Diff for /imach/src/imach.c between versions 1.48 and 1.49

version 1.48, 2002/06/10 13:12:49 version 1.49, 2002/06/20 14:03:39
Line 84 Line 84
 char version[80]="Imach version 0.8h, May 2002, INED-EUROREVES ";  char version[80]="Imach version 0.8h, May 2002, INED-EUROREVES ";
 int erreur; /* Error number */  int erreur; /* Error number */
 int nvar;  int nvar;
 int cptcovn, cptcovage=0, cptcoveff=0,cptcov;  int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov;
 int npar=NPARMAX;  int npar=NPARMAX;
 int nlstate=2; /* Number of live states */  int nlstate=2; /* Number of live states */
 int ndeath=1; /* Number of dead states */  int ndeath=1; /* Number of dead states */
Line 1939  void varprevlim(char fileres[], double * Line 1939  void varprevlim(char fileres[], double *
 /************ Variance of one-step probabilities  ******************/  /************ Variance of one-step probabilities  ******************/
 void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax)  void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax)
 {  {
   int i, j,  i1, k1, l1;    int i, j=0,  i1, k1, l1, t, tj;
   int k2, l2, j1,  z1;    int k2, l2, j1,  z1;
   int k=0,l, cptcode;    int k=0,l, cptcode;
   int first=1;    int first=1;
Line 2012  void varprob(char optionfilefiname[], do Line 2012  void varprob(char optionfilefiname[], do
     exit(0);      exit(0);
   }    }
   else{    else{
     fprintf(fichtm,"\n<H2> Computing matrix of variance-covariance of step probabilities</h2>\n");      fprintf(fichtm,"\n<li><h4> Computing matrix of variance-covariance of step probabilities</h4></li>\n");
     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");      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");
     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");      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");
   
   }    }
   
    
   cov[1]=1;    cov[1]=1;
   j=cptcoveff;    tj=cptcoveff;
   if (cptcovn<1) {j=1;ncodemax[1]=1;}    if (cptcovn<1) {tj=1;ncodemax[1]=1;}
   j1=0;    j1=0;
   for(k1=1; k1<=1;k1++){    for(t=1; t<=tj;t++){
     for(i1=1; i1<=ncodemax[k1];i1++){      for(i1=1; i1<=ncodemax[t];i1++){
     j1++;        j1++;
        
     if  (cptcovn>0) {        if  (cptcovn>0) {
       fprintf(ficresprob, "\n#********** Variable ");          fprintf(ficresprob, "\n#********** Variable ");
       fprintf(ficresprobcov, "\n#********** Variable ");          for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
       fprintf(ficgp, "\n#********** Variable ");          fprintf(ficresprob, "**********\n#");
       fprintf(fichtm, "\n<h4>********** Variable</h4>\n ");          fprintf(ficresprobcov, "\n#********** Variable ");
       fprintf(ficresprobcor, "\n#********** Variable ");          for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
       for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);          fprintf(ficresprobcov, "**********\n#");
       fprintf(ficresprob, "**********\n#");         
       for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);          fprintf(ficgp, "\n#********** Variable ");
       fprintf(ficresprobcov, "**********\n#");          for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, "# V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
       for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);          fprintf(ficgp, "**********\n#");
       fprintf(ficgp, "**********\n#");         
       for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, "# V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);         
       fprintf(ficgp, "**********\n#");          fprintf(fichtm, "\n<hr  size=\"2\" color=\"#EC5E5E\">********** Variable ");
       for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);          for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
       fprintf(fichtm, "**********\n#");          fprintf(fichtm, "**********\n<hr size=\"2\" color=\"#EC5E5E\">");
     }         
              fprintf(ficresprobcor, "\n#********** Variable ");    
           for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
           fprintf(ficgp, "**********\n#");    
         }
        
       for (age=bage; age<=fage; age ++){        for (age=bage; age<=fage; age ++){
         cov[2]=age;          cov[2]=age;
         for (k=1; k<=cptcovn;k++) {          for (k=1; k<=cptcovn;k++) {
Line 2169  void varprob(char optionfilefiname[], do Line 2175  void varprob(char optionfilefiname[], do
                     fprintf(ficgp,"\nset parametric;set nolabel");                      fprintf(ficgp,"\nset parametric;set nolabel");
                     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);                      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);
                     fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65");                      fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65");
                     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);                      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);
                     fprintf(fichtm,"\n<br><img src=\"varpijgr%s%1d%1d-%1d%1d.png\">, ",optionfilefiname,k2,l2,k1,l1);                      fprintf(fichtm,"\n<br><img src=\"varpijgr%s%d%1d%1d-%1d%1d.png\"> ",optionfilefiname, j1,k2,l2,k1,l1);
                     fprintf(ficgp,"\nset out \"varpijgr%s%1d%1d-%1d%1d.png\"",optionfilefiname,k2,l2,k1,l1);                      fprintf(ficgp,"\nset out \"varpijgr%s%d%1d%1d-%1d%1d.png\"",optionfilefiname, j1,k2,l2,k1,l1);
                     fprintf(ficgp,"\nset label \"%d\" at %11.3e,%11.3e center",(int) age, mu2,mu1);                      fprintf(ficgp,"\nset label \"%d\" at %11.3e,%11.3e center",(int) age, mu2,mu1);
                     fprintf(ficgp,"\n# Age %d, p%1d%1d - p%1d%1d",(int) age, k2,l2,k1,l1);                      fprintf(ficgp,"\n# Age %d, p%1d%1d - p%1d%1d",(int) age, k2,l2,k1,l1);
                     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\"",\                      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\"",\
Line 2187  void varprob(char optionfilefiname[], do Line 2193  void varprob(char optionfilefiname[], do
                   }/* if first */                    }/* if first */
                 } /* age mod 5 */                  } /* age mod 5 */
               } /* end loop age */                } /* end loop age */
               fprintf(ficgp,"\nset out \"varpijgr%s%1d%1d-%1d%1d.png\";replot;",optionfilefiname,k2,l2,k1,l1);                fprintf(ficgp,"\nset out \"varpijgr%s%d%1d%1d-%1d%1d.png\";replot;",optionfilefiname, j1,k2,l2,k1,l1);
               first=1;                first=1;
             } /*l12 */              } /*l12 */
           } /* k12 */            } /* k12 */
Line 2223  void printinghtml(char fileres[], char t Line 2229  void printinghtml(char fileres[], char t
     printf("Problem with %s \n",optionfilehtm), exit(0);      printf("Problem with %s \n",optionfilehtm), exit(0);
   }    }
   
    fprintf(fichtm,"<ul><li>Result files (first order: no variance)<br>\n     fprintf(fichtm,"<ul><li><h4>Result files (first order: no variance)</h4>\n
  - 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   - 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
  - Estimated transition probabilities over %d (stepm) months: <a href=\"pij%s\">pij%s</a><br>\n   - Estimated transition probabilities over %d (stepm) months: <a href=\"pij%s\">pij%s</a><br>\n
  - Stable prevalence in each health state: <a href=\"pl%s\">pl%s</a> <br>\n   - Stable prevalence in each health state: <a href=\"pl%s\">pl%s</a> <br>\n
Line 2231  void printinghtml(char fileres[], char t Line 2237  void printinghtml(char fileres[], char t
    <a href=\"e%s\">e%s</a> <br>\n</li>", \     <a href=\"e%s\">e%s</a> <br>\n</li>", \
   jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,fileres,fileres,stepm,fileres,fileres,fileres,fileres,estepm,fileres,fileres);    jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,fileres,fileres,stepm,fileres,fileres,fileres,fileres,estepm,fileres,fileres);
   
  fprintf(fichtm,"\n<li> Result files (second order: variances)<br>\n   fprintf(fichtm,"\n<br><li><h4> Result files (second order: variances)</h4>\n
  - Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n   - Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n
  - Variance of one-step probabilities: <a href=\"prob%s\">prob%s</a> <br>\n   - Variance of one-step probabilities: <a href=\"prob%s\">prob%s</a> <br>\n
  - Variance-covariance of one-step probabilities: <a href=\"probcov%s\">probcov%s</a> <br>\n   - Variance-covariance of one-step probabilities: <a href=\"probcov%s\">probcov%s</a> <br>\n
Line 2246  void printinghtml(char fileres[], char t Line 2252  void printinghtml(char fileres[], char t
         <br>",fileres,fileres,fileres,fileres);          <br>",fileres,fileres,fileres,fileres);
  else   else
    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);     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);
 fprintf(fichtm," <li>Graphs</li><p>");  fprintf(fichtm," <li><b>Graphs</b></li><p>");
   
  m=cptcoveff;   m=cptcoveff;
  if (cptcovn < 1) {m=1;ncodemax[1]=1;}   if (cptcovn < 1) {m=1;ncodemax[1]=1;}
Line 3415  Title=%s <br>Datafile=%s Firstpass=%d La Line 3421  Title=%s <br>Datafile=%s Firstpass=%d La
 Total number of observations=%d <br>\n  Total number of observations=%d <br>\n
 Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n  Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n
 <hr  size=\"2\" color=\"#EC5E5E\">  <hr  size=\"2\" color=\"#EC5E5E\">
  <ul><li>Parameter files<br>\n   <ul><li><h4>Parameter files</h4>\n
  - Copy of the parameter file: <a href=\"o%s\">o%s</a><br>\n   - Copy of the parameter file: <a href=\"o%s\">o%s</a><br>\n
  - 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);   - 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);
   fclose(fichtm);    fclose(fichtm);
   
  printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,jprev1,mprev1,anprev1,jprev2,mprev2,anprev2);   printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,jprev1,mprev1,anprev1,jprev2,mprev2,anprev2);
Line 3495  Interval (in months) between two waves: Line 3501  Interval (in months) between two waves:
   agelim=AGESUP;    agelim=AGESUP;
   hstepm=stepsize*YEARM; /* Every year of age */    hstepm=stepsize*YEARM; /* Every year of age */
   hstepm=hstepm/stepm; /* Typically 2 years, = 2/6 months = 4 */    hstepm=hstepm/stepm; /* Typically 2 years, = 2/6 months = 4 */
    
     /* hstepm=1;   aff par mois*/
   
   k=0;    k=0;
   for(cptcov=1;cptcov<=i1;cptcov++){    for(cptcov=1;cptcov<=i1;cptcov++){
     for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){      for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){
Line 3508  Interval (in months) between two waves: Line 3516  Interval (in months) between two waves:
         for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */          for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */
           nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */            nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */
           nhstepm = nhstepm/hstepm; /* Typically 40/4=10 */            nhstepm = nhstepm/hstepm; /* Typically 40/4=10 */
   
             /*      nhstepm=nhstepm*YEARM; aff par mois*/
   
           p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);            p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
           oldm=oldms;savm=savms;            oldm=oldms;savm=savms;
           hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);              hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);  
Line 3517  Interval (in months) between two waves: Line 3528  Interval (in months) between two waves:
               fprintf(ficrespij," %1d-%1d",i,j);                fprintf(ficrespij," %1d-%1d",i,j);
           fprintf(ficrespij,"\n");            fprintf(ficrespij,"\n");
            for (h=0; h<=nhstepm; h++){             for (h=0; h<=nhstepm; h++){
             fprintf(ficrespij,"%d %.0f %.0f",k,agedeb, agedeb+ h*hstepm/YEARM*stepm );              fprintf(ficrespij,"%d %f %f",k,agedeb, agedeb+ h*hstepm/YEARM*stepm );
             for(i=1; i<=nlstate;i++)              for(i=1; i<=nlstate;i++)
               for(j=1; j<=nlstate+ndeath;j++)                for(j=1; j<=nlstate+ndeath;j++)
                 fprintf(ficrespij," %.5f", p3mat[i][j][h]);                  fprintf(ficrespij," %.5f", p3mat[i][j][h]);

Removed from v.1.48  
changed lines
  Added in v.1.49


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>