#define AGEBASE 40\r
\r
\r
+int erreur; /* Error number */\r
int nvar;\r
int cptcovn, cptcovage=0, cptcoveff=0,cptcov;\r
int npar=NPARMAX;\r
powell(p,xi,npar,ftol,&iter,&fret,func);\r
\r
printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p));\r
- fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f ",iter,func(p));\r
+ fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p));\r
\r
}\r
\r
}\r
\r
fclose(ficgp);\r
+ /* end gnuplot */\r
\r
chdir(path);\r
\r
\r
fclose(ficrespij);\r
\r
+ if(stepm == 1) {\r
/*---------- Forecasting ------------------*/\r
calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;\r
\r
+ /*printf("calage= %f", calagedate);*/\r
+ \r
prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);\r
\r
\r
fprintf(ficresf,"# StartingAge FinalAge");\r
for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j);\r
if (popforecast==1) fprintf(ficresf," [Population]");\r
- \r
- for (cpt=0; cpt<=5;cpt++) { \r
+ \r
+ for (cpt=0; cpt<4;cpt++) { \r
fprintf(ficresf,"\n");\r
- fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); \r
- for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(bage-((int)calagedate %12)/12.); agedeb--){ /* If stepm=6 months */\r
+ fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); \r
+\r
+ for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(bage-((int)calagedate %12)/12.); agedeb--){ /* If stepm=6 months */\r
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); \r
nhstepm = nhstepm/hstepm; \r
/*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/\r
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
oldm=oldms;savm=savms;\r
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); \r
- \r
+ \r
for (h=0; h<=nhstepm; h++){\r
if (h==(int) (calagedate+YEARM*cpt)) {\r
fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm);\r
- }\r
+ } \r
for(j=1; j<=nlstate+ndeath;j++) {\r
kk1=0.;kk2=0;\r
for(i=1; i<=nlstate;i++) { \r
free_imatrix(s,1,maxwav+1,1,n);\r
free_vector(weight,1,n);\r
fclose(ficresf);\r
+ }/* End forecasting */\r
+ else{\r
+ erreur=108;\r
+ 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);\r
+ }\r
+\r
/*---------- Health expectancies and variances ------------*/\r
\r
strcpy(filerest,"t");\r
\r
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel);\r
\r
- printf("End of Imach\n");\r
+ if(erreur >0)\r
+ printf("End of Imach with error %d\n",erreur);\r
+ else printf("End of Imach\n");\r
/* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */\r
\r
/* 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);*/\r