Diff for /imach/src/imach.c between versions 1.337 and 1.338

version 1.337, 2022/09/02 14:26:02 version 1.338, 2022/09/04 17:40:33
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.338  2022/09/04 17:40:33  brouard
     Summary: 0.99r36
   
     * imach.c (Module): Now the easy runs i.e. without result or
     model=1+age only did not work. The defautl combination should be 1
     and not 0 because everything hasn't been tranformed yet.
   
   Revision 1.337  2022/09/02 14:26:02  brouard    Revision 1.337  2022/09/02 14:26:02  brouard
   Summary: version 0.99r35    Summary: version 0.99r35
   
Line 1517  int **nbcode, *Tvar; /**< model=V2 => Tv Line 1524  int **nbcode, *Tvar; /**< model=V2 => Tv
 /*TnsdVar[Tvar]   1   2                              3 */   /*TnsdVar[Tvar]   1   2                              3 */ 
 /*Tvaraff[nsd]     4   3                              1 */ /* ID of single dummy cova fixed or timevary*/  /*Tvaraff[nsd]     4   3                              1 */ /* ID of single dummy cova fixed or timevary*/
 /*TvarsD[nsd]     4   3                              1 */ /* ID of single dummy cova fixed or timevary*/  /*TvarsD[nsd]     4   3                              1 */ /* ID of single dummy cova fixed or timevary*/
 /*TvarsDind[k]    2   3                              9 */ /* position K of single dummy cova */  /*TvarsDind[nsd]  2   3                              9 */ /* position K of single dummy cova */
 /*    nsq      1                     2                 */ /* Counting single quantit tv */  /*    nsq      1                     2                 */ /* Counting single quantit tv */
 /* TvarsQ[k]   5                     2                 */ /* Number of single quantitative cova */  /* TvarsQ[k]   5                     2                 */ /* Number of single quantitative cova */
 /* TvarsQind   1                     6                 */ /* position K of single quantitative cova */  /* TvarsQind   1                     6                 */ /* position K of single quantitative cova */
