version 1.127, 2006/04/28 18:11:50
|
version 1.128, 2006/06/30 13:02:05
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.128 2006/06/30 13:02:05 brouard |
|
(Module): Clarifications on computing e.j |
|
|
Revision 1.127 2006/04/28 18:11:50 brouard |
Revision 1.127 2006/04/28 18:11:50 brouard |
(Module): Yes the sum of survivors was wrong since |
(Module): Yes the sum of survivors was wrong since |
imach-114 because nhstepm was no more computed in the age |
imach-114 because nhstepm was no more computed in the age |
Line 386 extern int errno;
|
Line 389 extern int errno;
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98h, April 2006, INED-EUROREVES-Institut de longevite "; |
char version[]="Imach version 0.98i, June 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 1344 double ***hpxij(double ***po, int nhstep
|
Line 1347 double ***hpxij(double ***po, int nhstep
|
for(i=1; i<=nlstate+ndeath; i++) |
for(i=1; i<=nlstate+ndeath; i++) |
for(j=1;j<=nlstate+ndeath;j++) { |
for(j=1;j<=nlstate+ndeath;j++) { |
po[i][j][h]=newm[i][j]; |
po[i][j][h]=newm[i][j]; |
/*printf("i=%d j=%d h=%d po[i][j][h]=%f ",i,j,h,po[i][j][h]); |
/*if(h==nhstepm) printf("po[%d][%d][%d]=%f ",i,j,h,po[i][j][h]);*/ |
*/ |
|
} |
} |
|
/*printf("h=%d ",h);*/ |
} /* end h */ |
} /* end h */ |
|
/* printf("\n H=%d \n",h); */ |
return po; |
return po; |
} |
} |
|
|
Line 2264 void prevalence(double ***probs, double
|
Line 2268 void prevalence(double ***probs, double
|
if( i <= iagemax){ |
if( i <= iagemax){ |
if(posprop>=1.e-5){ |
if(posprop>=1.e-5){ |
probs[i][jk][j1]= prop[jk][i]/posprop; |
probs[i][jk][j1]= prop[jk][i]/posprop; |
} |
} else |
|
printf("Warning Observed prevalence probs[%d][%d][%d]=%lf because of lack of cases\n",jk,i,j1,probs[i][jk][j1]); |
} |
} |
}/* end jk */ |
}/* end jk */ |
}/* end i */ |
}/* end i */ |
Line 2868 void varevsij(char optionfilefiname[], d
|
Line 2873 void varevsij(char optionfilefiname[], d
|
pstamp(ficresvij); |
pstamp(ficresvij); |
fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are "); |
fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are "); |
if(popbased==1) |
if(popbased==1) |
fprintf(ficresvij,"the age specific prevalence observed in the population i.e cross-sectionally\n in each health state (popbased=1)"); |
fprintf(ficresvij,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d\n",mobilav); |
else |
else |
fprintf(ficresvij,"the age specific period (stable) prevalences in each health state \n"); |
fprintf(ficresvij,"the age specific period (stable) prevalences in each health state \n"); |
fprintf(ficresvij,"# Age"); |
fprintf(ficresvij,"# Age"); |
Line 2896 void varevsij(char optionfilefiname[], d
|
Line 2901 void varevsij(char optionfilefiname[], d
|
/* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. |
/* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. |
nhstepm is the number of hstepm from age to agelim |
nhstepm is the number of hstepm from age to agelim |
nstepm is the number of stepm from age to agelin. |
nstepm is the number of stepm from age to agelin. |
Look at hpijx to understand the reason of that which relies in memory size |
Look at function hpijx to understand why (it is linked to memory size questions) */ |
and note for a fixed period like k years */ |
|
/* We decided (b) to get a life expectancy respecting the most precise curvature of the |
/* We decided (b) to get a life expectancy respecting the most precise curvature of the |
survival function given by stepm (the optimization length). Unfortunately it |
survival function given by stepm (the optimization length). Unfortunately it |
means that if the survival funtion is printed every two years of age and if |
means that if the survival funtion is printed every two years of age and if |
Line 2963 void varevsij(char optionfilefiname[], d
|
Line 2967 void varevsij(char optionfilefiname[], d
|
} |
} |
} |
} |
|
|
for(j=1; j<= nlstate; j++){ |
for(j=1; j<= nlstate; j++){ /* Sum of wi * eij = e.j */ |
for(h=0; h<=nhstepm; h++){ |
for(h=0; h<=nhstepm; h++){ |
for(i=1, gm[h][j]=0.;i<=nlstate;i++) |
for(i=1, gm[h][j]=0.;i<=nlstate;i++) |
gm[h][j] += prlim[i][i]*p3mat[i][j][h]; |
gm[h][j] += prlim[i][i]*p3mat[i][j][h]; |
Line 3523 void printinghtml(char fileres[], char t
|
Line 3527 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 . 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) Life expectancies by health status at initial age, ei. (b) health expectancies by health status at initial age, eij . If one or more covariates 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", |
<a href=\"%s\">%s</a> <br>\n", |
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
Line 3588 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 3592 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
<a href=\"%s\">%s</a> <br>\n</li>", |
<a href=\"%s\">%s</a> <br>\n</li>", |
estepm,subdirf2(fileres,"stde"),subdirf2(fileres,"stde")); |
estepm,subdirf2(fileres,"stde"),subdirf2(fileres,"stde")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), eij are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences (i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", |
- Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), e<sup>ij</sup> are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", |
estepm, subdirf2(fileres,"v"),subdirf2(fileres,"v")); |
estepm, subdirf2(fileres,"v"),subdirf2(fileres,"v")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors: <a href=\"%s\">%s</a> <br>\n", |
- Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"t"),subdirf2(fileres,"t")); |
estepm, subdirf2(fileres,"t"),subdirf2(fileres,"t")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ |
- Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ |
subdirf2(fileres,"vpl"),subdirf2(fileres,"vpl")); |
subdirf2(fileres,"vpl"),subdirf2(fileres,"vpl")); |
Line 3625 prevalence (with 95%% confidence interva
|
Line 3629 prevalence (with 95%% confidence interva
|
<img src=\"%s%d%d.png\">",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1); |
<img src=\"%s%d%d.png\">",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1); |
} |
} |
fprintf(fichtm,"\n<br>- Total life expectancy by age and \ |
fprintf(fichtm,"\n<br>- Total life expectancy by age and \ |
health expectancies in states (1) and (2): %s%d.png<br>\ |
health expectancies in states (1) and (2). If popbased=1 the smooth (due to the model) \ |
|
true period expectancies (those weighted with period prevalences are also\ |
|
drawn in addition to the population based expectancies computed using\ |
|
observed and cahotic prevalences: %s%d.png<br>\ |
<img src=\"%s%d.png\">",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1); |
<img src=\"%s%d.png\">",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1); |
} /* end i1 */ |
} /* end i1 */ |
}/* End k1 */ |
}/* End k1 */ |
Line 4388 int main(int argc, char *argv[])
|
Line 4395 int main(int argc, char *argv[])
|
int numlinepar=0; /* Current linenumber of parameter file */ |
int numlinepar=0; /* Current linenumber of parameter file */ |
int itimes; |
int itimes; |
int NDIM=2; |
int NDIM=2; |
|
int vpopbased=0; |
|
|
char ca[32], cb[32], cc[32]; |
char ca[32], cb[32], cc[32]; |
char dummy[]=" "; |
char dummy[]=" "; |
Line 5863 Interval (in months) between two waves:
|
Line 5871 Interval (in months) between two waves:
|
cvevsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart); |
cvevsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart); |
|
|
vareij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); |
vareij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); |
oldm=oldms;savm=savms; |
|
varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,0, mobilav, strstart); |
|
if(popbased==1){ |
|
varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,popbased,mobilav, strstart); |
|
} |
|
|
|
pstamp(ficrest); |
pstamp(ficrest); |
fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# Age ( e.. (std) "); |
for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/ |
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
oldm=oldms;savm=savms; |
fprintf(ficrest,"\n"); |
varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,vpopbased,mobilav, strstart); fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# (weighted average of eij where weights are "); |
|
if(vpopbased==1) |
|
fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav); |
|
else |
|
fprintf(ficrest,"the age specific period (stable) prevalences in each health state \n"); |
|
fprintf(ficrest,"# Age e.. (std) "); |
|
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
|
fprintf(ficrest,"\n"); |
|
|
epj=vector(1,nlstate+1); |
epj=vector(1,nlstate+1); |
for(age=bage; age <=fage ;age++){ |
for(age=bage; age <=fage ;age++){ |
prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); |
prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); |
if (popbased==1) { |
if (vpopbased==1) { |
if(mobilav ==0){ |
if(mobilav ==0){ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
prlim[i][i]=probs[(int)age][i][k]; |
prlim[i][i]=probs[(int)age][i][k]; |
}else{ /* mobilav */ |
}else{ /* mobilav */ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
prlim[i][i]=mobaverage[(int)age][i][k]; |
prlim[i][i]=mobaverage[(int)age][i][k]; |
|
} |
} |
} |
} |
|
|
|
fprintf(ficrest," %4.0f",age); |
fprintf(ficrest," %4.0f",age); |
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ |
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ |
for(i=1, epj[j]=0.;i <=nlstate;i++) { |
for(i=1, epj[j]=0.;i <=nlstate;i++) { |
epj[j] += prlim[i][i]*eij[i][j][(int)age]; |
epj[j] += prlim[i][i]*eij[i][j][(int)age]; |
/* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/ |
/* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/ |
|
} |
|
epj[nlstate+1] +=epj[j]; |
} |
} |
epj[nlstate+1] +=epj[j]; |
|
} |
|
|
|
for(i=1, vepp=0.;i <=nlstate;i++) |
for(i=1, vepp=0.;i <=nlstate;i++) |
for(j=1;j <=nlstate;j++) |
for(j=1;j <=nlstate;j++) |
vepp += vareij[i][j][(int)age]; |
vepp += vareij[i][j][(int)age]; |
fprintf(ficrest," %7.3f (%7.3f)", epj[nlstate+1],sqrt(vepp)); |
fprintf(ficrest," %7.3f (%7.3f)", epj[nlstate+1],sqrt(vepp)); |
for(j=1;j <=nlstate;j++){ |
for(j=1;j <=nlstate;j++){ |
fprintf(ficrest," %7.3f (%7.3f)", epj[j],sqrt(vareij[j][j][(int)age])); |
fprintf(ficrest," %7.3f (%7.3f)", epj[j],sqrt(vareij[j][j][(int)age])); |
|
} |
|
fprintf(ficrest,"\n"); |
} |
} |
fprintf(ficrest,"\n"); |
|
} |
} |
free_ma3x(eij,1,nlstate,1,nlstate,(int) bage, (int)fage); |
free_ma3x(eij,1,nlstate,1,nlstate,(int) bage, (int)fage); |
free_ma3x(vareij,1,nlstate,1,nlstate,(int) bage, (int)fage); |
free_ma3x(vareij,1,nlstate,1,nlstate,(int) bage, (int)fage); |