Imach, Version 0.8
Title=%s
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s
Total number of observations=%d
@@ -1910,8 +1919,9 @@ 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 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);
+ - Prevalences forecasting: f%s
+ - Population forecasting (if popforecast=1): pop%s
+
",title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,rfileres,rfileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres,fileres);
fprintf(fichtm," - Graphs
");
@@ -1953,7 +1963,7 @@ fclose(fichtm);
}
/******************* Gnuplot file **************/
-void printinggnuplot(char fileres[],char optionfilefiname[],char optionfile[],char optionfilegnuplot[], double agemin, double agemax, double fage , char pathc[], double p[]){
+void printinggnuplot(char fileres[],char optionfilefiname[],char optionfile[],char optionfilegnuplot[], double agemin, double agemaxpar, double fage , char pathc[], double p[]){
int m,cpt,k1,i,k,j,jk,k2,k3,ij,l;
@@ -2048,7 +2058,7 @@ fprintf(ficgp,"\nset out \"v%s%d%d.gif\"
for (k1=1; k1<= m ; k1 ++) {
for (cpt=1; cpt=(agemin-((int)calagedate %12)/12.); agedeb--){
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);
nhstepm = nhstepm/hstepm;
@@ -2250,7 +2260,7 @@ calagedate=(anproj1+mproj1/12.+jproj1/36
fclose(ficresf);
}
/************** Forecasting ******************/
-populforecast(char fileres[], double anproj1,double mproj1,double jproj1,double agemin, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anproj2,double p[], int i2){
+populforecast(char fileres[], double anpyram,double mpyram,double jpyram,double agemin, 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;
@@ -2259,14 +2269,14 @@ populforecast(char fileres[], double anp
double ***p3mat,***tabpop,***tabpopprev;
char filerespop[FILENAMELENGTH];
-tabpop= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
-tabpopprev= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
- agelim=AGESUP;
-calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;
+ tabpop= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ tabpopprev= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ agelim=AGESUP;
+ calagedate=(anpyram+mpyram/12.+jpyram/365.-dateintmean)*YEARM;
prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);
-
-
+
+
strcpy(filerespop,"pop");
strcat(filerespop,fileres);
if((ficrespop=fopen(filerespop,"w"))==NULL) {
@@ -2312,12 +2322,12 @@ calagedate=(anproj1+mproj1/12.+jproj1/36
fprintf(ficrespop," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
}
fprintf(ficrespop,"******\n");
- fprintf(ficrespop,"# StartingAge FinalAge");
+ fprintf(ficrespop,"# Age");
for(j=1; j<=nlstate+ndeath;j++) fprintf(ficrespop," P.%d",j);
if (popforecast==1) fprintf(ficrespop," [Population]");
for (cpt=0; cpt<=0;cpt++) {
- fprintf(ficrespop,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);
+ fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);
for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(agemin-((int)calagedate %12)/12.); agedeb--){
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);
@@ -2329,7 +2339,7 @@ calagedate=(anproj1+mproj1/12.+jproj1/36
for (h=0; h<=nhstepm; h++){
if (h==(int) (calagedate+YEARM*cpt)) {
- fprintf(ficrespop,"\n %.f ",agedeb+h*hstepm/YEARM*stepm);
+ fprintf(ficrespop,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);
}
for(j=1; j<=nlstate+ndeath;j++) {
kk1=0.;kk2=0;
@@ -2349,12 +2359,13 @@ calagedate=(anproj1+mproj1/12.+jproj1/36
for(i=1; i<=nlstate;i++){
kk1=0.;
for(j=1; j<=nlstate;j++){
- kk1= kk1+Tabpop[(int)(agedeb)][j][cptcod];
+ kk1= kk1+tabpop[(int)(agedeb)][j][cptcod];
}
tabpopprev[(int)(agedeb)][i][cptcod]=tabpop[(int)(agedeb)][i][cptcod]/kk1*popeffectif[(int)(agedeb+(calagedate+12*cpt)*hstepm/YEARM*stepm-1)];
}
-if (h==(int)(calagedate+12*cpt)) for(j=1; j<=nlstate;j++) fprintf(ficrespop," %.3f",tabpopprev[(int)(agedeb+1)][j][cptcod]);
+ if (h==(int)(calagedate+12*cpt)) for(j=1; j<=nlstate;j++)
+ fprintf(ficrespop," %15.2f",tabpopprev[(int)(agedeb+1)][j][cptcod]);
}
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
}
@@ -2362,8 +2373,8 @@ if (h==(int)(calagedate+12*cpt)) for(j=1
/******/
- for (cpt=1; cpt<=4;cpt++) {
- fprintf(ficrespop,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);
+ for (cpt=1; cpt<=(anpyram1-anpyram);cpt++) {
+ fprintf(ficrespop,"\n\n# Forecasting at date %.lf/%.lf/%.lf ",jpyram,mpyram,anpyram+cpt);
for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(agemin-((int)calagedate %12)/12.); agedeb--){
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);
nhstepm = nhstepm/hstepm;
@@ -2373,14 +2384,14 @@ if (h==(int)(calagedate+12*cpt)) for(j=1
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);
for (h=0; h<=nhstepm; h++){
if (h==(int) (calagedate+YEARM*cpt)) {
- fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm);
+ fprintf(ficresf,"\n %3.f ",agedeb+h*hstepm/YEARM*stepm);
}
for(j=1; j<=nlstate+ndeath;j++) {
kk1=0.;kk2=0;
for(i=1; i<=nlstate;i++) {
kk1=kk1+p3mat[i][j][h]*tabpopprev[(int)agedeb+1][i][cptcod];
}
- if (h==(int)(calagedate+12*cpt)) fprintf(ficresf," %.3f", kk1);
+ if (h==(int)(calagedate+12*cpt)) fprintf(ficresf," %15.2f", kk1);
}
}
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
@@ -2410,7 +2421,7 @@ int main(int argc, char *argv[])
int i,j, k, n=MAXN,iter,m,size,cptcode, cptcod;
double agedeb, agefin,hf;
- double agemin=1.e20, agemax=-1.e20;
+ double agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20;
double fret;
double **xi,tmp,delta;
@@ -2423,7 +2434,7 @@ int main(int argc, char *argv[])
char optionfile[FILENAMELENGTH], datafile[FILENAMELENGTH], filerespl[FILENAMELENGTH];
char optionfilext[10], optionfilefiname[FILENAMELENGTH], optionfilehtm[FILENAMELENGTH], optionfilegnuplot[FILENAMELENGTH], plotcmd[FILENAMELENGTH];
- char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH];
+ char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], rfileres[FILENAMELENGTH];
char filerest[FILENAMELENGTH];
char fileregp[FILENAMELENGTH];
@@ -2437,7 +2448,7 @@ int main(int argc, char *argv[])
int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab;
int mobilav=0,popforecast=0;
int hstepm, nhstepm;
- double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2;
+ double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,jpyram, mpyram,anpyram,jpyram1, mpyram1,anpyram1;
double bage, fage, age, agelim, agebase;
double ftolpl=FTOL;
@@ -2455,7 +2466,7 @@ int main(int argc, char *argv[])
double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2;
- char version[80]="Imach version 0.7, February 2002, INED-EUROREVES ";
+ char version[80]="Imach version 0.8, March 2002, INED-EUROREVES ";
char *alph[]={"a","a","b","c","d","e"}, str[4];
@@ -2516,9 +2527,9 @@ int main(int argc, char *argv[])
}
ungetc(c,ficpar);
- fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf 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);
- printf("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(ficparo,"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);
+ fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model);
+ printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model);
+ fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model);
while((c=getc(ficpar))=='#' && c!= EOF){
ungetc(c,ficpar);
fgets(line, MAXLINE, ficpar);
@@ -2623,12 +2634,17 @@ while((c=getc(ficpar))=='#' && c!= EOF){
printf("\n");
- /*-------- data file ----------*/
- if((ficres =fopen(fileres,"w"))==NULL) {
- printf("Problem with resultfile: %s\n", fileres);goto end;
+ /*-------- Rewriting paramater file ----------*/
+ strcpy(rfileres,"r"); /* "Rparameterfile */
+ strcat(rfileres,optionfilefiname); /* Parameter file first name*/
+ strcat(rfileres,"."); /* */
+ strcat(rfileres,optionfilext); /* Other files have txt extension */
+ if((ficres =fopen(rfileres,"w"))==NULL) {
+ printf("Problem writing new parameter file: %s\n", fileres);goto end;
}
fprintf(ficres,"#%s\n",version);
+ /*-------- data file ----------*/
if((fic=fopen(datafile,"r"))==NULL) {
printf("Problem with datafile: %s\n", datafile);goto end;
}
@@ -2670,7 +2686,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){
cutv(stra, strb,line,' '); moisnais[i]=(double)(atoi(strb)); strcpy(line,stra);
cutv(stra, strb,line,' '); weight[i]=(double)(atoi(strb)); strcpy(line,stra);
- for (j=ncov;j>=1;j--){
+ for (j=ncovcol;j>=1;j--){
cutv(stra, strb,line,' '); covar[j][i]=(double)(atoi(strb)); strcpy(line,stra);
}
num[i]=atol(stra);
@@ -2739,7 +2755,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){
}
else {
cutv(strb,stre,strc,'V');
- Tvar[i]=ncov+k1;
+ Tvar[i]=ncovcol+k1;
cutv(strb,strc,strd,'V');
Tprod[k1]=i;
Tvard[k1][1]=atoi(strc);
@@ -2747,7 +2763,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){
Tvar[cptcovn+k2]=Tvard[k1][1];
Tvar[cptcovn+k2+1]=Tvard[k1][2];
for (k=1; k<=lastobs;k++)
- covar[ncov+k1][k]=covar[atoi(stre)][k]*covar[atoi(strc)][k];
+ covar[ncovcol+k1][k]=covar[atoi(stre)][k]*covar[atoi(strc)][k];
k1++;
k2=k2+2;
}
@@ -2901,12 +2917,12 @@ 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,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate, ndeath, maxwav, weightopt,model);
jk=1;
- fprintf(ficres,"# Parameters\n");
- printf("# Parameters\n");
+ fprintf(ficres,"# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n");
+ printf("# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n");
for(i=1,jk=1; i <=nlstate; i++){
for(k=1; k <=(nlstate+ndeath); k++){
if (k != i)
@@ -2928,8 +2944,8 @@ printf("Total number of individuals= %d,
ftolhess=ftol; /* Usually correct */
hesscov(matcov, p, npar, delti, ftolhess, func);
}
- fprintf(ficres,"# Scales\n");
- printf("# Scales\n");
+ fprintf(ficres,"# Scales (for hessian or gradient estimation)\n");
+ printf("# Scales (for hessian or gradient estimation)\n");
for(i=1,jk=1; i <=nlstate; i++){
for(j=1; j <=nlstate+ndeath; j++){
if (j!=i) {
@@ -2947,8 +2963,8 @@ printf("Total number of individuals= %d,
}
k=1;
- fprintf(ficres,"# Covariance\n");
- printf("# Covariance\n");
+ fprintf(ficres,"# Covariance matrix \n# 121 Var(a12)\n# 122 Cov(b12,a12) Var(b12)\n# ...\n# 232 Cov(b23,a12) Cov(b23,b12) ... Var (b23)\n");
+ printf("# Covariance matrix \n# 121 Var(a12)\n# 122 Cov(b12,a12) Var(b12)\n# ...\n# 232 Cov(b23,a12) Cov(b23,b12) ... Var (b23)\n");
for(i=1;i<=npar;i++){
/* if (k>nlstate) k=1;
i1=(i-1)/(ncovmodel*nlstate)+1;
@@ -2973,16 +2989,16 @@ printf("Total number of individuals= %d,
}
ungetc(c,ficpar);
- fscanf(ficpar,"agemin=%lf agemax=%lf bage=%lf fage=%lf\n",&agemin,&agemax, &bage, &fage);
+ fscanf(ficpar,"agemin=%lf agemax=%lf bage=%lf fage=%lf\n",&agemin,&agemaxpar, &bage, &fage);
if (fage <= 2) {
bage = agemin;
- fage = agemax;
+ fage = agemaxpar;
}
fprintf(ficres,"# agemin agemax for life expectancy, bage fage (if mle==0 ie no data nor Max likelihood).\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);
+ fprintf(ficres,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemaxpar,bage,fage);
+ fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemaxpar,bage,fage);
while((c=getc(ficpar))=='#' && c!= EOF){
ungetc(c,ficpar);
@@ -3009,9 +3025,9 @@ printf("Total number of individuals= %d,
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);
-
+ 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);
@@ -3019,14 +3035,28 @@ printf("Total number of individuals= %d,
fputs(line,ficparo);
}
ungetc(c,ficpar);
- fscanf(ficpar,"popforecast=%d popfile=%s starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mov_average=%d\n",&popforecast,popfile,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilav);
-fprintf(ficparo,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mov_average=%d\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilav);
-fprintf(ficres,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mov_average=%d\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilav);
+
+ fscanf(ficpar,"starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mov_average=%d\n",&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilav);
+fprintf(ficparo,"starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mov_average=%d\n",jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilav);
+fprintf(ficres,"starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mov_average=%d\n",jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,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 popfiledate=%lf/%lf/%lf last-popfiledate=%lf/%lf/%lf\n",&popforecast,popfile,&jpyram,&mpyram,&anpyram,&jpyram1,&mpyram1,&anpyram1);
+ fprintf(ficparo,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);
+ fprintf(ficres,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1);
freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);
/*------------ gnuplot -------------*/
- printinggnuplot(fileres,optionfilefiname,optionfile,optionfilegnuplot, agemin,agemax,fage, pathc,p);
+ printinggnuplot(fileres,optionfilefiname,optionfile,optionfilegnuplot, agemin,agemaxpar,fage, pathc,p);
/*------------ free_vector -------------*/
chdir(path);
@@ -3039,22 +3069,10 @@ fprintf(ficres,"popforecast=%d popfile=%
/*free_matrix(covar,1,NCOVMAX,1,n);*/
fclose(ficparo);
fclose(ficres);
-
- /* Reads comments: lines beginning with '#' */
- while((c=getc(ficpar))=='#' && c!= EOF){
- ungetc(c,ficpar);
- fgets(line, MAXLINE, ficpar);
- puts(line);
- fputs(line,ficparo);
- }
- ungetc(c,ficpar);
-
- fscanf(ficpar,"agemin=%lf agemax=%lf bage=%lf fage=%lf\n",&agemin,&agemax, &bage, &fage);
- printf("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);
+
/*--------- index.htm --------*/
- printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm);
+ printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm,rfileres);
/*--------------- Prevalence limit --------------*/
@@ -3078,7 +3096,7 @@ fprintf(ficres,"popforecast=%d popfile=%
oldm=oldms; newm=newms; savm=savms; /* Keeps fixed addresses to free */
k=0;
agebase=agemin;
- agelim=agemax;
+ agelim=agemaxpar;
ftolpl=1.e-10;
i1=cptcoveff;
if (cptcovn < 1){i1=1;}
@@ -3157,15 +3175,15 @@ fprintf(ficres,"popforecast=%d popfile=%
/*---------- Forecasting ------------------*/
- if(stepm == 1) {
+ if((stepm == 1) && (strcmp(model,".")==0)){
prevforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anproj2,p, i1);
-populforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anproj2,p, i1);
+ if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);
free_matrix(mint,1,maxwav,1,n);
free_matrix(anint,1,maxwav,1,n); free_imatrix(s,1,maxwav+1,1,n);
free_vector(weight,1,n);}
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);
+ printf("Warning %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model);
}
@@ -3225,8 +3243,6 @@ populforecast(fileres, anproj1,mproj1,jp
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i);
fprintf(ficrest,"\n");
- hf=1;
- if (stepm >= YEARM) hf=stepm/YEARM;
epj=vector(1,nlstate+1);
for(age=bage; age <=fage ;age++){
prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k);
@@ -3235,19 +3251,19 @@ populforecast(fileres, anproj1,mproj1,jp
prlim[i][i]=probs[(int)age][i][k];
}
- fprintf(ficrest," %.0f",age);
+ fprintf(ficrest," %4.0f",age);
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){
for(i=1, epj[j]=0.;i <=nlstate;i++) {
- epj[j] += prlim[i][i]*hf*eij[i][j][(int)age];
+ epj[j] += prlim[i][i]*eij[i][j][(int)age];
}
epj[nlstate+1] +=epj[j];
}
for(i=1, vepp=0.;i <=nlstate;i++)
for(j=1;j <=nlstate;j++)
vepp += vareij[i][j][(int)age];
- fprintf(ficrest," %.2f (%.2f)", epj[nlstate+1],hf*sqrt(vepp));
+ fprintf(ficrest," %7.2f (%7.2f)", epj[nlstate+1],sqrt(vepp));
for(j=1;j <=nlstate;j++){
- fprintf(ficrest," %.2f (%.2f)", epj[j],hf*sqrt(vareij[j][j][(int)age]));
+ fprintf(ficrest," %7.2f (%7.2f)", epj[j],sqrt(vareij[j][j][(int)age]));
}
fprintf(ficrest,"\n");
}
@@ -3305,7 +3321,7 @@ populforecast(fileres, anproj1,mproj1,jp
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel);
if(erreur >0)
- printf("End of Imach with error %d\n",erreur);
+ printf("End of Imach with error or warning %d\n",erreur);
else printf("End of Imach\n");
/* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */