version 1.19, 2002/02/20 17:19:10
|
version 1.21, 2002/02/21 18:42:24
|
Line 67
|
Line 67
|
#define AGEBASE 40
|
#define AGEBASE 40
|
|
|
|
|
|
int erreur; /* Error number */
|
int nvar;
|
int nvar;
|
int cptcovn, cptcovage=0, cptcoveff=0,cptcov;
|
int cptcovn, cptcovage=0, cptcoveff=0,cptcov;
|
int npar=NPARMAX;
|
int npar=NPARMAX;
|
Line 901 void mlikeli(FILE *ficres,double p[], in
|
Line 902 void mlikeli(FILE *ficres,double p[], in
|
powell(p,xi,npar,ftol,&iter,&fret,func);
|
powell(p,xi,npar,ftol,&iter,&fret,func);
|
|
|
printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p));
|
printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p));
|
fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f ",iter,func(p));
|
fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p));
|
|
|
}
|
}
|
|
|
Line 1318 void prevalence(int agemin, int agemax,
|
Line 1319 void prevalence(int agemin, int agemax,
|
if ((k2>=dateprev1) && (k2<=dateprev2)) {
|
if ((k2>=dateprev1) && (k2<=dateprev2)) {
|
if(agev[m][i]==0) agev[m][i]=agemax+1;
|
if(agev[m][i]==0) agev[m][i]=agemax+1;
|
if(agev[m][i]==1) agev[m][i]=agemax+2;
|
if(agev[m][i]==1) agev[m][i]=agemax+2;
|
freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-1/12.)] += weight[i];
|
freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-((int)calagedate %12)/12.)] += weight[i];
|
freq[s[m][i]][s[m+1][i]][(int)(agemax+3+1)] += weight[i];
|
freq[s[m][i]][s[m+1][i]][(int)(agemax+3+1)] += weight[i];
|
}
|
}
|
}
|
}
|
Line 2632 ij=1;
|
Line 2633 ij=1;
|
}
|
}
|
|
|
fclose(ficgp);
|
fclose(ficgp);
|
|
/* end gnuplot */
|
|
|
chdir(path);
|
chdir(path);
|
|
|
Line 2824 fclose(fichtm);
|
Line 2826 fclose(fichtm);
|
|
|
fclose(ficrespij);
|
fclose(ficrespij);
|
|
|
|
if(stepm == 1) {
|
/*---------- Forecasting ------------------*/
|
/*---------- Forecasting ------------------*/
|
calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;
|
calagedate=(anproj1+mproj1/12.+jproj1/365.-dateintmean)*YEARM;
|
|
|
|
/*printf("calage= %f", calagedate);*/
|
|
|
prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);
|
prevalence(agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax,mint,anint,dateprev1,dateprev2, calagedate);
|
|
|
|
|
Line 2876 fclose(fichtm);
|
Line 2881 fclose(fichtm);
|
mprojmean=yp;
|
mprojmean=yp;
|
yp1=modf((yp2*30.5),&yp);
|
yp1=modf((yp2*30.5),&yp);
|
jprojmean=yp;
|
jprojmean=yp;
|
fprintf(ficresf,"Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean);
|
if(jprojmean==0) jprojmean=1;
|
|
if(mprojmean==0) jprojmean=1;
|
|
|
|
fprintf(ficresf,"# Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean);
|
|
|
if (popforecast==1) {
|
if (popforecast==1) {
|
if((ficpop=fopen(popfile,"r"))==NULL) {
|
if((ficpop=fopen(popfile,"r"))==NULL) {
|
Line 2907 fclose(fichtm);
|
Line 2915 fclose(fichtm);
|
fprintf(ficresf,"# StartingAge FinalAge");
|
fprintf(ficresf,"# StartingAge FinalAge");
|
for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j);
|
for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j);
|
if (popforecast==1) fprintf(ficresf," [Population]");
|
if (popforecast==1) fprintf(ficresf," [Population]");
|
|
|
for (cpt=0; cpt<=1;cpt++) {
|
for (cpt=0; cpt<4;cpt++) {
|
fprintf(ficresf,"\n");
|
fprintf(ficresf,"\n");
|
fprintf(ficresf,"\nForecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);
|
fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt);
|
for (agedeb=(fage-(1/12.)); agedeb>=(bage-(1/12.)); agedeb--){ /* If stepm=6 months */
|
|
|
for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(bage-((int)calagedate %12)/12.); agedeb--){ /* If stepm=6 months */
|
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);
|
nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm);
|
nhstepm = nhstepm/hstepm;
|
nhstepm = nhstepm/hstepm;
|
/*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/
|
/*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/
|
Line 2919 fclose(fichtm);
|
Line 2928 fclose(fichtm);
|
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
|
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
|
oldm=oldms;savm=savms;
|
oldm=oldms;savm=savms;
|
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);
|
hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);
|
|
|
for (h=0; h<=nhstepm; h++){
|
for (h=0; h<=nhstepm; h++){
|
if (h==(int) (calagedate+12*cpt)) {
|
if (h==(int) (calagedate+YEARM*cpt)) {
|
fprintf(ficresf,"h=%d ", h);
|
fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm);
|
fprintf(ficresf,"\n %f %f ",agedeb,agedeb+h*hstepm/YEARM*stepm);
|
}
|
}
|
|
for(j=1; j<=nlstate+ndeath;j++) {
|
for(j=1; j<=nlstate+ndeath;j++) {
|
kk1=0.;kk2=0;
|
kk1=0.;kk2=0;
|
for(i=1; i<=nlstate;i++) {
|
for(i=1; i<=nlstate;i++) {
|
if (mobilav==1)
|
if (mobilav==1)
|
kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod];
|
kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb+1][i][cptcod];
|
else {
|
else {
|
kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod];
|
kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod];
|
/* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h],probs[(int)(agedeb)+1][i][cptcod]);*/
|
/* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h], probs[(int)(agedeb)+1][i][cptcod]);*/
|
}
|
}
|
|
|
if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];
|
if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];
|
Line 2959 fclose(fichtm);
|
Line 2967 fclose(fichtm);
|
free_imatrix(s,1,maxwav+1,1,n);
|
free_imatrix(s,1,maxwav+1,1,n);
|
free_vector(weight,1,n);
|
free_vector(weight,1,n);
|
fclose(ficresf);
|
fclose(ficresf);
|
|
}/* End forecasting */
|
|
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);
|
|
}
|
|
|
/*---------- Health expectancies and variances ------------*/
|
/*---------- Health expectancies and variances ------------*/
|
|
|
strcpy(filerest,"t");
|
strcpy(filerest,"t");
|
Line 3096 strcpy(fileresvpl,"vpl");
|
Line 3110 strcpy(fileresvpl,"vpl");
|
|
|
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel);
|
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel);
|
|
|
printf("End of Imach\n");
|
if(erreur >0)
|
|
printf("End of Imach with error %d\n",erreur);
|
|
else printf("End of Imach\n");
|
/* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */
|
/* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */
|
|
|
/* printf("Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec);*/
|
/* printf("Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec);*/
|