Line 2510  void powell(double p[], double **xi, int Line 2517  void powell(double p[], double **xi, int
   xits=vector(1,n);     xits=vector(1,n); 
   *fret=(*func)(p);     *fret=(*func)(p); 
   for (j=1;j<=n;j++) pt[j]=p[j];     for (j=1;j<=n;j++) pt[j]=p[j]; 
   rcurr_time = time(NULL);      rcurr_time = time(NULL);
     fp=(*fret); /* Initialisation */
   for (*iter=1;;++(*iter)) {     for (*iter=1;;++(*iter)) { 
     ibig=0;       ibig=0; 
     del=0.0;       del=0.0; 
Line 2824  void powell(double p[], double **xi, int Line 2832  void powell(double p[], double **xi, int
       
   double **prevalim(double **prlim, int nlstate, double x[], double age, double **oldm, double **savm, double ftolpl, int *ncvyear, int ij, int nres)    double **prevalim(double **prlim, int nlstate, double x[], double age, double **oldm, double **savm, double ftolpl, int *ncvyear, int ij, int nres)
   {    {
     /**< Computes the prevalence limit in each live state at age x and for covariate combination ij       /**< Computes the prevalence limit in each live state at age x and for covariate combination ij . Nicely done
      *   (and selected quantitative values in nres)       *   (and selected quantitative values in nres)
      *  by left multiplying the unit       *  by left multiplying the unit
      *  matrix by transitions matrix until convergence is reached with precision ftolpl        *  matrix by transitions matrix until convergence is reached with precision ftolpl 
Line 5129  Title=%s <br>Datafile=%s Firstpass=%d La Line 5137  Title=%s <br>Datafile=%s Firstpass=%d La
                 /* }else  */ /* TODO TODO codtabm(j1,z1) or codtabm(j1,Tvaraff[z1]]z1)*/                  /* }else  */ /* TODO TODO codtabm(j1,z1) or codtabm(j1,Tvaraff[z1]]z1)*/
                 /* if( iind >=imx-3) printf("Searching error iind=%d Tvaraff[z1]=%d covar[Tvaraff[z1]][iind]=%.f TnsdVar[Tvaraff[z1]]=%d, cptcoveff=%d, cptcovs=%d \n",iind, Tvaraff[z1], covar[Tvaraff[z1]][iind],TnsdVar[Tvaraff[z1]],cptcoveff, cptcovs); */                  /* if( iind >=imx-3) printf("Searching error iind=%d Tvaraff[z1]=%d covar[Tvaraff[z1]][iind]=%.f TnsdVar[Tvaraff[z1]]=%d, cptcoveff=%d, cptcovs=%d \n",iind, Tvaraff[z1], covar[Tvaraff[z1]][iind],TnsdVar[Tvaraff[z1]],cptcoveff, cptcovs); */
                 if(Tvaraff[z1]<1 || Tvaraff[z1]>=NCOVMAX)                  if(Tvaraff[z1]<1 || Tvaraff[z1]>=NCOVMAX)
                   printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);                    printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=1+age+%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);
                 if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]){ /* for combination j1 of covariates */                  if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]){ /* for combination j1 of covariates */
                   /* Tests if the value of the covariate z1 for this individual iind responded to combination j1 (V4=1 V3=0) */                    /* Tests if the value of the covariate z1 for this individual iind responded to combination j1 (V4=1 V3=0) */
                   bool=0; /* bool should be equal to 1 to be selected, one covariate value failed */                    bool=0; /* bool should be equal to 1 to be selected, one covariate value failed */
Line 5439  Title=%s <br>Datafile=%s Firstpass=%d La Line 5447  Title=%s <br>Datafile=%s Firstpass=%d La
         printf("#  This combination (%d) is not valid and no result will be produced\n",j1);          printf("#  This combination (%d) is not valid and no result will be produced\n",j1);
         invalidvarcomb[j1]=1;          invalidvarcomb[j1]=1;
       }else{        }else{
         fprintf(ficresphtm,"\n <p> This combination (%d) is valid and result will be produced.</p>",j1);          fprintf(ficresphtm,"\n <p> This combination (%d) is valid and result will be produced (or no resultline).</p>",j1);
         invalidvarcomb[j1]=0;          invalidvarcomb[j1]=0;
       }        }
       fprintf(ficresphtmfr,"</table>\n");        fprintf(ficresphtmfr,"</table>\n");
Line 7208  To be simple, these graphs help to under Line 7216  To be simple, these graphs help to under
   
        /* Including quantitative variables of the resultline to be done */         /* Including quantitative variables of the resultline to be done */
        for (z1=1; z1<=cptcovs; z1++){ /* Loop on each variable of this resultline  */         for (z1=1; z1<=cptcovs; z1++){ /* Loop on each variable of this resultline  */
          printf("Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model);           printf("Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model);
          fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model);           fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model);
          /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */           /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */
          if(Dummy[modelresult[nres][z1]]==0){/* Dummy variable of the variable in position modelresult in the model corresponding to z1 in resultline  */           if(Dummy[modelresult[nres][z1]]==0){/* Dummy variable of the variable in position modelresult in the model corresponding to z1 in resultline  */
            if(Fixed[modelresult[nres][z1]]==0){ /* Fixed referenced to model equation */             if(Fixed[modelresult[nres][z1]]==0){ /* Fixed referenced to model equation */
              fprintf(ficresprob,"V%d=%d ",Tvresult[nres][z1],Tresult[nres][z1]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline  */               fprintf(ficresprob,"V%d=%d ",Tvresult[nres][z1],Tresult[nres][z1]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline  */
Line 7581  void printinghtml(char fileresu[], char Line 7589  void printinghtml(char fileresu[], char
    fprintf(fichtm," \n<ul>");     fprintf(fichtm," \n<ul>");
    for(nres=1; nres <= nresult; nres++){ /* For each resultline */     for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      /* k1=nres; */       /* k1=nres; */
      k1= TKresult[nres];       k1=TKresult[nres];
        if(TKresult[nres]==0)k1=1; /* To be checked for no result */
    /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */     /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
    /*   if(m != 1 && TKresult[nres]!= k1) */     /*   if(m != 1 && TKresult[nres]!= k1) */
    /*     continue; */     /*     continue; */
Line 7624  void printinghtml(char fileresu[], char Line 7633  void printinghtml(char fileresu[], char
   
    for(nres=1; nres <= nresult; nres++){ /* For each resultline */     for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      /* k1=nres; */       /* k1=nres; */
      k1= TKresult[nres];       k1=TKresult[nres];
        if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
    /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */     /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
    /*   if(m != 1 && TKresult[nres]!= k1) */     /*   if(m != 1 && TKresult[nres]!= k1) */
    /*     continue; */     /*     continue; */
Line 7649  void printinghtml(char fileresu[], char Line 7659  void printinghtml(char fileresu[], char
          /* printf(" V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]);fflush(stdout); */           /* printf(" V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]);fflush(stdout); */
        }         }
        /* if(nqfveff+nqtveff 0) */ /* Test to be done */         /* if(nqfveff+nqtveff 0) */ /* Test to be done */
        fprintf(fichtm," (model=%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);         fprintf(fichtm," (model=1+age+%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
        if(invalidvarcomb[k1]){         if(invalidvarcomb[k1]){
          fprintf(fichtm,"\n<h3>Combination (%d) ignored because no cases </h3>\n",k1);            fprintf(fichtm,"\n<h3>Combination (%d) ignored because no cases </h3>\n",k1); 
          printf("\nCombination (%d) ignored because no cases \n",k1);            printf("\nCombination (%d) ignored because no cases \n",k1); 
Line 7685  divided by h: <sub>h</sub>P<sub>ij</sub> Line 7695  divided by h: <sub>h</sub>P<sub>ij</sub>
      /* Period (forward stable) prevalence in each health state */       /* Period (forward 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 for a person being in state (1 to %d) at different ages, to be in state %d some years after. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br>", cpt, nlstate, cpt, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);         fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability for a person being in state (1 to %d) at different ages, to be in state %d some years after. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br>", cpt, nlstate, cpt, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
        fprintf(fichtm," (data from text file  <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"P_"),subdirf2(optionfilefiname,"P_"));         fprintf(fichtm," (data from text file  <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
       fprintf(fichtm,"<img src=\"%s_%d-%d-%d.svg\">" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);        fprintf(fichtm,"<img src=\"%s_%d-%d-%d.svg\">" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
      }       }
      if(prevbcast==1){       if(prevbcast==1){
        /* Backward prevalence in each health state */         /* Backward prevalence in each health state */
        for(cpt=1; cpt<=nlstate;cpt++){         for(cpt=1; cpt<=nlstate;cpt++){
          fprintf(fichtm,"<br>\n- Convergence to mixed (stable) back prevalence in state %d. Or probability for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older 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 for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br>", cpt, cpt, nlstate, 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);           fprintf(fichtm," (data from text file  <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"PIJB_"),subdirf2(optionfilefiname,"PIJB_"));
            fprintf(fichtm,"<img src=\"%s_%d-%d-%d.svg\">" ,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
        }         }
      }       }
      if(prevfcast==1){       if(prevfcast==1){
Line 7769  See page 'Matrix of variance-covariance Line 7780  See page 'Matrix of variance-covariance
 /*  - Population forecasting (if popforecast=1): <a href=\"pop%s\">pop%s</a> <br>\n */  /*  - Population forecasting (if popforecast=1): <a href=\"pop%s\">pop%s</a> <br>\n */
 /*      <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=1+age+%s (instead of .)<br><br></li>\n",popforecast, stepm, model); */
    fflush(fichtm);     fflush(fichtm);
   
    m=pow(2,cptcoveff);     m=pow(2,cptcoveff);
Line 7782  See page 'Matrix of variance-covariance Line 7793  See page 'Matrix of variance-covariance
    fprintf(fichtm," \n<ul>");     fprintf(fichtm," \n<ul>");
    for(nres=1; nres <= nresult; nres++){ /* For each resultline */     for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      /* k1=nres; */       /* k1=nres; */
      k1= TKresult[nres];       k1=TKresult[nres];
      /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */       /* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
      /* if(m != 1 && TKresult[nres]!= k1) */       /* if(m != 1 && TKresult[nres]!= k1) */
      /*   continue; */       /*   continue; */
Line 7812  See page 'Matrix of variance-covariance Line 7823  See page 'Matrix of variance-covariance
   
    for(nres=1; nres <= nresult; nres++){ /* For each resultline */     for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      /* k1=nres; */       /* k1=nres; */
      k1= TKresult[nres];       k1=TKresult[nres];
        if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
      /* for(k1=1; k1<=m;k1++){ */       /* for(k1=1; k1<=m;k1++){ */
      /* if(m != 1 && TKresult[nres]!= k1) */       /* if(m != 1 && TKresult[nres]!= k1) */
      /*   continue; */       /*   continue; */
Line 7832  See page 'Matrix of variance-covariance Line 7844  See page 'Matrix of variance-covariance
          /* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */           /* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */
        }         }
   
        fprintf(fichtm," (model=%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);         fprintf(fichtm," (model=1+age+%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
   
        if(invalidvarcomb[k1]){         if(invalidvarcomb[k1]){
          fprintf(fichtm,"\n<h4>Combination (%d) ignored because no cases </h4>\n",k1);            fprintf(fichtm,"\n<h4>Combination (%d) ignored because no cases </h4>\n",k1); 
Line 7933  void printinggnuplot(char fileresu[], ch Line 7945  void printinggnuplot(char fileresu[], ch
     /* for (k1=1; k1<= m ; k1 ++){ /\* For each valid combination of covariate *\/ */      /* for (k1=1; k1<= m ; k1 ++){ /\* For each valid combination of covariate *\/ */
       for(nres=1; nres <= nresult; nres++){ /* For each resultline */        for(nres=1; nres <= nresult; nres++){ /* For each resultline */
         k1=TKresult[nres];          k1=TKresult[nres];
           if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
         /* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */          /* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */
         /* if(m != 1 && TKresult[nres]!= k1) */          /* if(m != 1 && TKresult[nres]!= k1) */
         /*   continue; */          /*   continue; */
Line 7973  void printinggnuplot(char fileresu[], ch Line 7986  void printinggnuplot(char fileresu[], ch
         fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres);          fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
         fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres);          fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres);
         /* fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); */          /* fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); */
         fprintf(ficgp,"set title \"Alive state %d %s model=%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);          fprintf(ficgp,"set title \"Alive state %d %s model=1+age+%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);
         fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres);          fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres);
         /* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */          /* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */
       /* k1-1 error should be nres-1*/        /* k1-1 error should be nres-1*/
Line 8080  void printinggnuplot(char fileresu[], ch Line 8093  void printinggnuplot(char fileresu[], ch
   /* for (k1=1; k1<= m ; k1 ++){   */    /* for (k1=1; k1<= m ; k1 ++){   */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* if(m != 1 && TKresult[nres]!= k1) */        /* if(m != 1 && TKresult[nres]!= k1) */
       /*        continue; */        /*        continue; */
       fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files ");        fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files ");
Line 8151  void printinggnuplot(char fileresu[], ch Line 8165  void printinggnuplot(char fileresu[], ch
   /* for (k1=1; k1<= m ; k1 ++){ */    /* for (k1=1; k1<= m ; k1 ++){ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* if(m != 1 && TKresult[nres]!= k1) */        /* if(m != 1 && TKresult[nres]!= k1) */
       /*        continue; */        /*        continue; */
   
Line 8212  plot [%.f:%.f] \"%s\" every :::%d::%d u Line 8227  plot [%.f:%.f] \"%s\" every :::%d::%d u
   /* for (k1=1; k1<=m; k1++){    /\* For each covariate and each value *\/ */    /* for (k1=1; k1<=m; k1++){    /\* For each covariate and each value *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* if(m != 1 && TKresult[nres]!= k1) */        /* if(m != 1 && TKresult[nres]!= k1) */
       /*        continue; */        /*        continue; */
       for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/        for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/
Line 8269  set ter svg size 640, 480\nunset log y\n Line 8285  set ter svg size 640, 480\nunset log y\n
   /* for (k1=1; k1<= m ; k1++){ /\* For each covariate combination if any *\/ */    /* for (k1=1; k1<= m ; k1++){ /\* For each covariate combination if any *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* if(m != 1 && TKresult[nres]!= k1) */        /* if(m != 1 && TKresult[nres]!= k1) */
       /*        continue; */        /*        continue; */
       for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state  */        for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state  */
Line 8334  set ter svg size 640, 480\nunset log y\n Line 8351  set ter svg size 640, 480\nunset log y\n
   /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */    /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
   for(nres=1; nres <= nresult; nres++){ /* For each resultline */    for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      k1=TKresult[nres];       k1=TKresult[nres];
        if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
      /* if(m != 1 && TKresult[nres]!= k1) */       /* if(m != 1 && TKresult[nres]!= k1) */
      /*  continue; */       /*  continue; */
     for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */      for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */
Line 8391  set ter svg size 640, 480\nunset log y\n Line 8409  set ter svg size 640, 480\nunset log y\n
     /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */      /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* if(m != 1 && TKresult[nres]!= k1) */        /* if(m != 1 && TKresult[nres]!= k1) */
       /*        continue; */        /*        continue; */
       for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life origin state */        for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life origin state */
Line 8453  set ter svg size 640, 480\nunset log y\n Line 8472  set ter svg size 640, 480\nunset log y\n
     /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */      /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k1=TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       /* 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 */
Line 8574  set ter svg size 640, 480\nunset log y\n Line 8594  set ter svg size 640, 480\nunset log y\n
     /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */      /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      k1=TKresult[nres];       k1=TKresult[nres];
        if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
        /* 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 */
Line 8651  set ter svg size 640, 480\nunset log y\n Line 8672  set ter svg size 640, 480\nunset log y\n
             kl=0;              kl=0;
             strcpy(gplotcondition,"(");              strcpy(gplotcondition,"(");
             for (k=1; k<=cptcovs; k++){    /* For each covariate k of the resultline, get corresponding value lv for combination k1 */              for (k=1; k<=cptcovs; k++){    /* For each covariate k of the resultline, get corresponding value lv for combination k1 */
               if(Dummy[Tvresult[nres][k]]==0){  /* To be verified */                if(Dummy[modelresult[nres][k]]==0){  /* To be verified */
                 /* for (k=1; k<=cptcoveff; k++){    /\* For each covariate writing the chain of conditions *\/ */                  /* for (k=1; k<=cptcoveff; k++){    /\* For each covariate writing the chain of conditions *\/ */
                 /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */                  /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
                 /* lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */                  /* lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
Line 8666  set ter svg size 640, 480\nunset log y\n Line 8687  set ter svg size 640, 480\nunset log y\n
                 /* sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]); */                  /* sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]); */
                 sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%lg " ,kl,Tvresult[nres][k], kl+1,TinvDoQresult[nres][Tvresult[nres][k]]);                  sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%lg " ,kl,Tvresult[nres][k], kl+1,TinvDoQresult[nres][Tvresult[nres][k]]);
                 kl++;                  kl++;
                 if(k <cptcoveff && cptcoveff>1)                  if(k <cptcovs && cptcovs>1)
                   sprintf(gplotcondition+strlen(gplotcondition)," && ");                    sprintf(gplotcondition+strlen(gplotcondition)," && ");
               }                }
             }              }
Line 8733  set ter svg size 640, 480\nunset log y\n Line 8754  set ter svg size 640, 480\nunset log y\n
   fprintf(ficgp,"#\n");    fprintf(ficgp,"#\n");
   for(ng=1; ng<=3;ng++){ /* Number of graphics: first is logit, 2nd is probabilities, third is incidences per year*/    for(ng=1; ng<=3;ng++){ /* Number of graphics: first is logit, 2nd is probabilities, third is incidences per year*/
     fprintf(ficgp,"#Number of graphics: first is logit, 2nd is probabilities, third is incidences per year\n");      fprintf(ficgp,"#Number of graphics: first is logit, 2nd is probabilities, third is incidences per year\n");
     fprintf(ficgp,"#model=%s \n",model);      fprintf(ficgp,"#model=1+age+%s \n",model);
     fprintf(ficgp,"# Type of graphic ng=%d\n",ng);      fprintf(ficgp,"# Type of graphic ng=%d\n",ng);
     fprintf(ficgp,"#   k1=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */      fprintf(ficgp,"#   k1=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */
     /* for(k1=1; k1 <=m; k1++)  /\* For each combination of covariate *\/ */      /* for(k1=1; k1 <=m; k1++)  /\* For each combination of covariate *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      /* k1=nres; */       /* k1=nres; */
       k1= TKresult[nres];        k1=TKresult[nres];
         if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
       fprintf(ficgp,"\n\n# Resultline k1=%d ",k1);        fprintf(ficgp,"\n\n# Resultline k1=%d ",k1);
       strcpy(gplotlabel,"(");        strcpy(gplotlabel,"(");
       /*sprintf(gplotlabel+strlen(gplotlabel)," Dummy combination %d ",k1);*/        /*sprintf(gplotlabel+strlen(gplotlabel)," Dummy combination %d ",k1);*/
Line 9555  void prevforecast(char fileres[], double Line 9577  void prevforecast(char fileres[], double
   
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
        k=TKresult[nres];         k=TKresult[nres];
          if(TKresult[nres]==0) k=1; /* To be checked for noresult */
      /* for(k=1; k<=i1;k++){ /\* We find the combination equivalent to result line values of dummies *\/ */       /* for(k=1; k<=i1;k++){ /\* We find the combination equivalent to result line values of dummies *\/ */
       if(i1 != 1 && TKresult[nres]!= k)        if(i1 != 1 && TKresult[nres]!= k)
         continue;          continue;
Line 9615  void prevforecast(char fileres[], double Line 9638  void prevforecast(char fileres[], double
         
    for(nres=1; nres <= nresult; nres++){ /* For each resultline */     for(nres=1; nres <= nresult; nres++){ /* For each resultline */
      k=TKresult[nres];       k=TKresult[nres];
        if(TKresult[nres]==0) k=1; /* To be checked for noresult */
     /* for(k=1; k<=i1;k++){ */      /* for(k=1; k<=i1;k++){ */
     /*    if(i1 != 1 && TKresult[nres]!= k) */      /*    if(i1 != 1 && TKresult[nres]!= k) */
     /*   continue; */      /*   continue; */
Line 9622  void prevforecast(char fileres[], double Line 9646  void prevforecast(char fileres[], double
        printf("\n#****** ");         printf("\n#****** ");
        fprintf(ficlog,"\n#****** ");         fprintf(ficlog,"\n#****** ");
        for (j=1; j<= cptcovs; j++){ /* For each selected (single) quantitative value */         for (j=1; j<= cptcovs; j++){ /* For each selected (single) quantitative value */
          printf(" V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);           printf(" V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
          fprintf(ficresvbl," V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);           fprintf(ficresvbl," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
          fprintf(ficlog," V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);           fprintf(ficlog," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
        /* for(j=1;j<=cptcoveff;j++) { */         /* for(j=1;j<=cptcoveff;j++) { */
        /*        fprintf(ficresvbl,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */         /*        fprintf(ficresvbl,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
        /*        fprintf(ficlog,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */         /*        fprintf(ficlog,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
Line 10520  int decoderesult( char resultline[], int Line 10544  int decoderesult( char resultline[], int
         }          }
       }        }
       if(match == 0){        if(match == 0){
         printf("Error in result line (Dummy single): V%d is missing in result: %s according to model=%s. Tvar[k1=%d]=%d is different from Tvarsel[k2=%d]=%d.\n",Tvar[k1], resultline, model,k1, Tvar[k1], k2, Tvarsel[k2]);          printf("Error in result line (Dummy single): V%d is missing in result: %s according to model=1+age+%s. Tvar[k1=%d]=%d is different from Tvarsel[k2=%d]=%d.\n",Tvar[k1], resultline, model,k1, Tvar[k1], k2, Tvarsel[k2]);
         fprintf(ficlog,"Error in result line (Dummy single): V%d is missing in result: %s according to model=%s\n",Tvar[k1], resultline, model);          fprintf(ficlog,"Error in result line (Dummy single): V%d is missing in result: %s according to model=1+age+%s\n",Tvar[k1], resultline, model);
         return 1;          return 1;
       }        }
     }else if(Typevar[k1]==1){ /* Product with age We want to get the position k2 in the resultline of the product k1 in the model line*/      }else if(Typevar[k1]==1){ /* Product with age We want to get the position k2 in the resultline of the product k1 in the model line*/
Line 10537  int decoderesult( char resultline[], int Line 10561  int decoderesult( char resultline[], int
         }          }
       }        }
       if(match == 0){        if(match == 0){
         printf("Error in result line (Product with age): V%d is missing in result: %s according to model=%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);          printf("Error in result line (Product with age): V%d is missing in result: %s according to model=1+age+%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
         fprintf(ficlog,"Error in result line (Product with age): V%d is missing in result: %s according to model=%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);          fprintf(ficlog,"Error in result line (Product with age): V%d is missing in result: %s according to model=1+age+%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
       return 1;        return 1;
       }        }
     }else if(Typevar[k1]==2){ /* Product No age We want to get the position in the resultline of the product in the model line*/      }else if(Typevar[k1]==2){ /* Product No age We want to get the position in the resultline of the product in the model line*/
Line 10553  int decoderesult( char resultline[], int Line 10577  int decoderesult( char resultline[], int
         }          }
       }        }
       if(match == 0){        if(match == 0){
         printf("Error in result line (Product without age first variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][1], resultline, model);          printf("Error in result line (Product without age first variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][1], resultline, model);
         fprintf(ficlog,"Error in result line (Product without age first variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][1], resultline, model);          fprintf(ficlog,"Error in result line (Product without age first variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][1], resultline, model);
         return 1;          return 1;
       }        }
       match=0;        match=0;
Line 10567  int decoderesult( char resultline[], int Line 10591  int decoderesult( char resultline[], int
         }          }
       }        }
       if(match == 0){        if(match == 0){
         printf("Error in result line (Product without age second variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][2], resultline, model);          printf("Error in result line (Product without age second variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][2], resultline, model);
         fprintf(ficlog,"Error in result line (Product without age second variable): V%d is missing in result : %s according to model=%s\n",Tvardk[k1][2], resultline, model);          fprintf(ficlog,"Error in result line (Product without age second variable): V%d is missing in result : %s according to model=1+age+%s\n",Tvardk[k1][2], resultline, model);
         return 1;          return 1;
       }        }
     }/* End of testing */      }/* End of testing */
Line 10588  int decoderesult( char resultline[], int Line 10612  int decoderesult( char resultline[], int
       }        }
     }      }
     if(match == 0){      if(match == 0){
       printf("Error in result line: variable V%d is missing in model; result: %s, model=%s\n",Tvarsel[k2], resultline, model);        printf("Error in result line: variable V%d is missing in model; result: %s, model=1+age+%s\n",Tvarsel[k2], resultline, model);
       fprintf(ficlog,"Error in result line: variable V%d is missing in model; result: %s, model=%s\n",Tvarsel[k2], resultline, model);        fprintf(ficlog,"Error in result line: variable V%d is missing in model; result: %s, model=1+age+%s\n",Tvarsel[k2], resultline, model);
       return 1;        return 1;
     }else if(match > 1){      }else if(match > 1){
       printf("Error in result line: %d doubled; result: %s, model=%s\n",k2, resultline, model);        printf("Error in result line: %d doubled; result: %s, model=1+age+%s\n",k2, resultline, model);
       fprintf(ficlog,"Error in result line: %d doubled; result: %s, model=%s\n",k2, resultline, model);        fprintf(ficlog,"Error in result line: %d doubled; result: %s, model=1+age+%s\n",k2, resultline, model);
       return 1;        return 1;
     }      }
   }    }
Line 10725  int decodemodel( char model[], int lasto Line 10749  int decodemodel( char model[], int lasto
       return 1;        return 1;
     }      }
     if (strstr(model,"v") !=0){      if (strstr(model,"v") !=0){
       printf("Error. 'v' must be in upper case 'V' model=%s ",model);        printf("Error. 'v' must be in upper case 'V' model=1+age+%s ",model);
       fprintf(ficlog,"Error. 'v' must be in upper case model=%s ",model);fflush(ficlog);        fprintf(ficlog,"Error. 'v' must be in upper case model=1+age+%s ",model);fflush(ficlog);
       return 1;        return 1;
     }      }
     strcpy(modelsav,model);       strcpy(modelsav,model); 
     if ((strpt=strstr(model,"age*age")) !=0){      if ((strpt=strstr(model,"age*age")) !=0){
       printf(" strpt=%s, model=%s\n",strpt, model);        printf(" strpt=%s, model=1+age+%s\n",strpt, model);
       if(strpt != model){        if(strpt != model){
         printf("Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \          printf("Error in model: 'model=1+age+%s'; 'age*age' should in first place before other covariates\n \
  'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \   'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \
  corresponding column of parameters.\n",model);   corresponding column of parameters.\n",model);
         fprintf(ficlog,"Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \          fprintf(ficlog,"Error in model: 'model=1+age+%s'; 'age*age' should in first place before other covariates\n \
  'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \   'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \
  corresponding column of parameters.\n",model); fflush(ficlog);   corresponding column of parameters.\n",model); fflush(ficlog);
         return 1;          return 1;
Line 11185  Dummy[k] 0=dummy (0 1), 1 quantitative ( Line 11209  Dummy[k] 0=dummy (0 1), 1 quantitative (
       if((Typevar[k1]==Typevar[k2]) && (Fixed[k1]==Fixed[k2]) && (Dummy[k1]==Dummy[k2] )){        if((Typevar[k1]==Typevar[k2]) && (Fixed[k1]==Fixed[k2]) && (Dummy[k1]==Dummy[k2] )){
         if((Typevar[k1] == 0 || Typevar[k1] == 1)){ /* Simple or age product */          if((Typevar[k1] == 0 || Typevar[k1] == 1)){ /* Simple or age product */
           if(Tvar[k1]==Tvar[k2]){            if(Tvar[k1]==Tvar[k2]){
             printf("Error duplication in the model=%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]);              printf("Error duplication in the model=1+age+%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]);
             fprintf(ficlog,"Error duplication in the model=%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]); fflush(ficlog);              fprintf(ficlog,"Error duplication in the model=1+age+%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]); fflush(ficlog);
             return(1);              return(1);
           }            }
         }else if (Typevar[k1] ==2){          }else if (Typevar[k1] ==2){
           k3=Tposprod[k1];            k3=Tposprod[k1];
           k4=Tposprod[k2];            k4=Tposprod[k2];
           if( ((Tvard[k3][1]== Tvard[k4][1])&&(Tvard[k3][2]== Tvard[k4][2])) || ((Tvard[k3][1]== Tvard[k4][2])&&(Tvard[k3][2]== Tvard[k4][1])) ){            if( ((Tvard[k3][1]== Tvard[k4][1])&&(Tvard[k3][2]== Tvard[k4][2])) || ((Tvard[k3][1]== Tvard[k4][2])&&(Tvard[k3][2]== Tvard[k4][1])) ){
             printf("Error duplication in the model=%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]);              printf("Error duplication in the model=1+age+%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]);
             fprintf(ficlog,"Error duplication in the model=%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]); fflush(ficlog);              fprintf(ficlog,"Error duplication in the model=1+age+%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]); fflush(ficlog);
             return(1);              return(1);
           }            }
         }          }
Line 11553  int prevalence_limit(double *p, double * Line 11577  int prevalence_limit(double *p, double *
   /* for(k=1; k<=i1;k++){ /\* For each combination k of dummy covariates in the model *\/ */    /* for(k=1; k<=i1;k++){ /\* For each combination k of dummy covariates in the model *\/ */
     for(nres=1; nres <= nresult; nres++){ /* For each resultline */      for(nres=1; nres <= nresult; nres++){ /* For each resultline */
       k=TKresult[nres];        k=TKresult[nres];
         if(TKresult[nres]==0) k=1; /* To be checked for noresult */
       /* if(i1 != 1 && TKresult[nres]!= k) /\* We found the combination k corresponding to the resultline value of dummies *\/ */        /* if(i1 != 1 && TKresult[nres]!= k) /\* We found the combination k corresponding to the resultline value of dummies *\/ */
       /*        continue; */        /*        continue; */
   
Line 11658  int back_prevalence_limit(double *p, dou Line 11683  int back_prevalence_limit(double *p, dou
   if (cptcovn < 1){i1=1;}    if (cptcovn < 1){i1=1;}
       
   for(nres=1; nres <= nresult; nres++){ /* For each resultline */    for(nres=1; nres <= nresult; nres++){ /* For each resultline */
     for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */      /* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */
      if(i1 != 1 && TKresult[nres]!= k)        k=TKresult[nres];
         continue;        if(TKresult[nres]==0) k=1; /* To be checked for noresult */
      /*printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov));*/       /* if(i1 != 1 && TKresult[nres]!= k) */
        /*         continue; */
        /* /\*printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov));*\/ */
       fprintf(ficresplb,"#******");        fprintf(ficresplb,"#******");
       printf("#******");        printf("#******");
       fprintf(ficlog,"#******");        fprintf(ficlog,"#******");
       for(j=1;j<=cptcoveff ;j++) {/* all covariates */        for(j=1;j<=cptcovs ;j++) {/**< cptcovs number of SIMPLE covariates in the model or resultline V2+V1 =2 (dummy or quantit or time varying) */
         fprintf(ficresplb," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);          printf(" V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
         printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);          fprintf(ficresplb," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
         fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);          fprintf(ficlog," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
       }  
       for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */  
         printf(" V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);  
         fprintf(ficresplb," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);  
         fprintf(ficlog," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);  
       }        }
         /* for(j=1;j<=cptcoveff ;j++) {/\* all covariates *\/ */
         /*        fprintf(ficresplb," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
         /*        printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
         /*        fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
         /* } */
         /* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ */
         /*        printf(" V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
         /*        fprintf(ficresplb," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
         /*        fprintf(ficlog," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
         /* } */
       fprintf(ficresplb,"******\n");        fprintf(ficresplb,"******\n");
       printf("******\n");        printf("******\n");
       fprintf(ficlog,"******\n");        fprintf(ficlog,"******\n");
Line 11686  int back_prevalence_limit(double *p, dou Line 11718  int back_prevalence_limit(double *p, dou
       }        }
           
       fprintf(ficresplb,"#Age ");        fprintf(ficresplb,"#Age ");
       for(j=1;j<=cptcoveff;j++) {        for(j=1;j<=cptcovs;j++) {
         fprintf(ficresplb,"V%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);          fprintf(ficresplb,"V%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
       }        }
       for(i=1; i<=nlstate;i++) fprintf(ficresplb,"  %d-%d   ",i,i);        for(i=1; i<=nlstate;i++) fprintf(ficresplb,"  %d-%d   ",i,i);
       fprintf(ficresplb,"Total Years_to_converge\n");        fprintf(ficresplb,"Total Years_to_converge\n");
Line 11710  int back_prevalence_limit(double *p, dou Line 11742  int back_prevalence_limit(double *p, dou
           /* exit(1); */            /* exit(1); */
         }          }
         fprintf(ficresplb,"%.0f ",age );          fprintf(ficresplb,"%.0f ",age );
         for(j=1;j<=cptcoveff;j++)          for(j=1;j<=cptcovs;j++)
           fprintf(ficresplb,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);            fprintf(ficresplb,"%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
         tot=0.;          tot=0.;
         for(i=1; i<=nlstate;i++){          for(i=1; i<=nlstate;i++){
           tot +=  bprlim[i][i];            tot +=  bprlim[i][i];
Line 11721  int back_prevalence_limit(double *p, dou Line 11753  int back_prevalence_limit(double *p, dou
       } /* 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. */        /*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); */
   /* fclose(ficrespijb); */    /* fclose(ficrespijb); */
Line 11765  int hPijx(double *p, int bage, int fage) Line 11797  int hPijx(double *p, int bage, int fage)
   /*    k=k+1;  */    /*    k=k+1;  */
   for(nres=1; nres <= nresult; nres++){ /* For each resultline */    for(nres=1; nres <= nresult; nres++){ /* For each resultline */
     k=TKresult[nres];      k=TKresult[nres];
       if(TKresult[nres]==0) k=1; /* To be checked for noresult */
     /* for(k=1; k<=i1;k++){ */      /* for(k=1; k<=i1;k++){ */
     /* if(i1 != 1 && TKresult[nres]!= k) */      /* if(i1 != 1 && TKresult[nres]!= k) */
     /*  continue; */      /*  continue; */
Line 11846  int hPijx(double *p, int bage, int fage) Line 11879  int hPijx(double *p, int bage, int fage)
   /*    k=k+1;  */    /*    k=k+1;  */
   for(nres=1; nres <= nresult; nres++){ /* For each resultline */    for(nres=1; nres <= nresult; nres++){ /* For each resultline */
     k=TKresult[nres];      k=TKresult[nres];
       if(TKresult[nres]==0) k=1; /* To be checked for noresult */
     /* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */      /* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */
     /*    if(i1 != 1 && TKresult[nres]!= k) */      /*    if(i1 != 1 && TKresult[nres]!= k) */
     /*  continue; */      /*  continue; */
     fprintf(ficrespijb,"\n#****** ");      fprintf(ficrespijb,"\n#****** ");
     for(j=1;j<=cptcovs;j++){      for(j=1;j<=cptcovs;j++){
       fprintf(ficrespij," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);        fprintf(ficrespijb," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
       /* for(j=1;j<=cptcoveff;j++) */        /* for(j=1;j<=cptcoveff;j++) */
       /*        fprintf(ficrespijb,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */        /*        fprintf(ficrespijb,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
       /* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ */        /* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ */
Line 12291  int main(int argc, char *argv[]) Line 12325  int main(int argc, char *argv[])
         strcpy(model,modeltemp);           strcpy(model,modeltemp); 
       }        }
     }      }
     /* printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout); */      /* printf(" model=1+age%s modeltemp= %s, model=1+age+%s\n",model, modeltemp, model);fflush(stdout); */
     printf("model=1+age+%s\n",model);fflush(stdout);      printf("model=1+age+%s\n",model);fflush(stdout);
     fprintf(ficparo,"model=1+age+%s\n",model);fflush(stdout);      fprintf(ficparo,"model=1+age+%s\n",model);fflush(stdout);
     fprintf(ficres,"model=1+age+%s\n",model);fflush(stdout);      fprintf(ficres,"model=1+age+%s\n",model);fflush(stdout);
Line 12722  Please run with mle=-1 to get a correct Line 12756  Please run with mle=-1 to get a correct
   }    }
       
   ncovcombmax=pow(2,cptcoveff);    ncovcombmax=pow(2,cptcoveff);
   invalidvarcomb=ivector(1, ncovcombmax);     invalidvarcomb=ivector(0, ncovcombmax); 
   for(i=1;i<ncovcombmax;i++)    for(i=0;i<ncovcombmax;i++)
     invalidvarcomb[i]=0;      invalidvarcomb[i]=0;
       
   /* Nbcode gives the value of the lth modality (currently 1 to 2) of jth covariate, in    /* Nbcode gives the value of the lth modality (currently 1 to 2) of jth covariate, in
Line 14178  Please run with mle=-1 to get a correct Line 14212  Please run with mle=-1 to get a correct
   free_ivector(Tposprod,1,NCOVMAX);    free_ivector(Tposprod,1,NCOVMAX);
   free_ivector(Tprod,1,NCOVMAX);    free_ivector(Tprod,1,NCOVMAX);
   free_ivector(Tvaraff,1,NCOVMAX);    free_ivector(Tvaraff,1,NCOVMAX);
   free_ivector(invalidvarcomb,1,ncovcombmax);    free_ivector(invalidvarcomb,0,ncovcombmax);
   free_ivector(Tage,1,NCOVMAX);    free_ivector(Tage,1,NCOVMAX);
   free_ivector(Tmodelind,1,NCOVMAX);    free_ivector(Tmodelind,1,NCOVMAX);
   free_ivector(TmodelInvind,1,NCOVMAX);    free_ivector(TmodelInvind,1,NCOVMAX);

Removed from v.1.337  
changed lines
  Added in v.1.338


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