Diff for /imach/src/imach.c between versions 1.254 and 1.255

version 1.254, 2017/03/08 07:13:00 version 1.255, 2017/03/08 16:02:28
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.255  2017/03/08 16:02:28  brouard
     Summary: IMaCh version 0.99r10 bugs in gnuplot fixed
   
   Revision 1.254  2017/03/08 07:13:00  brouard    Revision 1.254  2017/03/08 07:13:00  brouard
   Summary: Fixing data parameter line    Summary: Fixing data parameter line
   
Line 2400  void powell(double p[], double **xi, int Line 2403  void powell(double p[], double **xi, int
             flatd++;              flatd++;
         }          }
         if(flatd >0){          if(flatd >0){
           printf("%d flat directions\n",flatd);            printf("%d flat directions: ",flatd);
           fprintf(ficlog,"%d flat directions\n",flatd);            fprintf(ficlog,"%d flat directions :",flatd);
           for (j=1;j<=n;j++) {             for (j=1;j<=n;j++) { 
             if(flatdir[j]>0){              if(flatdir[j]>0){
               printf("%d ",j);                printf("%d ",j);
Line 6459  divided by h: <sub>h</sub>P<sub>ij</sub> Line 6462  divided by h: <sub>h</sub>P<sub>ij</sub>
      }       }
      /* Period (stable) prevalence in each health state */       /* Period (stable) prevalence in each health state */
      for(cpt=1; cpt<=nlstate;cpt++){       for(cpt=1; cpt<=nlstate;cpt++){
        fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \         fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d some years earlier, knowing that we will be in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \
 <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);  <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
      }       }
      if(backcast==1){       if(backcast==1){
        /* Period (stable) back prevalence in each health state */         /* Period (stable) back prevalence in each health state */
        for(cpt=1; cpt<=nlstate;cpt++){         for(cpt=1; cpt<=nlstate;cpt++){
          fprintf(fichtm,"<br>\n- Convergence to period (stable) back prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \           fprintf(fichtm,"<br>\n- Convergence to mixed (stable) back prevalence in state %d. Or probability to be in state %d at a younger age, knowing that we will be in state (1 to %d) at different older ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \
 <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);  <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
        }         }
      }       }
Line 6929  set ter svg size 640, 480\nunset log y\n Line 6932  set ter svg size 640, 480\nunset log y\n
   for(nres=1; nres <= nresult; nres++){ /* For each resultline */    for(nres=1; nres <= nresult; nres++){ /* For each resultline */
     if(m != 1 && TKresult[nres]!= k1)      if(m != 1 && TKresult[nres]!= k1)
       continue;        continue;
     for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */      for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */
               
       fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt);        fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt);
       for (k=1; k<=cptcoveff; k++){    /* For each covariate and each value */        for (k=1; k<=cptcoveff; k++){    /* For each covariate and each value */
Line 6953  set ter svg size 640, 480\nunset log y\n Line 6956  set ter svg size 640, 480\nunset log y\n
       fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\        fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
 set ter svg size 640, 480\nunset log y\nplot [%.f:%.f]  ", ageminpar, agemaxpar);  set ter svg size 640, 480\nunset log y\nplot [%.f:%.f]  ", ageminpar, agemaxpar);
       k=3; /* Offset */        k=3; /* Offset */
       for (i=1; i<= nlstate ; i ++){        for (i=1; i<= nlstate ; i ++){ /* State of origin */
         if(i==1)          if(i==1)
           fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_"));            fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_"));
         else          else
           fprintf(ficgp,", '' ");            fprintf(ficgp,", '' ");
         l=(nlstate+ndeath)*(i-1)+1;          l=(nlstate+ndeath)*(i-1)+1; /* 1, 1+ nlstate+ndeath, 1+2*(nlstate+ndeath) */
         fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l);          fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l);
         for (j=2; j<= nlstate ; j ++)          for (j=2; j<= nlstate ; j ++)
           fprintf(ficgp,"+$%d",k+l+j-1);            fprintf(ficgp,"+$%d",k+l+j-1);
Line 6976  set ter svg size 640, 480\nunset log y\n Line 6979  set ter svg size 640, 480\nunset log y\n
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       if(m != 1 && TKresult[nres]!= k1)        if(m != 1 && TKresult[nres]!= k1)
         continue;          continue;
       for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */        for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life ending state */
         fprintf(ficgp,"\n#\n#\n#CV Back preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt);          fprintf(ficgp,"\n#\n#\n#CV Back preval stable (period): 'pijb' files, covariatecombination#=%d state=%d",k1, cpt);
         for (k=1; k<=cptcoveff; k++){    /* For each covariate and each value */          for (k=1; k<=cptcoveff; k++){    /* For each covariate and each value */
           lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate number corresponding to k1 combination */            lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate number corresponding to k1 combination */
           /* decodtabm(1,1,4) = 1 because h=1  k= (1) 1  1  1 */            /* decodtabm(1,1,4) = 1 because h=1  k= (1) 1  1  1 */
Line 6999  set ter svg size 640, 480\nunset log y\n Line 7002  set ter svg size 640, 480\nunset log y\n
         fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\          fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
 set ter svg size 640, 480\nunset log y\nplot [%.f:%.f]  ", ageminpar, agemaxpar);  set ter svg size 640, 480\nunset log y\nplot [%.f:%.f]  ", ageminpar, agemaxpar);
         k=3; /* Offset */          k=3; /* Offset */
         for (i=1; i<= nlstate ; i ++){          for (i=1; i<= nlstate ; i ++){ /* State of origin */
           if(i==1)            if(i==1)
             fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJB_"));              fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJB_"));
           else            else
             fprintf(ficgp,", '' ");              fprintf(ficgp,", '' ");
           /* l=(nlstate+ndeath)*(i-1)+1; */            /* l=(nlstate+ndeath)*(i-1)+1; */
           l=(nlstate+ndeath)*(cpt-1)+1;            l=(nlstate+ndeath)*(cpt-1)+1; /* fixed for i; cpt=1 1, cpt=2 1+ nlstate+ndeath, 1+2*(nlstate+ndeath) */
           /* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); /\* a vérifier *\/ */            /* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); /\* a vérifier *\/ */
           /* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l+(cpt-1)+i-1); /\* a vérifier *\/ */            /* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l+(cpt-1)+i-1); /\* a vérifier *\/ */
           fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d",k1,k+l+(cpt-1)+i-1); /* a vérifier */            fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d",k1,k+l+i-1); /* To be verified */
           /* for (j=2; j<= nlstate ; j ++) */            /* for (j=2; j<= nlstate ; j ++) */
           /*    fprintf(ficgp,"+$%d",k+l+j-1); */            /*    fprintf(ficgp,"+$%d",k+l+j-1); */
           /*    /\* fprintf(ficgp,"+$%d",k+l+j-1); *\/ */            /*    /\* fprintf(ficgp,"+$%d",k+l+j-1); *\/ */
Line 9566  int back_prevalence_limit(double *p, dou Line 9569  int back_prevalence_limit(double *p, dou
         fprintf(ficresplb," %.3f %d\n", tot, *ncvyearp);          fprintf(ficresplb," %.3f %d\n", tot, *ncvyearp);
       } /* Age */        } /* Age */
       /* was end of cptcod */        /* was end of cptcod */
         /*fprintf(ficresplb,"\n");*/ /* Seems to be necessary for gnuplot only if two result lines and no covariate. */
     } /* end of any combination */      } /* end of any combination */
   } /* end of nres */      } /* end of nres */  
   /* hBijx(p, bage, fage); */    /* hBijx(p, bage, fage); */
