Diff for /imach/src/imach.c between versions 1.42 and 1.43

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

Removed from v.1.42  
changed lines
  Added in v.1.43


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