int *num, firstpass=0, lastpass=4,*cod, *ncodemax, *Tage;\r
double **agev,*moisnais, *annais, *moisdc, *andc,**mint, **anint;\r
double **pmmij, ***probs, ***mobaverage;\r
+double dateintmean=0;\r
\r
double *weight;\r
int **s; /* Status */\r
} \r
\r
/************ Frequencies ********************/\r
-void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax, int fprev1,int lprev1,double **mint,double **anint, int boolprev, double dateprev1,double dateprev2)\r
+void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2)\r
{ /* Some frequencies */\r
\r
int i, m, jk, k1,i1, j1, bool, z1,z2,j;\r
double ***freq; /* Frequencies */\r
double *pp;\r
- double pos, k2;\r
+ double pos, k2, dateintsum=0,k2cpt=0;\r
FILE *ficresp;\r
char fileresp[FILENAMELENGTH];\r
\r
pp=vector(1,nlstate);\r
- probs= ma3x(1,130 ,1,8, 1,8);\r
+ probs= ma3x(1,AGESUP,1,NCOVMAX, 1,NCOVMAX);\r
strcpy(fileresp,"p");\r
strcat(fileresp,fileres);\r
if((ficresp=fopen(fileresp,"w"))==NULL) {\r
for (jk=-1; jk<=nlstate+ndeath; jk++) \r
for(m=agemin; m <= agemax+3; m++)\r
freq[i][jk][m]=0;\r
- \r
+\r
+ dateintsum=0;\r
+ k2cpt=0;\r
for (i=1; i<=imx; i++) {\r
bool=1;\r
if (cptcovn>0) {\r
bool=0;\r
}\r
if (bool==1) {\r
- if (boolprev==1){\r
- for(m=fprev1; m<=lprev1; m++){\r
+ for(m=firstpass; m<=lastpass; m++){\r
+ k2=anint[m][i]+(mint[m][i]/12.);\r
+ 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]] += weight[i];\r
freq[s[m][i]][s[m+1][i]][(int) agemax+3] += weight[i];\r
+ if ((agev[m][i]>1) && (agev[m][i]< (agemax+3))) {\r
+ dateintsum=dateintsum+k2;\r
+ k2cpt++;\r
+ }\r
+\r
}\r
}\r
- else {\r
- for(m=firstpass; m<=lastpass; m++){\r
- k2=anint[m][i]+(mint[m][i]/12.);\r
- 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]] += weight[i];\r
- freq[s[m][i]][s[m+1][i]][(int) agemax+3] += weight[i];\r
- }\r
- }\r
- }\r
- }\r
+ }\r
}\r
if (cptcovn>0) {\r
fprintf(ficresp, "\n#********** Variable "); \r
}\r
}\r
}\r
+ dateintmean=dateintsum/k2cpt; \r
\r
fclose(ficresp);\r
free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3);\r
free_vector(pp,1,nlstate);\r
\r
-} /* End of Freq */\r
+ /* End of Freq */\r
+}\r
\r
/************ Prevalence ********************/\r
-void prevalence(int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax, int fprev1,int lprev1, double **mint,double **anint,int boolprev, double dateprev1, double dateprev2)\r
+void prevalence(int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2, double calagedate)\r
{ /* Some frequencies */\r
\r
int i, m, jk, k1, i1, j1, bool, z1,z2,j;\r
double pos, k2;\r
\r
pp=vector(1,nlstate);\r
- probs= ma3x(1,130 ,1,8, 1,8);\r
+ probs= ma3x(1,AGESUP,1,NCOVMAX, 1,NCOVMAX);\r
\r
freq=ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3);\r
j1=0;\r
for (i=-1; i<=nlstate+ndeath; i++) \r
for (jk=-1; jk<=nlstate+ndeath; jk++) \r
for(m=agemin; m <= agemax+3; m++)\r
- freq[i][jk][m]=0;\r
+ freq[i][jk][m]=0;\r
\r
for (i=1; i<=imx; i++) {\r
bool=1;\r
for (z1=1; z1<=cptcoveff; z1++) \r
if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtab[j1][z1]]) \r
bool=0;\r
- }\r
- if (bool==1) {\r
- if (boolprev==1){\r
- for(m=fprev1; m<=lprev1; m++){\r
+ }\r
+ if (bool==1) { \r
+ for(m=firstpass; m<=lastpass; m++){\r
+ k2=anint[m][i]+(mint[m][i]/12.);\r
+ 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]] += weight[i];\r
- freq[s[m][i]][s[m+1][i]][(int) agemax+3] += weight[i];\r
- }\r
- }\r
- else {\r
- for(m=firstpass; m<=lastpass; m++){\r
- k2=anint[m][i]+(mint[m][i]/12.);\r
- 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]] += weight[i];\r
- freq[s[m][i]][s[m+1][i]][(int) agemax+3] += weight[i];\r
- }\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)(agemax+3+1)] += weight[i]; \r
}\r
}\r
}\r
}\r
+ \r
for(i=(int)agemin; i <= (int)agemax+3; i++){ \r
for(jk=1; jk <=nlstate ; jk++){\r
for(m=-1, pp[jk]=0; m <=nlstate+ndeath ; m++)\r
free_vector(pp,1,nlstate);\r
\r
} /* End of Freq */\r
+\r
/************* Waves Concatenation ***************/\r
\r
void concatwav(int wav[], int **dh, int **mw, int **s, double *agedc, double **agev, int firstpass, int lastpass, int imx, int nlstate, int stepm)\r
int ju,jl, mi;\r
int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij;\r
int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; \r
- int mobilav=0, fprev, lprev ,fprevfore=1, lprevfore=1,nforecast,popforecast=0;\r
+ int mobilav=0,popforecast=0;\r
int hstepm, nhstepm;\r
- int *popage,boolprev=0;/*boolprev=0 if date and zero if wave*/\r
+ int *popage;/*boolprev=0 if date and zero if wave*/\r
+ double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2;\r
\r
double bage, fage, age, agelim, agebase;\r
double ftolpl=FTOL;\r
double *epj, vepp;\r
double kk1, kk2;\r
double *popeffectif,*popcount;\r
- double dateprev1, dateprev2;\r
+ double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,jprojmean,mprojmean,anprojmean, calagedate;\r
+ double yp,yp1,yp2;\r
\r
char version[80]="Imach version 64b, May 2001, INED-EUROREVES ";\r
char *alph[]={"a","a","b","c","d","e"}, str[4];\r
#include <sys/time.h>\r
#include <time.h>\r
char stra[80], strb[80], strc[80], strd[80],stre[80],modelsav[80];\r
- char strfprev[10], strlprev[10];\r
- char strfprevfore[10], strlprevfore[10];\r
+ \r
/* long total_usecs;\r
struct timeval start_time, end_time;\r
\r
}\r
ungetc(c,ficpar);\r
\r
- fscanf(ficpar,"fprevalence=%s lprevalence=%s pop_based=%d\n",strfprev,strlprev,&popbased);\r
- fprintf(ficparo,"fprevalence=%s lprevalence=%s pop_based=%d\n",strfprev,strlprev,popbased);\r
- \r
- /* printf("%s %s",strfprev,strlprev);\r
- exit(0);*/\r
- while((c=getc(ficpar))=='#' && c!= EOF){\r
- ungetc(c,ficpar);\r
- fgets(line, MAXLINE, ficpar);\r
- puts(line);\r
- fputs(line,ficparo);\r
- }\r
- ungetc(c,ficpar);\r
- \r
- fscanf(ficpar,"fprevalence=%s lprevalence=%s nforecast=%d mob_average=%d\n",strfprevfore,strlprevfore,&nforecast,&mobilav);\r
- fprintf(ficparo,"fprevalence=%s lprevalence=%s nforecast=%d mob_average=%d\n",strfprevfore,strlprevfore,nforecast,mobilav);\r
- \r
- \r
-while((c=getc(ficpar))=='#' && c!= EOF){\r
- ungetc(c,ficpar);\r
- fgets(line, MAXLINE, ficpar);\r
- puts(line);\r
- fputs(line,ficparo);\r
- }\r
- ungetc(c,ficpar);\r
- \r
- fscanf(ficpar,"popforecast=%d popfile=%s\n",&popforecast,popfile);\r
- \r
+ \r
covar=matrix(0,NCOVMAX,1,n); \r
cptcovn=0; \r
if (strlen(model)>1) cptcovn=nbocc(model,'+')+1;\r
if ((s[2][i]==3) && (s[3][i]==2)) s[3][i]=3;\r
if ((s[3][i]==3) && (s[4][i]==2)) s[4][i]=3;\r
}\r
- for (i=1; i<=imx; i++) printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/\r
+\r
+ for (i=1; i<=imx; i++)\r
+ if (covar[1][i]==0) printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/\r
\r
/* Calculation of the number of parameter from char model*/\r
Tvar=ivector(1,15); \r
/* Calculates basic frequencies. Computes observed prevalence at single age\r
and prints on file fileres'p'. */\r
\r
- if ((nbocc(strfprev,'/')==1) && (nbocc(strlprev,'/')==1)){\r
- boolprev=0;\r
- cutv(stra,strb,strfprev,'/');\r
- dateprev1=(double)(atoi(strb)+atoi(stra)/12.);\r
- cutv(stra,strb,strlprev,'/');\r
- dateprev2=(double)(atoi(strb)+atoi(stra)/12.);\r
- }\r
- \r
- else if ((nbocc(strfprev,'/')==0) &&(nbocc(strlprev,'/')==0)){\r
- boolprev=1;\r
- fprev=atoi(strfprev); lprev=atoi(strlprev);\r
- }\r
- else {\r
- printf("Error in statement lprevalence or fprevalence\n");\r
- goto end;\r
- }\r
+ \r
\r
- freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax, fprev, lprev,mint,anint,boolprev,dateprev1,dateprev2); \r
- \r
- pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
+ pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
savms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
\r
/*--------- results files --------------*/\r
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);\r
- fprintf(ficres,"fprevalence=%s lprevalence=%s pop_based=%d\n",strfprev,strlprev,popbased); \r
- fprintf(ficres,"fprevalence=%s lprevalence=%s nforecast=%d mob_average=%d\n",strfprevfore,strlprevfore,nforecast,mobilav);\r
+ \r
\r
jk=1;\r
fprintf(ficres,"# Parameters\n");\r
fage = agemax;\r
}\r
\r
- fprintf(ficres,"# agemin agemax for life expectancy, bage fage (if mle==0 ie no data nor Max likelihood).\n");\r
+ fprintf(ficres,"# agemin agemax for life expectancy.\n");\r
+\r
fprintf(ficres,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax,bage,fage);\r
+ fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax,bage,fage);\r
+ \r
+ while((c=getc(ficpar))=='#' && c!= EOF){\r
+ ungetc(c,ficpar);\r
+ fgets(line, MAXLINE, ficpar);\r
+ puts(line);\r
+ fputs(line,ficparo);\r
+ }\r
+ ungetc(c,ficpar);\r
+ \r
+ fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mob_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav);\r
+ fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mob_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);\r
+ fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mob_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav);\r
+ \r
+ while((c=getc(ficpar))=='#' && c!= EOF){\r
+ ungetc(c,ficpar);\r
+ fgets(line, MAXLINE, ficpar);\r
+ puts(line);\r
+ fputs(line,ficparo);\r
+ }\r
+ ungetc(c,ficpar);\r
+ \r
\r
- \r
-/*------------ gnuplot -------------*/\r
+ dateprev1=anprev1+mprev1/12.+jprev1/365.;\r
+ dateprev2=anprev2+mprev2/12.+jprev2/365.;\r
+\r
+ fscanf(ficpar,"pop_based=%d\n",&popbased);\r
+ fprintf(ficparo,"pop_based=%d\n",popbased); \r
+ fprintf(ficres,"pop_based=%d\n",popbased); \r
+\r
+ while((c=getc(ficpar))=='#' && c!= EOF){\r
+ ungetc(c,ficpar);\r
+ fgets(line, MAXLINE, ficpar);\r
+ puts(line);\r
+ fputs(line,ficparo);\r
+ }\r
+ ungetc(c,ficpar);\r
+ fscanf(ficpar,"popforecast=%d popfile=%s starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf\n",&popforecast,popfile,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2);\r
+fprintf(ficparo,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2);\r
+fprintf(ficres,"popforecast=%d popfile=%s starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf\n",popforecast,popfile,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2);\r
+\r
+ freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2);\r
+\r
+ /*------------ gnuplot -------------*/\r
chdir(pathcd);\r
if((ficgp=fopen("graph.plt","w"))==NULL) {\r
printf("Problem with file graph.gp");goto end;\r
fclose(ficrespij);\r
\r
/*---------- Forecasting ------------------*/\r
+ calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;\r
+\r
+ prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);\r
+\r
\r
strcpy(fileresf,"f"); \r
strcat(fileresf,fileres);\r
}\r
printf("Computing forecasting: result on file '%s' \n", fileresf);\r
\r
- if ((nbocc(strfprevfore,'/')==1) && (nbocc(strlprevfore,'/')==1)){\r
- boolprev=0;\r
- cutv(stra,strb,strfprevfore,'/');\r
- dateprev1=(double)(atoi(strb)+atoi(stra)/12.);\r
- cutv(stra,strb,strlprevfore,'/');\r
- dateprev2=(double)(atoi(strb)+atoi(stra)/12.);\r
- }\r
- \r
- else if ((nbocc(strfprevfore,'/')==0) &&(nbocc(strlprevfore,'/')==0)){\r
- boolprev=1;\r
- fprev=atoi(strfprevfore); lprev=atoi(strlprevfore);\r
- }\r
- else {\r
- printf("Error in statement lprevalence or fprevalence\n");\r
- goto end;\r
- }\r
-\r
- prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax, fprevfore, lprevfore,mint,anint,boolprev,dateprev1,dateprev2);\r
- \r
free_matrix(mint,1,maxwav,1,n);\r
free_matrix(anint,1,maxwav,1,n);\r
free_matrix(agev,1,maxwav,1,imx);\r
if (stepm<=12) stepsize=1;\r
\r
agelim=AGESUP;\r
- hstepm=stepsize*YEARM; /* Every year of age */\r
+ /*hstepm=stepsize*YEARM; *//* Every year of age */\r
+ hstepm=1;\r
hstepm=hstepm/stepm; /* Typically 2 years, = 2 years/6 months = 4 */ \r
- \r
+ yp1=modf(dateintmean,&yp);\r
+ anprojmean=yp;\r
+ yp2=modf((yp1*12),&yp);\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
+\r
if (popforecast==1) {\r
if((ficpop=fopen(popfile,"r"))==NULL) {\r
printf("Problem with population file : %s\n",popfile);goto end;\r
i=i+1;\r
}\r
imx=i;\r
- \r
- for (i=1; i<imx;i++) popeffectif[popage[i]]=popcount[i];\r
+ \r
+ for (i=1; i<imx;i++) popeffectif[popage[i]]=popcount[i];\r
}\r
\r
for(cptcov=1;cptcov<=i1;cptcov++){\r
for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){\r
k=k+1;\r
- fprintf(ficresf,"\n#****** ");\r
+ fprintf(ficresf,"\n#******");\r
for(j=1;j<=cptcoveff;j++) {\r
- fprintf(ficresf,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);\r
+ fprintf(ficresf," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);\r
}\r
fprintf(ficresf,"******\n");\r
- fprintf(ficresf,"# StartingAge FinalAge Horizon(in years)");\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 (agedeb=fage; agedeb>=bage; agedeb--){ \r
- fprintf(ficresf,"\n%.f %.f 0",agedeb, agedeb);\r
- if (mobilav==1) {\r
- for(j=1; j<=nlstate;j++) \r
- fprintf(ficresf," %.3f",mobaverage[(int)agedeb][j][cptcod]);\r
- }\r
- else {\r
- for(j=1; j<=nlstate;j++) \r
- fprintf(ficresf," %.3f",probs[(int)agedeb][j][cptcod]);\r
- } \r
-\r
- for(j=1; j<=ndeath;j++) fprintf(ficresf," 0.00000");\r
- if (popforecast==1) fprintf(ficresf," [%.f] ",popeffectif[(int)agedeb]);\r
- }\r
- \r
- for (cpt=1; cpt<=nforecast;cpt++) { \r
+ \r
+ for (cpt=0; cpt<=1;cpt++) { \r
fprintf(ficresf,"\n");\r
- for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */\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
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
- \r
- if (h*hstepm/YEARM*stepm==cpt)\r
- fprintf(ficresf,"\n%.f %.f %.f",agedeb, agedeb+ h*hstepm/YEARM*stepm, 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
- if (mobilav==1) \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
+ }\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
- else kk1=kk1+p3mat[i][j][h]*probs[(int)agedeb][i][cptcod];\r
- if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];\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
+ }\r
+\r
+ if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];\r
+ }\r
+ \r
+ if (h==(int)(calagedate+12*cpt)){\r
+ fprintf(ficresf," %.3f", kk1);\r
+ \r
+ if (popforecast==1) fprintf(ficresf," [%.f]", kk2);\r
}\r
- if (h*hstepm/YEARM*stepm==cpt) {\r
- fprintf(ficresf," %.3f", kk1);\r
- if (popforecast==1) fprintf(ficresf," [%.f]", kk2);\r
- }\r
}\r
}\r
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
- \r
}\r
}\r
}\r