--- imach/src/imach.c 2002/02/20 17:15:02 1.17 +++ imach/src/imach.c 2002/02/21 18:42:24 1.21 @@ -67,6 +67,7 @@ #define AGEBASE 40 +int erreur; /* Error number */ int nvar; int cptcovn, cptcovage=0, cptcoveff=0,cptcov; int npar=NPARMAX; @@ -129,6 +130,7 @@ int m,nb; int *num, firstpass=0, lastpass=4,*cod, *ncodemax, *Tage; double **agev,*moisnais, *annais, *moisdc, *andc,**mint, **anint; double **pmmij, ***probs, ***mobaverage; +double dateintmean=0; double *weight; int **s; /* Status */ @@ -900,7 +902,7 @@ void mlikeli(FILE *ficres,double p[], in powell(p,xi,npar,ftol,&iter,&fret,func); printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p)); - fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f ",iter,func(p)); + fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p)); } @@ -1150,18 +1152,18 @@ void lubksb(double **a, int n, int *indx } /************ Frequencies ********************/ -void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax, int fprev1,int lprev1,double **mint,double **anint) +void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2) { /* Some frequencies */ - int i, m, jk, k1, k2,i1, j1, bool, z1,z2,j; + int i, m, jk, k1,i1, j1, bool, z1,z2,j; double ***freq; /* Frequencies */ double *pp; - double pos; + double pos, k2, dateintsum=0,k2cpt=0; FILE *ficresp; char fileresp[FILENAMELENGTH]; pp=vector(1,nlstate); - probs= ma3x(1,130 ,1,8, 1,8); + probs= ma3x(1,AGESUP,1,NCOVMAX, 1,NCOVMAX); strcpy(fileresp,"p"); strcat(fileresp,fileres); if((ficresp=fopen(fileresp,"w"))==NULL) { @@ -1183,7 +1185,9 @@ void freqsummary(char fileres[], int ag for (jk=-1; jk<=nlstate+ndeath; jk++) for(m=agemin; m <= agemax+3; m++) freq[i][jk][m]=0; - + + dateintsum=0; + k2cpt=0; for (i=1; i<=imx; i++) { bool=1; if (cptcovn>0) { @@ -1191,17 +1195,22 @@ void freqsummary(char fileres[], int ag if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtab[j1][z1]]) bool=0; } - if (bool==1) { - for(m=fprev1; m<=lprev1; m++){ + if (bool==1) { + for(m=firstpass; m<=lastpass; m++){ k2=anint[m][i]+(mint[m][i]/12.); - if ((k2>=1984) && (k2<=1988.5)) { - if(agev[m][i]==0) agev[m][i]=agemax+1; - if(agev[m][i]==1) agev[m][i]=agemax+2; - 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]; + if ((k2>=dateprev1) && (k2<=dateprev2)) { + if(agev[m][i]==0) agev[m][i]=agemax+1; + if(agev[m][i]==1) agev[m][i]=agemax+2; + 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]; + if ((agev[m][i]>1) && (agev[m][i]< (agemax+3))) { + dateintsum=dateintsum+k2; + k2cpt++; + } + } - } - } + } + } } if (cptcovn>0) { fprintf(ficresp, "\n#********** Variable "); @@ -1261,24 +1270,26 @@ void freqsummary(char fileres[], int ag } } } + dateintmean=dateintsum/k2cpt; fclose(ficresp); free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3); free_vector(pp,1,nlstate); -} /* End of Freq */ + /* End of Freq */ +} /************ Prevalence ********************/ -void prevalence(int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax, int fprev1,int lprev1) +void prevalence(int agemin, int 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) { /* Some frequencies */ int i, m, jk, k1, i1, j1, bool, z1,z2,j; double ***freq; /* Frequencies */ double *pp; - double pos; + double pos, k2; pp=vector(1,nlstate); - probs= ma3x(1,130 ,1,8, 1,8); + probs= ma3x(1,AGESUP,1,NCOVMAX, 1,NCOVMAX); freq=ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3); j1=0; @@ -1293,7 +1304,7 @@ void prevalence(int agemin, int agemax, for (i=-1; i<=nlstate+ndeath; i++) for (jk=-1; jk<=nlstate+ndeath; jk++) for(m=agemin; m <= agemax+3; m++) - freq[i][jk][m]=0; + freq[i][jk][m]=0; for (i=1; i<=imx; i++) { bool=1; @@ -1301,23 +1312,27 @@ void prevalence(int agemin, int agemax, for (z1=1; z1<=cptcoveff; z1++) if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtab[j1][z1]]) bool=0; - } - if (bool==1) { - for(m=fprev1; m<=lprev1; m++){ - if(agev[m][i]==0) agev[m][i]=agemax+1; - if(agev[m][i]==1) agev[m][i]=agemax+2; - 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]; + } + if (bool==1) { + for(m=firstpass; m<=lastpass; m++){ + k2=anint[m][i]+(mint[m][i]/12.); + if ((k2>=dateprev1) && (k2<=dateprev2)) { + if(agev[m][i]==0) agev[m][i]=agemax+1; + if(agev[m][i]==1) agev[m][i]=agemax+2; + 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)(agemax+3+1)] += weight[i]; + } } } } - for(i=(int)agemin; i <= (int)agemax+3; i++){ - for(jk=1; jk <=nlstate ; jk++){ - for(m=-1, pp[jk]=0; m <=nlstate+ndeath ; m++) - pp[jk] += freq[jk][m][i]; - } - for(jk=1; jk <=nlstate ; jk++){ - for(m=-1, pos=0; m <=0 ; m++) + + for(i=(int)agemin; i <= (int)agemax+3; i++){ + for(jk=1; jk <=nlstate ; jk++){ + for(m=-1, pp[jk]=0; m <=nlstate+ndeath ; m++) + pp[jk] += freq[jk][m][i]; + } + for(jk=1; jk <=nlstate ; jk++){ + for(m=-1, pos=0; m <=0 ; m++) pos += freq[jk][m][i]; } @@ -1336,7 +1351,7 @@ void prevalence(int agemin, int agemax, } } - } + } } } @@ -1345,6 +1360,7 @@ void prevalence(int agemin, int agemax, free_vector(pp,1,nlstate); } /* End of Freq */ + /************* Waves Concatenation ***************/ void concatwav(int wav[], int **dh, int **mw, int **s, double *agedc, double **agev, int firstpass, int lastpass, int imx, int nlstate, int stepm) @@ -1871,9 +1887,10 @@ int main() int ju,jl, mi; int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij; int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; - int mobilav=0, fprev, lprev ,fprevfore=1, lprevfore=1,nforecast,popforecast=0; + int mobilav=0,popforecast=0; int hstepm, nhstepm; - int *popage; + int *popage;/*boolprev=0 if date and zero if wave*/ + double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2; double bage, fage, age, agelim, agebase; double ftolpl=FTOL; @@ -1889,6 +1906,8 @@ int main() double *epj, vepp; double kk1, kk2; double *popeffectif,*popcount; + double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,jprojmean,mprojmean,anprojmean, calagedate; + double yp,yp1,yp2; char version[80]="Imach version 64b, May 2001, INED-EUROREVES "; char *alph[]={"a","a","b","c","d","e"}, str[4]; @@ -1898,6 +1917,7 @@ int main() #include #include char stra[80], strb[80], strc[80], strd[80],stre[80],modelsav[80]; + /* long total_usecs; struct timeval start_time, end_time; @@ -1960,31 +1980,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){ } ungetc(c,ficpar); - fscanf(ficpar,"fprevalence=%d lprevalence=%d pop_based=%d\n",&fprev,&lprev,&popbased); - fprintf(ficparo,"fprevalence=%d lprevalence=%d pop_based=%d\n",fprev,lprev,popbased); - - while((c=getc(ficpar))=='#' && c!= EOF){ - ungetc(c,ficpar); - fgets(line, MAXLINE, ficpar); - puts(line); - fputs(line,ficparo); - } - ungetc(c,ficpar); - - fscanf(ficpar,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",&fprevfore,&lprevfore,&nforecast,&mobilav); - fprintf(ficparo,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",fprevfore,lprevfore,nforecast,mobilav); - - -while((c=getc(ficpar))=='#' && c!= EOF){ - ungetc(c,ficpar); - fgets(line, MAXLINE, ficpar); - puts(line); - fputs(line,ficparo); - } - ungetc(c,ficpar); - - fscanf(ficpar,"popforecast=%d popfile=%s\n",&popforecast,popfile); - + covar=matrix(0,NCOVMAX,1,n); cptcovn=0; if (strlen(model)>1) cptcovn=nbocc(model,'+')+1; @@ -2147,7 +2143,9 @@ while((c=getc(ficpar))=='#' && c!= EOF){ if ((s[2][i]==3) && (s[3][i]==2)) s[3][i]=3; if ((s[3][i]==3) && (s[4][i]==2)) s[4][i]=3; } - for (i=1; i<=imx; i++) printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/ + + for (i=1; i<=imx; i++) + if (covar[1][i]==0) printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/ /* Calculation of the number of parameter from char model*/ Tvar=ivector(1,15); @@ -2329,12 +2327,10 @@ printf("Total number of individuals= %d, /* Calculates basic frequencies. Computes observed prevalence at single age and prints on file fileres'p'. */ - freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax, fprev, lprev,mint,anint); - - free_matrix(mint,1,maxwav,1,n); - free_matrix(anint,1,maxwav,1,n); - - pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ + + + + pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ savms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ @@ -2350,8 +2346,7 @@ printf("Total number of individuals= %d, /*--------- results files --------------*/ fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncov=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncov, nlstate, ndeath, maxwav, mle,weightopt,model); - fprintf(ficres,"fprevalence=%d lprevalence=%d pop_based=%d\n",fprev,lprev,popbased); - fprintf(ficres,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",fprevfore,lprevfore,nforecast,mobilav); + jk=1; fprintf(ficres,"# Parameters\n"); @@ -2393,7 +2388,7 @@ printf("Total number of individuals= %d, fprintf(ficres,"\n"); } } - } + } k=1; fprintf(ficres,"# Covariance\n"); @@ -2429,11 +2424,53 @@ printf("Total number of individuals= %d, fage = agemax; } - fprintf(ficres,"# agemin agemax for life expectancy, bage fage (if mle==0 ie no data nor Max likelihood).\n"); + fprintf(ficres,"# agemin agemax for life expectancy.\n"); + fprintf(ficres,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax,bage,fage); + fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax,bage,fage); + + while((c=getc(ficpar))=='#' && c!= EOF){ + ungetc(c,ficpar); + fgets(line, MAXLINE, ficpar); + puts(line); + fputs(line,ficparo); + } + ungetc(c,ficpar); + + fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mob_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav); + fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mob_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); + fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mob_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); + + while((c=getc(ficpar))=='#' && c!= EOF){ + ungetc(c,ficpar); + fgets(line, MAXLINE, ficpar); + puts(line); + fputs(line,ficparo); + } + ungetc(c,ficpar); + - -/*------------ gnuplot -------------*/ + dateprev1=anprev1+mprev1/12.+jprev1/365.; + dateprev2=anprev2+mprev2/12.+jprev2/365.; + + fscanf(ficpar,"pop_based=%d\n",&popbased); + fprintf(ficparo,"pop_based=%d\n",popbased); + fprintf(ficres,"pop_based=%d\n",popbased); + + while((c=getc(ficpar))=='#' && c!= EOF){ + ungetc(c,ficpar); + fgets(line, MAXLINE, ficpar); + puts(line); + fputs(line,ficparo); + } + ungetc(c,ficpar); + fscanf(ficpar,"popforecast=%d popfile=%s starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf\n",&popforecast,popfile,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2); +fprintf(ficparo,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2); +fprintf(ficres,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2); + + freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2); + + /*------------ gnuplot -------------*/ chdir(pathcd); if((ficgp=fopen("graph.plt","w"))==NULL) { printf("Problem with file graph.gp");goto end; @@ -2596,6 +2633,7 @@ ij=1; } fclose(ficgp); + /* end gnuplot */ chdir(path); @@ -2649,7 +2687,7 @@ Interval (in months) between two waves: - Variances of life expectancies by age and initial health status: v%s
- Health expectancies with their variances: t%s
- Standard deviation of stationary prevalences: vpl%s
- - Prevalences forecasting: f%s
+ - Prevalences and population forecasting: f%s