Line 9682  int hPijx(double *p, int bage, int fage) Line 9686  int hPijx(double *p, int bage, int fage)
       
   /* hstepm=1;   aff par mois*/    /* hstepm=1;   aff par mois*/
   pstamp(ficrespijb);    pstamp(ficrespijb);
   fprintf(ficrespijb,"#****** h Pij x Back Probability to be in state i at age x-h being in j at x ");    fprintf(ficrespijb,"#****** h Bij x Back probability to be in state i at age x-h being in j at x: B1j+B2j+...=1 ");
   i1= pow(2,cptcoveff);    i1= pow(2,cptcoveff);
   /* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */    /* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */
   /*    /\*for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){*\/ */    /*    /\*for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){*\/ */
Line 9716  int hPijx(double *p, int bage, int fage) Line 9720  int hPijx(double *p, int bage, int fage)
         /* hbxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);   */          /* hbxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);   */
         hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm, k);          hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm, k);
         /* hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm,oldm,savm, dnewm, doldm, dsavm, k); */          /* hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm,oldm,savm, dnewm, doldm, dsavm, k); */
         fprintf(ficrespijb,"# Cov Agex agex-h hpijx with i,j=");          fprintf(ficrespijb,"# Cov Agex agex-h hbijx with i,j=");
         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(ficrespijb," %1d-%1d",i,j);              fprintf(ficrespijb," %1d-%1d",i,j);

Removed from v.1.254  
changed lines
  Added in v.1.255


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