version 1.192, 2015/07/16 16:49:02
|
version 1.194, 2015/08/18 13:32:00
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.194 2015/08/18 13:32:00 brouard |
|
Summary: Adding error when the covariance matrix doesn't contain the exact number of lines required by the model line. |
|
|
|
Revision 1.193 2015/08/04 07:17:42 brouard |
|
Summary: 0.98q4 |
|
|
Revision 1.192 2015/07/16 16:49:02 brouard |
Revision 1.192 2015/07/16 16:49:02 brouard |
Summary: Fixing some outputs |
Summary: Fixing some outputs |
|
|
Line 682 typedef struct {
|
Line 688 typedef struct {
|
#define YEARM 12. /**< Number of months per year */ |
#define YEARM 12. /**< Number of months per year */ |
#define AGESUP 130 |
#define AGESUP 130 |
#define AGEBASE 40 |
#define AGEBASE 40 |
|
#define AGEOVERFLOW 1.e20 |
#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */ |
#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */ |
#ifdef _WIN32 |
#ifdef _WIN32 |
#define DIRSEPARATOR '\\' |
#define DIRSEPARATOR '\\' |
Line 696 typedef struct {
|
Line 703 typedef struct {
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98q3, July 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; |
char version[]="Imach version 0.98q5, August 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
char strstart[80]; |
char strstart[80]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
Line 4536 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 4543 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
}/* End k1 */ |
}/* End k1 */ |
fprintf(fichtm,"</ul>"); |
fprintf(fichtm,"</ul>"); |
|
|
|
|
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n", rfileres,rfileres); |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br> \ |
|
- 95%% confidence intervals and T statistics are in the log file.<br>\n", rfileres,rfileres); |
|
|
fprintf(fichtm," - Variance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
fprintf(fichtm," - Standard deviation of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"prob"),subdirf2(fileres,"prob")); |
subdirf2(fileres,"prob"),subdirf2(fileres,"prob")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Variance-covariance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
- Variance-covariance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
Line 6269 int main(int argc, char *argv[])
|
Line 6276 int main(int argc, char *argv[])
|
/* FILE *ficgp;*/ /*Gnuplot File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
struct stat info; |
struct stat info; |
double agedeb=0.; |
double agedeb=0.; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
|
|
double ageminpar=AGEOVERFLOW,agemin=AGEOVERFLOW, agemaxpar=-AGEOVERFLOW, agemax=-AGEOVERFLOW; |
|
|
double fret; |
double fret; |
double dum=0.; /* Dummy variable */ |
double dum=0.; /* Dummy variable */ |
Line 6284 int main(int argc, char *argv[])
|
Line 6292 int main(int argc, char *argv[])
|
int c, h , cpt; |
int c, h , cpt; |
int jl=0; |
int jl=0; |
int i1, j1, jk, stepsize=0; |
int i1, j1, jk, stepsize=0; |
|
int count=0; |
|
|
int *tab; |
int *tab; |
int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */ |
int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */ |
int mobilav=0,popforecast=0; |
int mobilav=0,popforecast=0; |
Line 6474 int main(int argc, char *argv[])
|
Line 6484 int main(int argc, char *argv[])
|
ungetc(c,ficpar); |
ungetc(c,ficpar); |
|
|
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 model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &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 model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model); |
numlinepar++; |
numlinepar=numlinepar+3; /* In general */ |
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=1+age+%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=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
model[strlen(model)-1]='\0'; |
model[strlen(model)-1]='\0'; |
Line 6561 int main(int argc, char *argv[])
|
Line 6571 int main(int argc, char *argv[])
|
if(jj==i) continue; |
if(jj==i) continue; |
j++; |
j++; |
fscanf(ficpar,"%1d%1d",&i1,&j1); |
fscanf(ficpar,"%1d%1d",&i1,&j1); |
if ((i1 != i) && (j1 != j)){ |
if ((i1 != i) || (j1 != jj)){ |
printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \ |
printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \ |
It might be a problem of design; if ncovcol and the model are correct\n \ |
It might be a problem of design; if ncovcol and the model are correct\n \ |
run imach with mle=-1 to get a correct template of the parameter file.\n",numlinepar, i,j, i1, j1); |
run imach with mle=-1 to get a correct template of the parameter file.\n",numlinepar, i,j, i1, j1); |
Line 6569 run imach with mle=-1 to get a correct t
|
Line 6579 run imach with mle=-1 to get a correct t
|
} |
} |
fprintf(ficparo,"%1d%1d",i1,j1); |
fprintf(ficparo,"%1d%1d",i1,j1); |
if(mle==1) |
if(mle==1) |
printf("%1d%1d",i,j); |
printf("%1d%1d",i,jj); |
fprintf(ficlog,"%1d%1d",i,j); |
fprintf(ficlog,"%1d%1d",i,jj); |
for(k=1; k<=ncovmodel;k++){ |
for(k=1; k<=ncovmodel;k++){ |
fscanf(ficpar," %lf",¶m[i][j][k]); |
fscanf(ficpar," %lf",¶m[i][j][k]); |
if(mle==1){ |
if(mle==1){ |
Line 6651 run imach with mle=-1 to get a correct t
|
Line 6661 run imach with mle=-1 to get a correct t
|
for(i=1; i <=npar; i++) |
for(i=1; i <=npar; i++) |
for(j=1; j <=npar; j++) matcov[i][j]=0.; |
for(j=1; j <=npar; j++) matcov[i][j]=0.; |
|
|
|
/* Scans npar lines */ |
for(i=1; i <=npar; i++){ |
for(i=1; i <=npar; i++){ |
fscanf(ficpar,"%s",str); |
count=fscanf(ficpar,"%1d%1d%1d",&i1,&j1,&jk); |
|
if(count != 3){ |
|
printf("Error! Error in parameter file %s at line %d after line starting with %1d%1d%1d\n\ |
|
This is probably because your covariance matrix doesn't \n contain exactly %d lines corresponding to your model line '1+age+%s'.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",optionfile,numlinepar, i1,j1,jk, npar, model); |
|
fprintf(ficlog,"Error! Error in parameter file %s at line %d after line starting with %1d%1d%1d\n\ |
|
This is probably because your covariance matrix doesn't \n contain exactly %d lines corresponding to your model line '1+age+%s'.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",optionfile,numlinepar, i1,j1,jk, npar, model); |
|
exit(1); |
|
}else |
if(mle==1) |
if(mle==1) |
printf("%s",str); |
printf("%1d%1d%1d",i1,j1,jk); |
fprintf(ficlog,"%s",str); |
fprintf(ficlog,"%1d%1d%1d",i1,j1,jk); |
fprintf(ficparo,"%s",str); |
fprintf(ficparo,"%1d%1d%1d",i1,j1,jk); |
for(j=1; j <=i; j++){ |
for(j=1; j <=i; j++){ |
fscanf(ficpar," %le",&matcov[i][j]); |
fscanf(ficpar," %le",&matcov[i][j]); |
if(mle==1){ |
if(mle==1){ |
Line 6672 run imach with mle=-1 to get a correct t
|
Line 6692 run imach with mle=-1 to get a correct t
|
fprintf(ficlog,"\n"); |
fprintf(ficlog,"\n"); |
fprintf(ficparo,"\n"); |
fprintf(ficparo,"\n"); |
} |
} |
|
/* End of read covariance matrix npar lines */ |
for(i=1; i <=npar; i++) |
for(i=1; i <=npar; i++) |
for(j=i+1;j<=npar;j++) |
for(j=i+1;j<=npar;j++) |
matcov[i][j]=matcov[j][i]; |
matcov[i][j]=matcov[j][i]; |
Line 7111 Interval (in months) between two waves:
|
Line 7132 Interval (in months) between two waves:
|
} |
} |
|
|
printf("iter=%d MLE=%f Eq=%lf*exp(%lf*(age-%d))\n",iter,-gompertz(p),p[1],p[2],agegomp); |
printf("iter=%d MLE=%f Eq=%lf*exp(%lf*(age-%d))\n",iter,-gompertz(p),p[1],p[2],agegomp); |
for (i=1;i<=NDIM;i++) |
for (i=1;i<=NDIM;i++) { |
printf("%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
printf("%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
|
fprintf(ficlog,"%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
|
} |
lsurv=vector(1,AGESUP); |
lsurv=vector(1,AGESUP); |
lpop=vector(1,AGESUP); |
lpop=vector(1,AGESUP); |
tpop=vector(1,AGESUP); |
tpop=vector(1,AGESUP); |
Line 7145 Interval (in months) between two waves:
|
Line 7167 Interval (in months) between two waves:
|
|
|
|
|
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplotmort(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
if(ageminpar == AGEOVERFLOW ||agemaxpar == AGEOVERFLOW){ |
|
printf("Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
fprintf(ficlog,"Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
}else |
|
printinggnuplotmort(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
printinghtmlmort(fileres,title,datafile, firstpass, lastpass, \ |
printinghtmlmort(fileres,title,datafile, firstpass, lastpass, \ |
stepm, weightopt,\ |
stepm, weightopt,\ |
model,imx,p,matcov,agemortsup); |
model,imx,p,matcov,agemortsup); |
Line 7210 Interval (in months) between two waves:
|
Line 7239 Interval (in months) between two waves:
|
ftolhess=ftol; /* Usually correct */ |
ftolhess=ftol; /* Usually correct */ |
hesscov(matcov, p, npar, delti, ftolhess, func); |
hesscov(matcov, p, npar, delti, ftolhess, func); |
} |
} |
|
printf("Parameters and 95%% confidence intervals\n"); |
|
fprintf(ficlog, "Parameters, T and confidence intervals\n"); |
|
for(i=1,jk=1; i <=nlstate; i++){ |
|
for(k=1; k <=(nlstate+ndeath); k++){ |
|
if (k != i) { |
|
printf("%d%d ",i,k); |
|
fprintf(ficlog,"%d%d ",i,k); |
|
for(j=1; j <=ncovmodel; j++){ |
|
printf("%12.7f T=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-2*sqrt(matcov[jk][jk]),p[jk]+2*sqrt(matcov[jk][jk])); |
|
fprintf(ficlog,"%12.7f T=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-2*sqrt(matcov[jk][jk]),p[jk]+2*sqrt(matcov[jk][jk])); |
|
jk++; |
|
} |
|
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} |
|
} |
|
} |
|
|
fprintf(ficres,"# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficres,"# Scales (for hessian or gradient estimation)\n"); |
printf("# Scales (for hessian or gradient estimation)\n"); |
printf("# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficlog,"# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficlog,"# Scales (for hessian or gradient estimation)\n"); |
Line 7366 Interval (in months) between two waves:
|
Line 7413 Interval (in months) between two waves:
|
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
|
|
fscanf(ficpar,"pop_based=%d\n",&popbased); |
fscanf(ficpar,"pop_based=%d\n",&popbased); |
|
fprintf(ficlog,"pop_based=%d\n",popbased); |
fprintf(ficparo,"pop_based=%d\n",popbased); |
fprintf(ficparo,"pop_based=%d\n",popbased); |
fprintf(ficres,"pop_based=%d\n",popbased); |
fprintf(ficres,"pop_based=%d\n",popbased); |
|
|
Line 7390 Interval (in months) between two waves:
|
Line 7438 Interval (in months) between two waves:
|
/* ,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2); */ |
/* ,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2); */ |
|
|
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplot(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
if(ageminpar == AGEOVERFLOW ||agemaxpar == -AGEOVERFLOW){ |
|
printf("Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
fprintf(ficlog,"Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
}else |
|
printinggnuplot(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
|
|
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |