version 1.117, 2006/03/14 17:16:22
|
version 1.121, 2006/03/16 17:45:01
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.121 2006/03/16 17:45:01 lievre |
|
* imach.c (Module): Comments concerning covariates added |
|
|
|
* imach.c (Module): refinements in the computation of lli if |
|
status=-2 in order to have more reliable computation if stepm is |
|
not 1 month. Version 0.98f |
|
|
|
Revision 1.120 2006/03/16 15:10:38 lievre |
|
(Module): refinements in the computation of lli if |
|
status=-2 in order to have more reliable computation if stepm is |
|
not 1 month. Version 0.98f |
|
|
|
Revision 1.119 2006/03/15 17:42:26 brouard |
|
(Module): Bug if status = -2, the loglikelihood was |
|
computed as likelihood omitting the logarithm. Version O.98e |
|
|
|
Revision 1.118 2006/03/14 18:20:07 brouard |
|
(Module): varevsij Comments added explaining the second |
|
table of variances if popbased=1 . |
|
(Module): Covariances of eij, ekl added, graphs fixed, new html link. |
|
(Module): Function pstamp added |
|
(Module): Version 0.98d |
|
|
Revision 1.117 2006/03/14 17:16:22 brouard |
Revision 1.117 2006/03/14 17:16:22 brouard |
(Module): varevsij Comments added explaining the second |
(Module): varevsij Comments added explaining the second |
table of variances if popbased=1 . |
table of variances if popbased=1 . |
Line 318 extern int errno;
|
Line 341 extern int errno;
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98d, March 2006, INED-EUROREVES-Institut de longevite "; |
char version[]="Imach version 0.98f, March 2006, INED-EUROREVES-Institut de longevite "; |
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 1375 double func( double *x)
|
Line 1398 double func( double *x)
|
|
|
} else if (s2==-2) { |
} else if (s2==-2) { |
for (j=1,survp=0. ; j<=nlstate; j++) |
for (j=1,survp=0. ; j<=nlstate; j++) |
survp += out[s1][j]; |
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j]; |
lli= survp; |
/*survp += out[s1][j]; */ |
|
lli= log(survp); |
} |
} |
|
|
else if (s2==-4) { |
else if (s2==-4) { |
for (j=3,survp=0. ; j<=nlstate; j++) |
for (j=3,survp=0. ; j<=nlstate; j++) |
survp += out[s1][j]; |
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j]; |
lli= survp; |
lli= log(survp); |
} |
} |
|
|
else if (s2==-5) { |
|
for (j=1,survp=0. ; j<=2; j++) |
|
survp += out[s1][j]; |
|
lli= survp; |
|
} |
|
|
|
|
|
|
else if (s2==-5) { |
|
for (j=1,survp=0. ; j<=2; j++) |
|
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j]; |
|
lli= log(survp); |
|
} |
|
|
else{ |
else{ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
/* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */ |
/* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */ |
Line 1586 double funcone( double *x)
|
Line 1609 double funcone( double *x)
|
*/ |
*/ |
if( s2 > nlstate && (mle <5) ){ /* Jackson */ |
if( s2 > nlstate && (mle <5) ){ /* Jackson */ |
lli=log(out[s1][s2] - savm[s1][s2]); |
lli=log(out[s1][s2] - savm[s1][s2]); |
} else if (mle==1){ |
} else if (s2==-2) { |
|
for (j=1,survp=0. ; j<=nlstate; j++) |
|
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j]; |
|
lli= log(survp); |
|
}else if (mle==1){ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
} else if(mle==2){ |
} else if(mle==2){ |
lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]):log((1.+bbh)*out[s1][s2])); /* linear interpolation */ |
lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]):log((1.+bbh)*out[s1][s2])); /* linear interpolation */ |
Line 1602 double funcone( double *x)
|
Line 1629 double funcone( double *x)
|
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
/* printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
/* printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
if(globpr){ |
if(globpr){ |
fprintf(ficresilk,"%9d %6d %1d %1d %1d %1d %3d %10.6f %6.4f\ |
fprintf(ficresilk,"%9d %6d %2d %2d %1d %1d %3d %11.6f %8.4f\ |
%10.6f %10.6f %10.6f ", \ |
%11.6f %11.6f %11.6f ", \ |
num[i],i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i], |
num[i],i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i], |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
for(k=1,llt=0.,l=0.; k<=nlstate; k++){ |
for(k=1,llt=0.,l=0.; k<=nlstate; k++){ |
Line 2468 void evsij(char fileres[], double ***eij
|
Line 2495 void evsij(char fileres[], double ***eij
|
for (age=bage; age<=fage; age ++){ /* If stepm=6 months */ |
for (age=bage; age<=fage; age ++){ /* If stepm=6 months */ |
/* Computed by stepm unit matrices, product of hstepm matrices, stored |
/* Computed by stepm unit matrices, product of hstepm matrices, stored |
in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */ |
in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */ |
|
|
hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, cij); |
hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, cij); |
|
|
hf=hstepm*stepm/YEARM; /* Duration of hstepm expressed in year unit. */ |
hf=hstepm*stepm/YEARM; /* Duration of hstepm expressed in year unit. */ |
|
|
/* Computing Variances of health expectancies */ |
printf("%d|",(int)age);fflush(stdout); |
/* Gradient is computed with plus gp and minus gm. Code is duplicated in order to |
fprintf(ficlog,"%d|",(int)age);fflush(ficlog); |
decrease memory allocation */ |
|
printf("%d|",(int)age);fflush(stdout); |
|
fprintf(ficlog,"%d|",(int)age);fflush(ficlog); |
|
/* Computing expectancies */ |
/* Computing expectancies */ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
for(j=1; j<=nlstate;j++) |
for(j=1; j<=nlstate;j++) |
for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){ |
for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){ |
eij[i][j][(int)age] += (p3mat[i][j][h]+p3mat[i][j][h+1])/2.0*hf; |
eij[i][j][(int)age] += (p3mat[i][j][h]+p3mat[i][j][h+1])/2.0*hf; |
|
|
/* if((int)age==70)printf("i=%2d,j=%2d,h=%2d,age=%3d,%9.4f,%9.4f,%9.4f\n",i,j,h,(int)age,p3mat[i][j][h],hf,eij[i][j][(int)age]);*/ |
/* if((int)age==70)printf("i=%2d,j=%2d,h=%2d,age=%3d,%9.4f,%9.4f,%9.4f\n",i,j,h,(int)age,p3mat[i][j][h],hf,eij[i][j][(int)age]);*/ |
|
|
} |
} |
|
|
Line 2498 void evsij(char fileres[], double ***eij
|
Line 2523 void evsij(char fileres[], double ***eij
|
fprintf(ficreseij,"%9.4f", eip ); |
fprintf(ficreseij,"%9.4f", eip ); |
} |
} |
fprintf(ficreseij,"\n"); |
fprintf(ficreseij,"\n"); |
|
|
} |
} |
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); |
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); |
printf("\n"); |
printf("\n"); |
fprintf(ficlog,"\n"); |
fprintf(ficlog,"\n"); |
|
|
} |
} |
|
|
void cvevsij(char fileres[], double ***eij, double x[], int nlstate, int stepm, int bage, int fage, double **oldm, double **savm, int cij, int estepm,double delti[],double **matcov,char strstart[] ) |
void cvevsij(char fileres[], double ***eij, double x[], int nlstate, int stepm, int bage, int fage, double **oldm, double **savm, int cij, int estepm,double delti[],double **matcov,char strstart[] ) |
Line 3435 void printinghtml(char fileres[], char t
|
Line 3460 void printinghtml(char fileres[], char t
|
- Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", |
- Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"pl"),subdirf2(fileres,"pl")); |
subdirf2(fileres,"pl"),subdirf2(fileres,"pl")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- (a) Life expectancies by health status at initial age, (b) health expectancies by health status at initial age: ei., eij (estepm=%2d months): \ |
- (a) Life expectancies by health status at initial age, (b) health expectancies by health status at initial age: ei., eij . If one or more covariate are included, specific tables for each value of the covariate are output in sequences within the same file (estepm=%2d months): \ |
<a href=\"%s\">%s</a> <br>\n</li>", |
<a href=\"%s\">%s</a> <br>\n</li>", |
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
|
|
Line 4404 int main(int argc, char *argv[])
|
Line 4429 int main(int argc, char *argv[])
|
while ((val = strsep(&tok, "\"" )) != NULL && *val == '\0'); |
while ((val = strsep(&tok, "\"" )) != NULL && *val == '\0'); |
printf("val= |%s| pathr=%s\n",val,pathr); |
printf("val= |%s| pathr=%s\n",val,pathr); |
strcpy (pathtot, val); |
strcpy (pathtot, val); |
if(pathr[0] == '\0') break; /* Un peu sale */ |
if(pathr[0] == '\0') break; /* Dirty */ |
} |
} |
} |
} |
else{ |
else{ |
Line 4423 int main(int argc, char *argv[])
|
Line 4448 int main(int argc, char *argv[])
|
/* Split argv[1]=pathtot, parameter file name to get path, optionfile, extension and name */ |
/* Split argv[1]=pathtot, parameter file name to get path, optionfile, extension and name */ |
split(pathtot,path,optionfile,optionfilext,optionfilefiname); |
split(pathtot,path,optionfile,optionfilext,optionfilefiname); |
printf("\npathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); |
printf("\npathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); |
chdir(path); |
chdir(path); /* Can be a relative path */ |
|
if(getcwd(pathcd,MAXLINE) > 0) /* So pathcd is the full path */ |
|
printf("Current directory %s!\n",pathcd); |
strcpy(command,"mkdir "); |
strcpy(command,"mkdir "); |
strcat(command,optionfilefiname); |
strcat(command,optionfilefiname); |
if((outcmd=system(command)) != 0){ |
if((outcmd=system(command)) != 0){ |
Line 4689 int main(int argc, char *argv[])
|
Line 4716 int main(int argc, char *argv[])
|
|
|
/*-------- data file ----------*/ |
/*-------- data file ----------*/ |
if((fic=fopen(datafile,"r"))==NULL) { |
if((fic=fopen(datafile,"r"))==NULL) { |
printf("Problem with datafile: %s\n", datafile);goto end; |
printf("Problem while opening datafile: %s\n", datafile);goto end; |
fprintf(ficlog,"Problem with datafile: %s\n", datafile);goto end; |
fprintf(ficlog,"Problem while opening datafile: %s\n", datafile);goto end; |
} |
} |
|
|
n= lastobs; |
n= lastobs; |
Line 5256 Interval (in months) between two waves:
|
Line 5283 Interval (in months) between two waves:
|
printf("%d %.0lf %lf %.0lf %.0lf %.0lf %lf\n",k,lsurv[k],p[1]*exp(p[2]*(k-agegomp)),(p[1]*exp(p[2]*(k-agegomp)))*lsurv[k],lpop[k],tpop[k],tpop[k]/lsurv[k]); |
printf("%d %.0lf %lf %.0lf %.0lf %.0lf %lf\n",k,lsurv[k],p[1]*exp(p[2]*(k-agegomp)),(p[1]*exp(p[2]*(k-agegomp)))*lsurv[k],lpop[k],tpop[k],tpop[k]/lsurv[k]); |
|
|
|
|
replace_back_to_slash(pathc,path); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplotmort(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
printinggnuplotmort(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
|
|
printinghtmlmort(fileres,title,datafile, firstpass, lastpass, \ |
printinghtmlmort(fileres,title,datafile, firstpass, lastpass, \ |
Line 5493 Interval (in months) between two waves:
|
Line 5520 Interval (in months) between two waves:
|
/* freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint);*/ |
/* freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint);*/ |
/*,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
/*,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
|
|
replace_back_to_slash(pathc,path); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplot(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
printinggnuplot(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
|
|
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
Line 5748 Interval (in months) between two waves:
|
Line 5775 Interval (in months) between two waves:
|
} |
} |
|
|
pstamp(ficrest); |
pstamp(ficrest); |
fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state ( e.. (std) "); |
fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# Age ( e.. (std) "); |
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
fprintf(ficrest,"\n"); |
fprintf(ficrest,"\n"); |
|
|
Line 5888 Interval (in months) between two waves:
|
Line 5915 Interval (in months) between two waves:
|
fclose(ficlog); |
fclose(ficlog); |
/*------ End -----------*/ |
/*------ End -----------*/ |
|
|
chdir(path); |
|
|
printf("Before Current directory %s!\n",pathcd); |
|
if(chdir(pathcd) != 0) |
|
printf("Can't move to directory %s!\n",path); |
|
if(getcwd(pathcd,MAXLINE) > 0) |
|
printf("Current directory %s!\n",pathcd); |
/*strcat(plotcmd,CHARSEPARATOR);*/ |
/*strcat(plotcmd,CHARSEPARATOR);*/ |
sprintf(plotcmd,"gnuplot"); |
sprintf(plotcmd,"gnuplot"); |
#ifndef UNIX |
#ifndef UNIX |