Diff for /imach/src/imach.c between versions 1.68 and 1.69

version 1.68, 2003/02/04 12:40:59 version 1.69, 2003/02/04 20:55:29
Line 972  double func( double *x) Line 972  double func( double *x)
          * is higher than the multiple of stepm and negative otherwise.           * is higher than the multiple of stepm and negative otherwise.
          */           */
         /* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/          /* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/
         /* if s2=-2 lli=out[1][1]+out[1][2];*/  
         if (s2==-2) {  
           for (j=1,survp=0. ; j<=nlstate; j++)   
             survp += out[s1][j];  
           lli= survp;  
         }  
   
         else  
         lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));  /* linear interpolation */          lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));  /* linear interpolation */
         /*lli=(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]);*/          /*lli=(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]);*/
         /*if(lli ==000.0)*/          /*if(lli ==000.0)*/
Line 1424  void  freqsummary(char fileres[], int ag Line 1416  void  freqsummary(char fileres[], int ag
     fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp);      fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp);
     exit(0);      exit(0);
   }    }
   freq= ma3x(-2,nlstate+ndeath,-2,nlstate+ndeath,agemin,agemax+3);    freq= ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3);
   j1=0;    j1=0;
       
   j=cptcoveff;    j=cptcoveff;
Line 1539  void  freqsummary(char fileres[], int ag Line 1531  void  freqsummary(char fileres[], int ag
           }            }
         }          }
                   
         for(jk=-2; jk <=nlstate+ndeath; jk++)          for(jk=-1; jk <=nlstate+ndeath; jk++)
           for(m=-2; m <=nlstate+ndeath; m++)            for(m=-1; m <=nlstate+ndeath; m++)
             if(freq[jk][m][i] !=0 ) {              if(freq[jk][m][i] !=0 ) {
             if(first==1)              if(first==1)
               printf(" %d%d=%.0f",jk,m,freq[jk][m][i]);                printf(" %d%d=%.0f",jk,m,freq[jk][m][i]);
Line 1557  void  freqsummary(char fileres[], int ag Line 1549  void  freqsummary(char fileres[], int ag
   dateintmean=dateintsum/k2cpt;     dateintmean=dateintsum/k2cpt; 
     
   fclose(ficresp);    fclose(ficresp);
   free_ma3x(freq,-2,nlstate+ndeath,-2,nlstate+ndeath,(int) agemin,(int) agemax+3);    free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3);
   free_vector(pp,1,nlstate);    free_vector(pp,1,nlstate);
       
   /* End of Freq */    /* End of Freq */
 }  }
   
 /************ Prevalence ********************/  /************ Prevalence ********************/
 void prevalence(int agemin, float agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2, double calagedate)  void prevalence(int agemin, float agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2, double calagedatem)
 {  /* Some frequencies */  {  
     /* Compute observed prevalence between dateprev1 and dateprev2 by counting the number of people
        in each health status at the date of interview (if between dateprev1 and dateprev2).
        We still use firstpass and lastpass as another selection.
     */
     
   int i, m, jk, k1, i1, j1, bool, z1,z2,j;    int i, m, jk, k1, i1, j1, bool, z1,z2,j;
   double ***freq; /* Frequencies */    double ***freq; /* Frequencies */
   double *pp;    double *pp;
   double pos, k2;    double pos; 
     double  y2; /* in fractional years */
   
   pp=vector(1,nlstate);    pp=vector(1,nlstate);
       
   freq=ma3x(-2,nlstate+ndeath,-2,nlstate+ndeath,agemin,agemax+3);    freq=ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3);
   j1=0;    j1=0;
       
   j=cptcoveff;    j=cptcoveff;
Line 1584  void prevalence(int agemin, float agemax Line 1581  void prevalence(int agemin, float agemax
     for(i1=1; i1<=ncodemax[k1];i1++){      for(i1=1; i1<=ncodemax[k1];i1++){
       j1++;        j1++;
               
       for (i=-2; i<=nlstate+ndeath; i++)          for (i=-1; i<=nlstate+ndeath; i++)  
         for (jk=-2; jk<=nlstate+ndeath; jk++)            for (jk=-1; jk<=nlstate+ndeath; jk++)  
           for(m=agemin; m <= agemax+3; m++)            for(m=agemin; m <= agemax+3; m++)
             freq[i][jk][m]=0;              freq[i][jk][m]=0;
             
       for (i=1; i<=imx; i++) {        for (i=1; i<=imx; i++) { /* Each individual */
         bool=1;          bool=1;
         if  (cptcovn>0) {          if  (cptcovn>0) {
           for (z1=1; z1<=cptcoveff; z1++)             for (z1=1; z1<=cptcoveff; z1++) 
Line 1597  void prevalence(int agemin, float agemax Line 1594  void prevalence(int agemin, float agemax
               bool=0;                bool=0;
         }           } 
         if (bool==1) {           if (bool==1) { 
           for(m=firstpass; m<=lastpass; m++){            for(m=firstpass; m<=lastpass; m++){/* Other selection (we can limit to certain interviews*/
             k2=anint[m][i]+(mint[m][i]/12.);              y2=anint[m][i]+(mint[m][i]/12.); /* Fractional date in year */
             if ((k2>=dateprev1) && (k2<=dateprev2)) {              if ((y2>=dateprev1) && (y2<=dateprev2)) { /* Here is the main selection (fractional years) */
               if(agev[m][i]==0) agev[m][i]=agemax+1;                if(agev[m][i]==0) agev[m][i]=agemax+1;
               if(agev[m][i]==1) agev[m][i]=agemax+2;                if(agev[m][i]==1) agev[m][i]=agemax+2;
               if (m<lastpass) {                if (m<lastpass) {
                 if (calagedate>0)                   if (calagedatem>0) /* We compute prevalence at exact age, agev in fractional years */
                   freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-((int)calagedate %12)/12.)] += weight[i];                    freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-((int)calagedatem %12)/12.)] += weight[i];
                 else                  else
                   freq[s[m][i]][s[m+1][i]][(int)agev[m][i]] += weight[i];                    freq[s[m][i]][s[m+1][i]][(int)agev[m][i]] += weight[i];
                 freq[s[m][i]][s[m+1][i]][(int)(agemax+3)] += weight[i];                   freq[s[m][i]][s[m+1][i]][(int)(agemax+3)] += weight[i]; 
               }                }
             }              }
           }            } /* end selection of waves */
         }          }
       }        }
       for(i=(int)agemin; i <= (int)agemax+3; i++){         for(i=(int)agemin; i <= (int)agemax+3; i++){ 
Line 1642  void prevalence(int agemin, float agemax Line 1639  void prevalence(int agemin, float agemax
   } /* end k1 */    } /* end k1 */
   
       
   free_ma3x(freq,-2,nlstate+ndeath,-2,nlstate+ndeath,(int) agemin,(int) agemax+3);    free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3);
   free_vector(pp,1,nlstate);    free_vector(pp,1,nlstate);
       
 }  /* End of Freq */  }  /* End of Freq */
Line 1672  void  concatwav(int wav[], int **dh, int Line 1669  void  concatwav(int wav[], int **dh, int
     mi=0;      mi=0;
     m=firstpass;      m=firstpass;
     while(s[m][i] <= nlstate){      while(s[m][i] <= nlstate){
       if(s[m][i]>=1 || s[m][i]==-2)        if(s[m][i]>=1)
         mw[++mi][i]=m;          mw[++mi][i]=m;
       if(m >=lastpass)        if(m >=lastpass)
         break;          break;
Line 2144  void varevsij(char optionfilefiname[], d Line 2141  void varevsij(char optionfilefiname[], d
          computed over hstepm matrices product = hstepm*stepm months)            computed over hstepm matrices product = hstepm*stepm months) 
          as a weighted average of prlim.           as a weighted average of prlim.
       */        */
       for(j=nlstate+1,gpp[j]=0.;j<=nlstate+ndeath;j++){        for(j=nlstate+1;j<=nlstate+ndeath;j++){
         for(i=1,gpp[j]=0.; i<= nlstate; i++)          for(i=1,gpp[j]=0.; i<= nlstate; i++)
           gpp[j] += prlim[i][i]*p3mat[i][j][1];            gpp[j] += prlim[i][i]*p3mat[i][j][1];
       }            }    
Line 2175  void varevsij(char optionfilefiname[], d Line 2172  void varevsij(char optionfilefiname[], d
          computed over hstepm matrices product = hstepm*stepm months)            computed over hstepm matrices product = hstepm*stepm months) 
          as a weighted average of prlim.           as a weighted average of prlim.
       */        */
       for(j=nlstate+1,gmp[j]=0.;j<=nlstate+ndeath;j++){        for(j=nlstate+1;j<=nlstate+ndeath;j++){
         for(i=1,gmp[j]=0.; i<= nlstate; i++)          for(i=1,gmp[j]=0.; i<= nlstate; i++)
          gmp[j] += prlim[i][i]*p3mat[i][j][1];           gmp[j] += prlim[i][i]*p3mat[i][j][1];
       }            }    
Line 2200  void varevsij(char optionfilefiname[], d Line 2197  void varevsij(char optionfilefiname[], d
           trgradg[h][j][theta]=gradg[h][theta][j];            trgradg[h][j][theta]=gradg[h][theta][j];
   
     for(j=nlstate+1; j<=nlstate+ndeath;j++) /* mu */      for(j=nlstate+1; j<=nlstate+ndeath;j++) /* mu */
       for(theta=1; theta <=npar; theta++) {        for(theta=1; theta <=npar; theta++)
         trgradgp[j][theta]=gradgp[theta][j];          trgradgp[j][theta]=gradgp[theta][j];
       }    
   
     hf=hstepm*stepm/YEARM;  /* Duration of hstepm expressed in year unit. */      hf=hstepm*stepm/YEARM;  /* Duration of hstepm expressed in year unit. */
     for(i=1;i<=nlstate;i++)      for(i=1;i<=nlstate;i++)
Line 2226  void varevsij(char optionfilefiname[], d Line 2223  void varevsij(char optionfilefiname[], d
    for(j=nlstate+1;j<=nlstate+ndeath;j++)     for(j=nlstate+1;j<=nlstate+ndeath;j++)
      for(i=nlstate+1;i<=nlstate+ndeath;i++){       for(i=nlstate+1;i<=nlstate+ndeath;i++){
         varppt[j][i]=doldmp[j][i];          varppt[j][i]=doldmp[j][i];
      }  
   
     /* end ppptj */      /* end ppptj */
     /*  x centered again */      /*  x centered again */
     hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm,savm, ij);        hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm,savm, ij);  
Line 2449  void varprob(char optionfilefiname[], do Line 2444  void varprob(char optionfilefiname[], do
       fprintf(ficresprobcov," p%1d-%1d ",i,j);        fprintf(ficresprobcov," p%1d-%1d ",i,j);
       fprintf(ficresprobcor," p%1d-%1d ",i,j);        fprintf(ficresprobcor," p%1d-%1d ",i,j);
     }        }  
   fprintf(ficresprob,"\n");   /* fprintf(ficresprob,"\n");
   fprintf(ficresprobcov,"\n");    fprintf(ficresprobcov,"\n");
   fprintf(ficresprobcor,"\n");    fprintf(ficresprobcor,"\n");
   xp=vector(1,npar);   */
    xp=vector(1,npar);
   dnewm=matrix(1,(nlstate)*(nlstate+ndeath),1,npar);    dnewm=matrix(1,(nlstate)*(nlstate+ndeath),1,npar);
   doldm=matrix(1,(nlstate)*(nlstate+ndeath),1,(nlstate)*(nlstate+ndeath));    doldm=matrix(1,(nlstate)*(nlstate+ndeath),1,(nlstate)*(nlstate+ndeath));
   mu=matrix(1,(nlstate)*(nlstate+ndeath), (int) bage, (int)fage);    mu=matrix(1,(nlstate)*(nlstate+ndeath), (int) bage, (int)fage);
Line 2491  void varprob(char optionfilefiname[], do Line 2487  void varprob(char optionfilefiname[], do
       if  (cptcovn>0) {        if  (cptcovn>0) {
         fprintf(ficresprob, "\n#********** Variable ");           fprintf(ficresprob, "\n#********** Variable "); 
         for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "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(ficresprob, "**********\n#");          fprintf(ficresprob, "**********\n#\n");
         fprintf(ficresprobcov, "\n#********** Variable ");           fprintf(ficresprobcov, "\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(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
         fprintf(ficresprobcov, "**********\n#");          fprintf(ficresprobcov, "**********\n#\n");
                   
         fprintf(ficgp, "\n#********** Variable ");           fprintf(ficgp, "\n#********** Variable "); 
         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(ficgp, " V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]);
         fprintf(ficgp, "**********\n#");          fprintf(ficgp, "**********\n#\n");
                   
                   
         fprintf(fichtm, "\n<hr  size=\"2\" color=\"#EC5E5E\">********** Variable ");           fprintf(fichtm, "\n<hr  size=\"2\" color=\"#EC5E5E\">********** Variable "); 
Line 2507  void varprob(char optionfilefiname[], do Line 2503  void varprob(char optionfilefiname[], do
                   
         fprintf(ficresprobcor, "\n#********** Variable ");              fprintf(ficresprobcor, "\n#********** Variable ");    
         for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "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(ficresprobcor, "**********\n#");    
       }        }
               
       for (age=bage; age<=fage; age ++){         for (age=bage; age<=fage; age ++){ 
Line 2826  m=pow(2,cptcoveff); Line 2822  m=pow(2,cptcoveff);
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
        else fprintf(ficgp," \%%*lf (\%%*lf)");         else fprintf(ficgp," \%%*lf (\%%*lf)");
      }       }
      fprintf(ficgp,"\" t\"Stable prevalence\" w l 0,\"vpl%s\" every :::%d::%d u 1:($2+2*$3) \"\%%lf",fileres,k1-1,k1-1);       fprintf(ficgp,"\" t\"Stable prevalence\" w l 0,\"vpl%s\" every :::%d::%d u 1:($2+1.96*$3) \"\%%lf",fileres,k1-1,k1-1);
      for (i=1; i<= nlstate ; i ++) {       for (i=1; i<= nlstate ; i ++) {
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
        else fprintf(ficgp," \%%*lf (\%%*lf)");         else fprintf(ficgp," \%%*lf (\%%*lf)");
      }        } 
      fprintf(ficgp,"\" t\"95\%% CI\" w l 1,\"vpl%s\" every :::%d::%d u 1:($2-2*$3) \"\%%lf",fileres,k1-1,k1-1);        fprintf(ficgp,"\" t\"95\%% CI\" w l 1,\"vpl%s\" every :::%d::%d u 1:($2-1.96*$3) \"\%%lf",fileres,k1-1,k1-1); 
      for (i=1; i<= nlstate ; i ++) {       for (i=1; i<= nlstate ; i ++) {
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
        else fprintf(ficgp," \%%*lf (\%%*lf)");         else fprintf(ficgp," \%%*lf (\%%*lf)");
Line 3023  int movingaverage(double ***probs, doubl Line 3019  int movingaverage(double ***probs, doubl
   
 /************** Forecasting ******************/  /************** Forecasting ******************/
 prevforecast(char fileres[], double anproj1,double mproj1,double jproj1,double ageminpar, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anproj2,double p[], int i2){  prevforecast(char fileres[], double anproj1,double mproj1,double jproj1,double ageminpar, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anproj2,double p[], int i2){
       /* proj1, year, month, day of starting projection 
   int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;       agemin, agemax range of age
        dateprev1 dateprev2 range of dates during which prevalence is computed
        
     */
     int yearp, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;
   int *popage;    int *popage;
   double calagedate, agelim, kk1, kk2, yp,yp1,yp2,jprojmean,mprojmean,anprojmean;    double calagedatem, agelim, kk1, kk2, yp,yp1,yp2,jprojmean,mprojmean,anprojmean;
   double *popeffectif,*popcount;    double *popeffectif,*popcount;
   double ***p3mat;    double ***p3mat;
   double ***mobaverage;    double ***mobaverage;
   char fileresf[FILENAMELENGTH];    char fileresf[FILENAMELENGTH];
   
  agelim=AGESUP;    agelim=AGESUP;
  calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;    calagedatem=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM; /* offset
         from the mean date of interviews between dateprev1 and dateprev2
   prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);        (in fractional years converted to fractional months) */
      /* Computing age-specific starting prevalence between exact 
        dateprev1 and dateprev2 (in float years) and
    shifting ages from calagedatem.
     */
     prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedatem);
     
   strcpy(fileresf,"f");     strcpy(fileresf,"f"); 
   strcat(fileresf,fileres);    strcat(fileresf,fileres);
Line 3064  prevforecast(char fileres[], double anpr Line 3068  prevforecast(char fileres[], double anpr
       
   hstepm=1;    hstepm=1;
   hstepm=hstepm/stepm;     hstepm=hstepm/stepm; 
   yp1=modf(dateintmean,&yp);    yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp  and
                                  fractional in yp1 */
   anprojmean=yp;    anprojmean=yp;
   yp2=modf((yp1*12),&yp);    yp2=modf((yp1*12),&yp);
   mprojmean=yp;    mprojmean=yp;
Line 3073  prevforecast(char fileres[], double anpr Line 3078  prevforecast(char fileres[], double anpr
   if(jprojmean==0) jprojmean=1;    if(jprojmean==0) jprojmean=1;
   if(mprojmean==0) jprojmean=1;    if(mprojmean==0) jprojmean=1;
       
   fprintf(ficresf,"# Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean);     fprintf(ficresf,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f ",jprojmean,mprojmean,anprojmean,dateintmean,dateprev1,dateprev2); 
       
   for(cptcov=1;cptcov<=i2;cptcov++){    for(cptcov=1, k=0;cptcov<=i2;cptcov++){
     for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){      for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){
       k=k+1;        k=k+1;
       fprintf(ficresf,"\n#******");        fprintf(ficresf,"\n#******");
Line 3085  prevforecast(char fileres[], double anpr Line 3090  prevforecast(char fileres[], double anpr
       fprintf(ficresf,"******\n");        fprintf(ficresf,"******\n");
       fprintf(ficresf,"# StartingAge FinalAge");        fprintf(ficresf,"# StartingAge FinalAge");
       for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j);        for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j);
               for (yearp=0; yearp<=(anproj2-anproj1);yearp++) { 
         
       for (cpt=0; cpt<=(anproj2-anproj1);cpt++) {   
         fprintf(ficresf,"\n");          fprintf(ficresf,"\n");
         fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);             fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);   
   
         for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(ageminpar-((int)calagedate %12)/12.); agedeb--){           for (agedeb=(fage-((int)calagedatem %12/12.)); agedeb>=(ageminpar-((int)calagedatem %12)/12.); agedeb--){ 
           nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);             nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); 
           nhstepm = nhstepm/hstepm;             nhstepm = nhstepm/hstepm; 
                       
Line 3100  prevforecast(char fileres[], double anpr Line 3103  prevforecast(char fileres[], double anpr
           hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);              hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);  
                   
           for (h=0; h<=nhstepm; h++){            for (h=0; h<=nhstepm; h++){
             if (h==(int) (calagedate+YEARM*cpt)) {              if (h==(int) (calagedatem+YEARM*yearp)) {
               fprintf(ficresf,"\n %.f %.f ",anproj1+cpt,agedeb+h*hstepm/YEARM*stepm);                fprintf(ficresf,"\n");
                 for(j=1;j<=cptcoveff;j++) 
                   fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
                 fprintf(ficresf,"%.f %.f ",anproj1+yearp,agedeb+h*hstepm/YEARM*stepm);
             }               } 
             for(j=1; j<=nlstate+ndeath;j++) {              for(j=1; j<=nlstate+ndeath;j++) {
               kk1=0.;kk2=0;                kk1=0.;kk2=0;
Line 3113  prevforecast(char fileres[], double anpr Line 3119  prevforecast(char fileres[], double anpr
                 }                  }
                                   
               }                }
               if (h==(int)(calagedate+12*cpt)){                if (h==(int)(calagedatem+12*yearp)){
                 fprintf(ficresf," %.3f", kk1);                  fprintf(ficresf," %.3f", kk1);
                                                   
               }                }
Line 3134  populforecast(char fileres[], double anp Line 3140  populforecast(char fileres[], double anp
       
   int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;    int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;
   int *popage;    int *popage;
   double calagedate, agelim, kk1, kk2;    double calagedatem, agelim, kk1, kk2;
   double *popeffectif,*popcount;    double *popeffectif,*popcount;
   double ***p3mat,***tabpop,***tabpopprev;    double ***p3mat,***tabpop,***tabpopprev;
   double ***mobaverage;    double ***mobaverage;
Line 3143  populforecast(char fileres[], double anp Line 3149  populforecast(char fileres[], double anp
   tabpop= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);    tabpop= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
   tabpopprev= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);    tabpopprev= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
   agelim=AGESUP;    agelim=AGESUP;
   calagedate=(anpyram+mpyram/12.+jpyram/365.-dateintmean)*YEARM;    calagedatem=(anpyram+mpyram/12.+jpyram/365.-dateintmean)*YEARM;
       
   prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);    prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedatem);
       
       
   strcpy(filerespop,"pop");     strcpy(filerespop,"pop"); 
Line 3191  populforecast(char fileres[], double anp Line 3197  populforecast(char fileres[], double anp
     for (i=1; i<imx;i++) popeffectif[popage[i]]=popcount[i];      for (i=1; i<imx;i++) popeffectif[popage[i]]=popcount[i];
   }    }
   
   for(cptcov=1;cptcov<=i2;cptcov++){    for(cptcov=1,k=0;cptcov<=i2;cptcov++){
    for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){     for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){
       k=k+1;        k=k+1;
       fprintf(ficrespop,"\n#******");        fprintf(ficrespop,"\n#******");
Line 3206  populforecast(char fileres[], double anp Line 3212  populforecast(char fileres[], double anp
       for (cpt=0; cpt<=0;cpt++) {         for (cpt=0; cpt<=0;cpt++) { 
         fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);             fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);   
                   
         for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(ageminpar-((int)calagedate %12)/12.); agedeb--){           for (agedeb=(fage-((int)calagedatem %12/12.)); agedeb>=(ageminpar-((int)calagedatem %12)/12.); agedeb--){ 
           nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);             nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); 
           nhstepm = nhstepm/hstepm;             nhstepm = nhstepm/hstepm; 
                       
Line 3215  populforecast(char fileres[], double anp Line 3221  populforecast(char fileres[], double anp
           hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);              hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);  
                   
           for (h=0; h<=nhstepm; h++){            for (h=0; h<=nhstepm; h++){
             if (h==(int) (calagedate+YEARM*cpt)) {              if (h==(int) (calagedatem+YEARM*cpt)) {
               fprintf(ficrespop,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);                fprintf(ficrespop,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);
             }               } 
             for(j=1; j<=nlstate+ndeath;j++) {              for(j=1; j<=nlstate+ndeath;j++) {
Line 3227  populforecast(char fileres[], double anp Line 3233  populforecast(char fileres[], double anp
                   kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod];                    kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod];
                 }                  }
               }                }
               if (h==(int)(calagedate+12*cpt)){                if (h==(int)(calagedatem+12*cpt)){
                 tabpop[(int)(agedeb)][j][cptcod]=kk1;                  tabpop[(int)(agedeb)][j][cptcod]=kk1;
                   /*fprintf(ficrespop," %.3f", kk1);                    /*fprintf(ficrespop," %.3f", kk1);
                     if (popforecast==1) fprintf(ficrespop," [%.f]", kk1*popeffectif[(int)agedeb+1]);*/                      if (popforecast==1) fprintf(ficrespop," [%.f]", kk1*popeffectif[(int)agedeb+1]);*/
Line 3238  populforecast(char fileres[], double anp Line 3244  populforecast(char fileres[], double anp
                 for(j=1; j<=nlstate;j++){                  for(j=1; j<=nlstate;j++){
                   kk1= kk1+tabpop[(int)(agedeb)][j][cptcod];                     kk1= kk1+tabpop[(int)(agedeb)][j][cptcod]; 
                 }                  }
                   tabpopprev[(int)(agedeb)][i][cptcod]=tabpop[(int)(agedeb)][i][cptcod]/kk1*popeffectif[(int)(agedeb+(calagedate+12*cpt)*hstepm/YEARM*stepm-1)];                    tabpopprev[(int)(agedeb)][i][cptcod]=tabpop[(int)(agedeb)][i][cptcod]/kk1*popeffectif[(int)(agedeb+(calagedatem+12*cpt)*hstepm/YEARM*stepm-1)];
             }              }
   
             if (h==(int)(calagedate+12*cpt)) for(j=1; j<=nlstate;j++)               if (h==(int)(calagedatem+12*cpt)) for(j=1; j<=nlstate;j++) 
               fprintf(ficrespop," %15.2f",tabpopprev[(int)(agedeb+1)][j][cptcod]);                fprintf(ficrespop," %15.2f",tabpopprev[(int)(agedeb+1)][j][cptcod]);
           }            }
           free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);            free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
Line 3252  populforecast(char fileres[], double anp Line 3258  populforecast(char fileres[], double anp
   
       for (cpt=1; cpt<=(anpyram1-anpyram);cpt++) {         for (cpt=1; cpt<=(anpyram1-anpyram);cpt++) { 
         fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);             fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);   
         for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(ageminpar-((int)calagedate %12)/12.); agedeb--){           for (agedeb=(fage-((int)calagedatem %12/12.)); agedeb>=(ageminpar-((int)calagedatem %12)/12.); agedeb--){ 
           nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);             nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); 
           nhstepm = nhstepm/hstepm;             nhstepm = nhstepm/hstepm; 
                       
Line 3260  populforecast(char fileres[], double anp Line 3266  populforecast(char fileres[], double anp
           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);  
           for (h=0; h<=nhstepm; h++){            for (h=0; h<=nhstepm; h++){
             if (h==(int) (calagedate+YEARM*cpt)) {              if (h==(int) (calagedatem+YEARM*cpt)) {
               fprintf(ficresf,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);                fprintf(ficresf,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);
             }               } 
             for(j=1; j<=nlstate+ndeath;j++) {              for(j=1; j<=nlstate+ndeath;j++) {
Line 3268  populforecast(char fileres[], double anp Line 3274  populforecast(char fileres[], double anp
               for(i=1; i<=nlstate;i++) {                              for(i=1; i<=nlstate;i++) {              
                 kk1=kk1+p3mat[i][j][h]*tabpopprev[(int)agedeb+1][i][cptcod];                      kk1=kk1+p3mat[i][j][h]*tabpopprev[(int)agedeb+1][i][cptcod];    
               }                }
               if (h==(int)(calagedate+12*cpt)) fprintf(ficresf," %15.2f", kk1);                 if (h==(int)(calagedatem+12*cpt)) fprintf(ficresf," %15.2f", kk1);        
             }              }
           }            }
           free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);            free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
Line 3315  int main(int argc, char *argv[]) Line 3321  int main(int argc, char *argv[])
   int ju,jl, mi;    int ju,jl, mi;
   int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij;    int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij;
   int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,*tab;     int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,*tab; 
     int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */
   int mobilav=0,popforecast=0;    int mobilav=0,popforecast=0;
   int hstepm, nhstepm;    int hstepm, nhstepm;
   double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,jpyram, mpyram,anpyram,jpyram1, mpyram1,anpyram1, calagedate;    double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,jpyram, mpyram,anpyram,jpyram1, mpyram1,anpyram1, calagedatem;
   
   double bage, fage, age, agelim, agebase;    double bage, fage, age, agelim, agebase;
   double ftolpl=FTOL;    double ftolpl=FTOL;
Line 3718  int main(int argc, char *argv[]) Line 3725  int main(int argc, char *argv[])
   for (i=1; i<=imx; i++)  {    for (i=1; i<=imx; i++)  {
     agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]);      agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]);
     for(m=1; (m<= maxwav); m++){      for(m=1; (m<= maxwav); m++){
       if(s[m][i] >0 || s[m][i]==-2){        if(s[m][i] >0){
         if (s[m][i] >= nlstate+1) {          if (s[m][i] >= nlstate+1) {
           if(agedc[i]>0)            if(agedc[i]>0)
             if(moisdc[i]!=99 && andc[i]!=9999) agev[m][i]=agedc[i];              if(moisdc[i]!=99 && andc[i]!=9999)
                 agev[m][i]=agedc[i];
           /*if(moisdc[i]==99 && andc[i]==9999) s[m][i]=-1;*/            /*if(moisdc[i]==99 && andc[i]==9999) s[m][i]=-1;*/
             else {              else {
               if (andc[i]!=9999){                if (andc[i]!=9999){
Line 3730  int main(int argc, char *argv[]) Line 3738  int main(int argc, char *argv[])
                 agev[m][i]=-1;                  agev[m][i]=-1;
               }                }
             }              }
         }          }<
         else if(s[m][i] !=9){ /* Should no more exist */          else if(s[m][i] !=9){ /* Standard case, age in fractional
                                    years but with the precision of a
                                    month */
           agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]);            agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]);
           if(mint[m][i]==99 || anint[m][i]==9999)            if(mint[m][i]==99 || anint[m][i]==9999)
             agev[m][i]=1;              agev[m][i]=1;
Line 3783  int main(int argc, char *argv[]) Line 3793  int main(int argc, char *argv[])
   dh=imatrix(1,lastpass-firstpass+1,1,imx);    dh=imatrix(1,lastpass-firstpass+1,1,imx);
   bh=imatrix(1,lastpass-firstpass+1,1,imx);    bh=imatrix(1,lastpass-firstpass+1,1,imx);
   mw=imatrix(1,lastpass-firstpass+1,1,imx);    mw=imatrix(1,lastpass-firstpass+1,1,imx);
        
   
   /* Concatenates waves */    /* Concatenates waves */
   concatwav(wav, dh, bh, mw, s, agedc, agev,  firstpass, lastpass, imx, nlstate, stepm);    concatwav(wav, dh, bh, mw, s, agedc, agev,  firstpass, lastpass, imx, nlstate, stepm);
   
Line 3951  int main(int argc, char *argv[]) Line 3960  int main(int argc, char *argv[])
   fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mov_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav);    fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mov_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav);
   fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);    fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);
   fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);    fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);
     printf("begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);
     fprintf(ficlog,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);
         
   while((c=getc(ficpar))=='#' && c!= EOF){    while((c=getc(ficpar))=='#' && c!= EOF){
     ungetc(c,ficpar);      ungetc(c,ficpar);
Line 3976  int main(int argc, char *argv[]) Line 3987  int main(int argc, char *argv[])
   }    }
   ungetc(c,ficpar);    ungetc(c,ficpar);
   
   fscanf(ficpar,"starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf\n",&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2);    fscanf(ficpar,"prevforecast=%d starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mobil_average=%d\n",&prevfcast,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilavproj);
   fprintf(ficparo,"starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",jproj1,mproj1,anproj1,jproj2,mproj2,anproj2);    fprintf(ficparo,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",&prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj);
   fprintf(ficres,"starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",jproj1,mproj1,anproj1,jproj2,mproj2,anproj2);    printf("prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobilaverage=%d\n",&prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj);
     fprintf(ficlog,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobilaverage=%d\n",&prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj);
     fprintf(ficres,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobilaverage=%d\n",&prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj);
     /* day and month of proj2 are not used but only year anproj2.*/
   
   while((c=getc(ficpar))=='#' && c!= EOF){    while((c=getc(ficpar))=='#' && c!= EOF){
     ungetc(c,ficpar);      ungetc(c,ficpar);
Line 3993  int main(int argc, char *argv[]) Line 4006  int main(int argc, char *argv[])
   fprintf(ficparo,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);    fprintf(ficparo,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);
   fprintf(ficres,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);    fprintf(ficres,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);
   
   
   freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);    freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);
   
   /*------------ gnuplot -------------*/    /*------------ gnuplot -------------*/
Line 4087  Interval (in months) between two waves: Line 4099  Interval (in months) between two waves:
                   
       for (age=agebase; age<=agelim; age++){        for (age=agebase; age<=agelim; age++){
         prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k);          prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k);
         fprintf(ficrespl,"%.0f",age );          fprintf(ficrespl,"%.0f ",age );
           for(j=1;j<=cptcoveff;j++)
             fprintf(ficrespl,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
         for(i=1; i<=nlstate;i++)          for(i=1; i<=nlstate;i++)
           fprintf(ficrespl," %.5f", prlim[i][i]);            fprintf(ficrespl," %.5f", prlim[i][i]);
         fprintf(ficrespl,"\n");          fprintf(ficrespl,"\n");
Line 4156  Interval (in months) between two waves: Line 4170  Interval (in months) between two waves:
   
   
   /*---------- Forecasting ------------------*/    /*---------- Forecasting ------------------*/
    if((stepm == 1) && (strcmp(model,".")==0)){    /*if((stepm == 1) && (strcmp(model,".")==0)){*/
     prevforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anproj2,p, i1);    if(prevfcast==1){
     if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);      if(stepm ==1){
   }         prevforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilavproj, agedeb, fage, popforecast, popfile, anproj2,p, i1);
   else{        if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);
     erreur=108;      } 
     printf("Warning %d!! You can only forecast the prevalences if the optimization\n  has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model);      else{
     fprintf(ficlog,"Warning %d!! You can only forecast the prevalences if the optimization\n  has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model);        erreur=108;
         printf("Warning %d!! You can only forecast the prevalences if the optimization\n  has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model);
         fprintf(ficlog,"Warning %d!! You can only forecast the prevalences if the optimization\n  has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model);
     }      }
     }
       
   
   /*---------- Health expectancies and variances ------------*/    /*---------- Health expectancies and variances ------------*/
Line 4188  Interval (in months) between two waves: Line 4205  Interval (in months) between two waves:
   printf("Computing Health Expectancies: result on file '%s' \n", filerese);    printf("Computing Health Expectancies: result on file '%s' \n", filerese);
   fprintf(ficlog,"Computing Health Expectancies: result on file '%s' \n", filerese);    fprintf(ficlog,"Computing Health Expectancies: result on file '%s' \n", filerese);
   
   
   strcpy(fileresv,"v");    strcpy(fileresv,"v");
   strcat(fileresv,fileres);    strcat(fileresv,fileres);
   if((ficresvij=fopen(fileresv,"w"))==NULL) {    if((ficresvij=fopen(fileresv,"w"))==NULL) {
Line 4198  Interval (in months) between two waves: Line 4214  Interval (in months) between two waves:
   printf("Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);    printf("Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);
   fprintf(ficlog,"Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);    fprintf(ficlog,"Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);
   
   calagedate=-1;    calagedatem=-1;
   
   prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);    prevalence(ageminpar, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedatem);
   
   if (mobilav!=0) {    if (mobilav!=0) {
     mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);      mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);

Removed from v.1.68  
changed lines
  Added in v.1.69


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