if ((k2>=dateprev1) && (k2<=dateprev2)) {\r
if(agev[m][i]==0) agev[m][i]=agemax+1;\r
if(agev[m][i]==1) agev[m][i]=agemax+2;\r
- freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-1/12.)] += weight[i];\r
+ freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-((int)calagedate %12)/12.)] += weight[i];\r
freq[s[m][i]][s[m+1][i]][(int)(agemax+3+1)] += weight[i]; \r
}\r
}\r
mprojmean=yp;\r
yp1=modf((yp2*30.5),&yp);\r
jprojmean=yp;\r
- fprintf(ficresf,"Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean); \r
+ if(jprojmean==0) jprojmean=1;\r
+ if(mprojmean==0) jprojmean=1;\r
+\r
+ fprintf(ficresf,"# Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean); \r
\r
if (popforecast==1) {\r
if((ficpop=fopen(popfile,"r"))==NULL) {\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<=1;cpt++) { \r
+ for (cpt=0; cpt<=5;cpt++) { \r
fprintf(ficresf,"\n");\r
- fprintf(ficresf,"\nForecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); \r
- for (agedeb=(fage-(1/12.)); agedeb>=(bage-(1/12.)); agedeb--){ /* If stepm=6 months */\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
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
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); \r
\r
for (h=0; h<=nhstepm; h++){\r
- if (h==(int) (calagedate+12*cpt)) {\r
- fprintf(ficresf,"h=%d ", h);\r
- fprintf(ficresf,"\n %f %f ",agedeb,agedeb+h*hstepm/YEARM*stepm);\r
+ if (h==(int) (calagedate+YEARM*cpt)) {\r
+ fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm);\r
}\r
for(j=1; j<=nlstate+ndeath;j++) {\r
kk1=0.;kk2=0;\r
for(i=1; i<=nlstate;i++) { \r
if (mobilav==1) \r
- kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod];\r
+ kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb+1][i][cptcod];\r
else {\r
kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod];\r
- /* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h],probs[(int)(agedeb)+1][i][cptcod]);*/\r
+ /* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h], probs[(int)(agedeb)+1][i][cptcod]);*/\r
}\r
\r
if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];\r