- Graphs
");
- for (i=1; i<=(nlstate+ndeath)*(nlstate+ndeath-1);i++){
- if (i== 2) fprintf(ficresprob,"%.3e %.3e ",gm[i],doldm[i][i]);
-if (i== 4) fprintf(ficresprob,"%.3e %.3e ",gm[i],doldm[i][i]);
- }
+ m=cptcoveff;
+ if (cptcovn < 1) {m=1;ncodemax[1]=1;}
- free_vector(gp,1,(nlstate+ndeath)*(nlstate+ndeath));
- free_vector(gm,1,(nlstate+ndeath)*(nlstate+ndeath));
- free_matrix(trgradg,1,(nlstate+ndeath)*(nlstate+ndeath),1,npar);
- free_matrix(gradg,1,(nlstate+ndeath)*(nlstate+ndeath),1,npar);
-}
- free_vector(xp,1,npar);
-fclose(ficresprob);
- exit(0);
+ jj1=0;
+ for(k1=1; k1<=m;k1++){
+ for(i1=1; i1<=ncodemax[k1];i1++){
+ jj1++;
+ if (cptcovn > 0) {
+ fprintf(fichtm,"
************ Results for covariates");
+ for (cpt=1; cpt<=cptcoveff;cpt++)
+ fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtab[jj1][cpt]]);
+ fprintf(fichtm," ************\n
");
+ }
+ for(cpt=1; cpt<=nlstate;cpt++) {
+ fprintf(fichtm,"
- Observed (cross-sectional) and period (incidence based) \
+prevalence (with 95%% confidence interval) in state (%d): %s%d%d.png
\
+",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1);
+ }
+ fprintf(fichtm,"\n
- Total life expectancy by age and \
+health expectancies in states (1) and (2): %s%d.png
\
+",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1);
+ } /* end i1 */
+ }/* End k1 */
+ fprintf(fichtm,"
");
+ fflush(fichtm);
}
-/***********************************************/
-/**************** Main Program *****************/
-/***********************************************/
-
-int main(int argc, char *argv[])
-{
+/******************* Gnuplot file **************/
+void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){
- int i,j, k, n=MAXN,iter,m,size,cptcode, cptcod;
- double agedeb, agefin,hf;
- double agemin=1.e20, agemax=-1.e20;
+ char dirfileres[132],optfileres[132];
+ int m,cpt,k1,i,k,j,jk,k2,k3,ij,l;
+ int ng;
+/* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */
+/* printf("Problem with file %s",optionfilegnuplot); */
+/* fprintf(ficlog,"Problem with file %s",optionfilegnuplot); */
+/* } */
+
+ /*#ifdef windows */
+ fprintf(ficgp,"cd \"%s\" \n",pathc);
+ /*#endif */
+ m=pow(2,cptcoveff);
- double fret;
- double **xi,tmp,delta;
+ strcpy(dirfileres,optionfilefiname);
+ strcpy(optfileres,"vpl");
+ /* 1eme*/
+ for (cpt=1; cpt<= nlstate ; cpt ++) {
+ for (k1=1; k1<= m ; k1 ++) {
+ fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"v"),cpt,k1);
+ fprintf(ficgp,"\n#set out \"v%s%d%d.png\" \n",optionfilefiname,cpt,k1);
+ fprintf(ficgp,"set xlabel \"Age\" \n\
+set ylabel \"Probability\" \n\
+set ter png small\n\
+set size 0.65,0.65\n\
+plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"\%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1);
- double dum; /* Dummy variable */
- double ***p3mat;
+ for (i=1; i<= nlstate ; i ++) {
+ if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1);
+ for (i=1; i<= nlstate ; i ++) {
+ if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ fprintf(ficgp,"\" t\"95\%% CI\" w l 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1);
+ for (i=1; i<= nlstate ; i ++) {
+ if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ fprintf(ficgp,"\" t\"\" w l 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l 2",subdirf2(fileres,"p"),k1-1,k1-1,2+4*(cpt-1));
+ }
+ }
+ /*2 eme*/
+
+ for (k1=1; k1<= m ; k1 ++) {
+ fprintf(ficgp,"\nset out \"%s%d.png\" \n",subdirf2(optionfilefiname,"e"),k1);
+ fprintf(ficgp,"set ylabel \"Years\" \nset ter png small\nset size 0.65,0.65\nplot [%.f:%.f] ",ageminpar,fage);
+
+ for (i=1; i<= nlstate+1 ; i ++) {
+ k=2*i;
+ fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
+ for (j=1; j<= nlstate+1 ; j ++) {
+ if (j==i) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l ,");
+ else fprintf(ficgp,"\" t\"LE in state (%d)\" w l ,",i-1);
+ fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
+ for (j=1; j<= nlstate+1 ; j ++) {
+ if (j==i) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ fprintf(ficgp,"\" t\"\" w l 0,");
+ fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
+ for (j=1; j<= nlstate+1 ; j ++) {
+ if (j==i) fprintf(ficgp," \%%lf (\%%lf)");
+ else fprintf(ficgp," \%%*lf (\%%*lf)");
+ }
+ if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l 0");
+ else fprintf(ficgp,"\" t\"\" w l 0,");
+ }
+ }
+
+ /*3eme*/
+
+ for (k1=1; k1<= m ; k1 ++) {
+ for (cpt=1; cpt<= nlstate ; cpt ++) {
+ /* k=2+nlstate*(2*cpt-2); */
+ k=2+(nlstate+1)*(cpt-1);
+ fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"exp"),cpt,k1);
+ fprintf(ficgp,"set ter png small\n\
+set size 0.65,0.65\n\
+plot [%.f:%.f] \"%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",ageminpar,fage,subdirf2(fileres,"e"),k1-1,k1-1,k,cpt);
+ /*fprintf(ficgp,",\"e%s\" every :::%d::%d u 1:($%d-2*$%d) \"\%%lf ",fileres,k1-1,k1-1,k,k+1);
+ for (i=1; i<= nlstate*2 ; i ++) fprintf(ficgp,"\%%lf (\%%lf) ");
+ fprintf(ficgp,"\" t \"e%d1\" w l",cpt);
+ fprintf(ficgp,",\"e%s\" every :::%d::%d u 1:($%d+2*$%d) \"\%%lf ",fileres,k1-1,k1-1,k,k+1);
+ for (i=1; i<= nlstate*2 ; i ++) fprintf(ficgp,"\%%lf (\%%lf) ");
+ fprintf(ficgp,"\" t \"e%d1\" w l",cpt);
+
+ */
+ for (i=1; i< nlstate ; i ++) {
+ fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+i,cpt,i+1);
+ /* fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+2*i,cpt,i+1);*/
+
+ }
+ fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d.\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+nlstate,cpt);
+ }
+ }
+
+ /* CV preval stable (period) */
+ for (k1=1; k1<= m ; k1 ++) {
+ for (cpt=1; cpt<=nlstate ; cpt ++) {
+ k=3;
+ fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"p"),cpt,k1);
+ fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
+set ter png small\nset size 0.65,0.65\n\
+unset log y\n\
+plot [%.f:%.f] \"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",ageminpar,agemaxpar,subdirf2(fileres,"pij"),k1,k+cpt+1,k+1);
+
+ for (i=1; i< nlstate ; i ++)
+ fprintf(ficgp,"+$%d",k+i+1);
+ fprintf(ficgp,")) t\"prev(%d,%d)\" w l",cpt,cpt+1);
+
+ l=3+(nlstate+ndeath)*cpt;
+ fprintf(ficgp,",\"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",subdirf2(fileres,"pij"),k1,l+cpt+1,l+1);
+ for (i=1; i< nlstate ; i ++) {
+ l=3+(nlstate+ndeath)*cpt;
+ fprintf(ficgp,"+$%d",l+i+1);
+ }
+ fprintf(ficgp,")) t\"prev(%d,%d)\" w l\n",cpt+1,cpt+1);
+ }
+ }
+
+ /* proba elementaires */
+ for(i=1,jk=1; i <=nlstate; i++){
+ for(k=1; k <=(nlstate+ndeath); k++){
+ if (k != i) {
+ for(j=1; j <=ncovmodel; j++){
+ fprintf(ficgp,"p%d=%f ",jk,p[jk]);
+ jk++;
+ fprintf(ficgp,"\n");
+ }
+ }
+ }
+ }
+
+ for(ng=1; ng<=2;ng++){ /* Number of graphics: first is probabilities second is incidence per year*/
+ for(jk=1; jk <=m; jk++) {
+ fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"pe"),jk,ng);
+ if (ng==2)
+ fprintf(ficgp,"\nset ylabel \"Quasi-incidence per year\"\n");
+ else
+ fprintf(ficgp,"\nset title \"Probability\"\n");
+ fprintf(ficgp,"\nset ter png small\nset size 0.65,0.65\nset log y\nplot [%.f:%.f] ",ageminpar,agemaxpar);
+ i=1;
+ for(k2=1; k2<=nlstate; k2++) {
+ k3=i;
+ for(k=1; k<=(nlstate+ndeath); k++) {
+ if (k != k2){
+ if(ng==2)
+ fprintf(ficgp," %f*exp(p%d+p%d*x",YEARM/stepm,i,i+1);
+ else
+ fprintf(ficgp," exp(p%d+p%d*x",i,i+1);
+ ij=1;
+ for(j=3; j <=ncovmodel; j++) {
+ if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) {
+ fprintf(ficgp,"+p%d*%d*x",i+j-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);
+ ij++;
+ }
+ else
+ fprintf(ficgp,"+p%d*%d",i+j-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]);
+ }
+ fprintf(ficgp,")/(1");
+
+ for(k1=1; k1 <=nlstate; k1++){
+ fprintf(ficgp,"+exp(p%d+p%d*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1);
+ ij=1;
+ for(j=3; j <=ncovmodel; j++){
+ if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) {
+ fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]);
+ ij++;
+ }
+ else
+ fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2,nbcode[Tvar[j-2]][codtab[jk][j-2]]);
+ }
+ fprintf(ficgp,")");
+ }
+ fprintf(ficgp,") t \"p%d%d\" ", k2,k);
+ if ((k+k2)!= (nlstate*2+ndeath)) fprintf(ficgp,",");
+ i=i+ncovmodel;
+ }
+ } /* end k */
+ } /* end k2 */
+ } /* end jk */
+ } /* end ng */
+ fflush(ficgp);
+} /* end gnuplot */
+
+
+/*************** Moving average **************/
+int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav){
+
+ int i, cpt, cptcod;
+ int modcovmax =1;
+ int mobilavrange, mob;
+ double age;
+
+ modcovmax=2*cptcoveff;/* Max number of modalities. We suppose
+ a covariate has 2 modalities */
+ if (cptcovn<1) modcovmax=1; /* At least 1 pass */
+
+ if(mobilav==1||mobilav ==3 ||mobilav==5 ||mobilav== 7){
+ if(mobilav==1) mobilavrange=5; /* default */
+ else mobilavrange=mobilav;
+ for (age=bage; age<=fage; age++)
+ for (i=1; i<=nlstate;i++)
+ for (cptcod=1;cptcod<=modcovmax;cptcod++)
+ mobaverage[(int)age][i][cptcod]=probs[(int)age][i][cptcod];
+ /* We keep the original values on the extreme ages bage, fage and for
+ fage+1 and bage-1 we use a 3 terms moving average; for fage+2 bage+2
+ we use a 5 terms etc. until the borders are no more concerned.
+ */
+ for (mob=3;mob <=mobilavrange;mob=mob+2){
+ for (age=bage+(mob-1)/2; age<=fage-(mob-1)/2; age++){
+ for (i=1; i<=nlstate;i++){
+ for (cptcod=1;cptcod<=modcovmax;cptcod++){
+ mobaverage[(int)age][i][cptcod] =probs[(int)age][i][cptcod];
+ for (cpt=1;cpt<=(mob-1)/2;cpt++){
+ mobaverage[(int)age][i][cptcod] +=probs[(int)age-cpt][i][cptcod];
+ mobaverage[(int)age][i][cptcod] +=probs[(int)age+cpt][i][cptcod];
+ }
+ mobaverage[(int)age][i][cptcod]=mobaverage[(int)age][i][cptcod]/mob;
+ }
+ }
+ }/* end age */
+ }/* end mob */
+ }else return -1;
+ return 0;
+}/* End movingaverage */
+
+
+/************** Forecasting ******************/
+prevforecast(char fileres[], double anproj1, double mproj1, double jproj1, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double bage, double fage, int firstpass, int lastpass, double anproj2, double p[], int cptcoveff){
+ /* proj1, year, month, day of starting projection
+ agemin, agemax range of age
+ dateprev1 dateprev2 range of dates during which prevalence is computed
+ anproj2 year of en of projection (same day and month as proj1).
+ */
+ int yearp, stepsize, hstepm, nhstepm, j, k, c, cptcod, i, h, i1;
+ int *popage;
+ double agec; /* generic age */
+ double agelim, ppij, yp,yp1,yp2,jprojmean,mprojmean,anprojmean;
+ double *popeffectif,*popcount;
+ double ***p3mat;
+ double ***mobaverage;
+ char fileresf[FILENAMELENGTH];
+
+ agelim=AGESUP;
+ prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass);
+
+ strcpy(fileresf,"f");
+ strcat(fileresf,fileres);
+ if((ficresf=fopen(fileresf,"w"))==NULL) {
+ printf("Problem with forecast resultfile: %s\n", fileresf);
+ fprintf(ficlog,"Problem with forecast resultfile: %s\n", fileresf);
+ }
+ printf("Computing forecasting: result on file '%s' \n", fileresf);
+ fprintf(ficlog,"Computing forecasting: result on file '%s' \n", fileresf);
+
+ if (cptcoveff==0) ncodemax[cptcoveff]=1;
+
+ if (mobilav!=0) {
+ mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ if (movingaverage(probs, ageminpar, fage, mobaverage,mobilav)!=0){
+ fprintf(ficlog," Error in movingaverage mobilav=%d\n",mobilav);
+ printf(" Error in movingaverage mobilav=%d\n",mobilav);
+ }
+ }
+
+ stepsize=(int) (stepm+YEARM-1)/YEARM;
+ if (stepm<=12) stepsize=1;
+ if(estepm < stepm){
+ printf ("Problem %d lower than %d\n",estepm, stepm);
+ }
+ else hstepm=estepm;
+
+ hstepm=hstepm/stepm;
+ yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp and
+ fractional in yp1 */
+ 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;
+
+ i1=cptcoveff;
+ if (cptcovn < 1){i1=1;}
+
+ fprintf(ficresf,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jprojmean,mprojmean,anprojmean,dateintmean,dateprev1,dateprev2);
+
+ fprintf(ficresf,"#****** Routine prevforecast **\n");
+
+/* if (h==(int)(YEARM*yearp)){ */
+ for(cptcov=1, k=0;cptcov<=i1;cptcov++){
+ for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){
+ k=k+1;
+ fprintf(ficresf,"\n#******");
+ for(j=1;j<=cptcoveff;j++) {
+ fprintf(ficresf," V%d=%d, hpijx=probability over h years, hp.jx is weighted by observed prev ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
+ }
+ fprintf(ficresf,"******\n");
+ fprintf(ficresf,"# Covariate valuofcovar yearproj age");
+ for(j=1; j<=nlstate+ndeath;j++){
+ for(i=1; i<=nlstate;i++)
+ fprintf(ficresf," p%d%d",i,j);
+ fprintf(ficresf," p.%d",j);
+ }
+ for (yearp=0; yearp<=(anproj2-anproj1);yearp +=stepsize) {
+ fprintf(ficresf,"\n");
+ fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+yearp);
+
+ for (agec=fage; agec>=(ageminpar-1); agec--){
+ nhstepm=(int) rint((agelim-agec)*YEARM/stepm);
+ nhstepm = nhstepm/hstepm;
+ p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
+ oldm=oldms;savm=savms;
+ hpxij(p3mat,nhstepm,agec,hstepm,p,nlstate,stepm,oldm,savm, k);
+
+ for (h=0; h<=nhstepm; h++){
+ if (h*hstepm/YEARM*stepm ==yearp) {
+ 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,agec+h*hstepm/YEARM*stepm);
+ }
+ for(j=1; j<=nlstate+ndeath;j++) {
+ ppij=0.;
+ for(i=1; i<=nlstate;i++) {
+ if (mobilav==1)
+ ppij=ppij+p3mat[i][j][h]*mobaverage[(int)agec][i][cptcod];
+ else {
+ ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][cptcod];
+ }
+ if (h*hstepm/YEARM*stepm== yearp) {
+ fprintf(ficresf," %.3f", p3mat[i][j][h]);
+ }
+ } /* end i */
+ if (h*hstepm/YEARM*stepm==yearp) {
+ fprintf(ficresf," %.3f", ppij);
+ }
+ }/* end j */
+ } /* end h */
+ free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
+ } /* end agec */
+ } /* end yearp */
+ } /* end cptcod */
+ } /* end cptcov */
+
+ if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+
+ fclose(ficresf);
+}
+
+/************** Forecasting *****not tested NB*************/
+populforecast(char fileres[], double anpyram,double mpyram,double jpyram,double ageminpar, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anpyram1,double p[], int i2){
+
+ int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;
+ int *popage;
+ double calagedatem, agelim, kk1, kk2;
+ double *popeffectif,*popcount;
+ double ***p3mat,***tabpop,***tabpopprev;
+ double ***mobaverage;
+ char filerespop[FILENAMELENGTH];
+
+ tabpop= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ tabpopprev= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ agelim=AGESUP;
+ calagedatem=(anpyram+mpyram/12.+jpyram/365.-dateintmean)*YEARM;
+
+ prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass);
+
+
+ strcpy(filerespop,"pop");
+ strcat(filerespop,fileres);
+ if((ficrespop=fopen(filerespop,"w"))==NULL) {
+ printf("Problem with forecast resultfile: %s\n", filerespop);
+ fprintf(ficlog,"Problem with forecast resultfile: %s\n", filerespop);
+ }
+ printf("Computing forecasting: result on file '%s' \n", filerespop);
+ fprintf(ficlog,"Computing forecasting: result on file '%s' \n", filerespop);
+
+ if (cptcoveff==0) ncodemax[cptcoveff]=1;
+
+ if (mobilav!=0) {
+ mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ if (movingaverage(probs, ageminpar, fage, mobaverage,mobilav)!=0){
+ fprintf(ficlog," Error in movingaverage mobilav=%d\n",mobilav);
+ printf(" Error in movingaverage mobilav=%d\n",mobilav);
+ }
+ }
+
+ stepsize=(int) (stepm+YEARM-1)/YEARM;
+ if (stepm<=12) stepsize=1;
+
+ agelim=AGESUP;
+
+ hstepm=1;
+ hstepm=hstepm/stepm;
+
+ if (popforecast==1) {
+ if((ficpop=fopen(popfile,"r"))==NULL) {
+ printf("Problem with population file : %s\n",popfile);exit(0);
+ fprintf(ficlog,"Problem with population file : %s\n",popfile);exit(0);
+ }
+ popage=ivector(0,AGESUP);
+ popeffectif=vector(0,AGESUP);
+ popcount=vector(0,AGESUP);
+
+ i=1;
+ while ((c=fscanf(ficpop,"%d %lf\n",&popage[i],&popcount[i])) != EOF) i=i+1;
+
+ imx=i;
+ for (i=1; i