]> henry.ined.fr Git - .git/commitdiff
Prevalence and forecasting
authorAgnès Lièvre <agnes.lievre@education.gouv.fr>
Wed, 20 Feb 2002 17:22:01 +0000 (17:22 +0000)
committerAgnès Lièvre <agnes.lievre@education.gouv.fr>
Wed, 20 Feb 2002 17:22:01 +0000 (17:22 +0000)
src/imach.c

index 9fdeaddf9fbddf2881363a1455083417f405df4f..d938b4a5e1b2a3eb84c273b8306ee5fa9625b8ca 100644 (file)
@@ -1318,7 +1318,7 @@ void prevalence(int agemin, int agemax, int **s, double **agev, int nlstate, int
            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
@@ -2876,7 +2876,10 @@ fclose(fichtm);
   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
@@ -2908,10 +2911,10 @@ fclose(fichtm);
       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,"\nForecasting 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
@@ -2921,18 +2924,17 @@ fclose(fichtm);
        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