",title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres); fprintf(fichtm,"
  • Graphs
  • "); @@ -2788,7 +2826,14 @@ fclose(fichtm); fclose(ficrespij); + if(stepm == 1) { /*---------- Forecasting ------------------*/ + calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM; + + /*printf("calage= %f", calagedate);*/ + + prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate); + strcpy(fileresf,"f"); strcat(fileresf,fileres); @@ -2797,9 +2842,9 @@ fclose(fichtm); } printf("Computing forecasting: result on file '%s' \n", fileresf); - prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax, fprevfore, lprevfore); - - free_matrix(agev,1,maxwav,1,imx); + free_matrix(mint,1,maxwav,1,n); + free_matrix(anint,1,maxwav,1,n); + free_matrix(agev,1,maxwav,1,imx); /* Mobile average */ if (cptcoveff==0) ncodemax[cptcoveff]=1; @@ -2827,9 +2872,20 @@ fclose(fichtm); if (stepm<=12) stepsize=1; agelim=AGESUP; - hstepm=stepsize*YEARM; /* Every year of age */ + /*hstepm=stepsize*YEARM; *//* Every year of age */ + hstepm=1; hstepm=hstepm/stepm; /* Typically 2 years, = 2 years/6 months = 4 */ - + yp1=modf(dateintmean,&yp); + anprojmean=yp; + yp2=modf((yp1*12),&yp); + mprojmean=yp; + yp1=modf((yp2*30.5),&yp); + jprojmean=yp; + if(jprojmean==0) jprojmean=1; + if(mprojmean==0) jprojmean=1; + + fprintf(ficresf,"# Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean); + if (popforecast==1) { if((ficpop=fopen(popfile,"r"))==NULL) { printf("Problem with population file : %s\n",popfile);goto end; @@ -2844,40 +2900,27 @@ fclose(fichtm); i=i+1; } imx=i; - - for (i=1; i=bage; agedeb--){ - fprintf(ficresf,"\n%.f %.f 0",agedeb, agedeb); - if (mobilav==1) { - for(j=1; j<=nlstate;j++) - fprintf(ficresf," %.3f",mobaverage[(int)agedeb][j][cptcod]); - } - else { - for(j=1; j<=nlstate;j++) - fprintf(ficresf," %.3f",probs[(int)agedeb][j][cptcod]); - } - - for(j=1; j<=ndeath;j++) fprintf(ficresf," 0.00000"); - if (popforecast==1) fprintf(ficresf," [%.f] ",popeffectif[(int)agedeb]); - } - - for (cpt=1; cpt<=nforecast;cpt++) { + + for (cpt=0; cpt<4;cpt++) { fprintf(ficresf,"\n"); - for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */ + fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); + + for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(bage-((int)calagedate %12)/12.); agedeb--){ /* If stepm=6 months */ nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); nhstepm = nhstepm/hstepm; /*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/ @@ -2885,29 +2928,32 @@ fclose(fichtm); p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); oldm=oldms;savm=savms; hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); - - for (h=0; h<=nhstepm; h++){ - if (h*hstepm/YEARM*stepm==cpt) - fprintf(ficresf,"\n%.f %.f %.f",agedeb, agedeb+ h*hstepm/YEARM*stepm, h*hstepm/YEARM*stepm); + for (h=0; h<=nhstepm; h++){ + if (h==(int) (calagedate+YEARM*cpt)) { + fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm); + } + for(j=1; j<=nlstate+ndeath;j++) { + kk1=0.;kk2=0; + for(i=1; i<=nlstate;i++) { + if (mobilav==1) + kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb+1][i][cptcod]; + else { + kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod]; + /* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h], probs[(int)(agedeb)+1][i][cptcod]);*/ + } + + if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb]; + } - - for(j=1; j<=nlstate+ndeath;j++) { - kk1=0.;kk2=0; - for(i=1; i<=nlstate;i++) { - if (mobilav==1) - kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod]; - else kk1=kk1+p3mat[i][j][h]*probs[(int)agedeb][i][cptcod]; - if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb]; + if (h==(int)(calagedate+12*cpt)){ + fprintf(ficresf," %.3f", kk1); + + if (popforecast==1) fprintf(ficresf," [%.f]", kk2); } - if (h*hstepm/YEARM*stepm==cpt) { - fprintf(ficresf," %.3f", kk1); - if (popforecast==1) fprintf(ficresf," [%.f]", kk2); - } } } free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); - } } } @@ -2921,6 +2967,12 @@ fclose(fichtm); free_imatrix(s,1,maxwav+1,1,n); free_vector(weight,1,n); fclose(ficresf); + }/* End forecasting */ + else{ + erreur=108; + printf("Error %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d\n", erreur, stepm); + } + /*---------- Health expectancies and variances ------------*/ strcpy(filerest,"t"); @@ -3058,7 +3110,9 @@ strcpy(fileresvpl,"vpl"); free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel); - printf("End of Imach\n"); + if(erreur >0) + printf("End of Imach with error %d\n",erreur); + else printf("End of Imach\n"); /* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */ /* printf("Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec);*/