--- imach/src/imach.c 2006/03/22 17:13:53 1.124
+++ imach/src/imach.c 2006/04/28 17:23:28 1.126
@@ -1,6 +1,16 @@
-/* $Id: imach.c,v 1.124 2006/03/22 17:13:53 lievre Exp $
+/* $Id: imach.c,v 1.126 2006/04/28 17:23:28 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.126 2006/04/28 17:23:28 brouard
+ (Module): Yes the sum of survivors was wrong since
+ imach-114 because nhstepm was no more computed in the age
+ loop. Now we define nhstepma in the age loop.
+ Version 0.98h
+
+ Revision 1.125 2006/04/04 15:20:31 lievre
+ Errors in calculation of health expectancies. Age was not initialized.
+ Forecasting file added.
+
Revision 1.124 2006/03/22 17:13:53 lievre
Parameters are printed with %lf instead of %f (more numbers after the comma).
The log-likelihood is printed in the log file
@@ -361,11 +371,11 @@ extern int errno;
#define ODIRSEPARATOR '/'
#endif
-/* $Id: imach.c,v 1.124 2006/03/22 17:13:53 lievre Exp $ */
+/* $Id: imach.c,v 1.126 2006/04/28 17:23:28 brouard Exp $ */
/* $State: Exp $ */
-char version[]="Imach version 0.98g, March 2006, INED-EUROREVES-Institut de longevite ";
-char fullversion[]="$Revision: 1.124 $ $Date: 2006/03/22 17:13:53 $";
+char version[]="Imach version 0.98h, April 2006, INED-EUROREVES-Institut de longevite ";
+char fullversion[]="$Revision: 1.126 $ $Date: 2006/04/28 17:23:28 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -2097,7 +2107,6 @@ void freqsummary(char fileres[], int ia
for(i=iagemin; i <= iagemax+3; i++){
if(i==iagemax+3){
fprintf(ficlog,"Total");
- fprintf(fichtm,"
Total
");
}else{
if(first==1){
first=0;
@@ -2463,6 +2472,7 @@ void evsij(char fileres[], double ***eij
{
/* Health expectancies, no variances */
int i, j, nhstepm, hstepm, h, nstepm, k, cptj, cptj2, i2, j2;
+ int nhstepma, nstepma; /* Decreasing with age */
double age, agelim, hf;
double ***p3mat;
double eip;
@@ -2509,18 +2519,28 @@ void evsij(char fileres[], double ***eij
hstepm=hstepm/stepm; /* Typically in stepm units, if stepm=6 & estepm=24 , = 24/6 months = 4 */
agelim=AGESUP;
- /* nhstepm age range expressed in number of stepm */
- nstepm=(int) rint((agelim-age)*YEARM/stepm);
+ /* If stepm=6 months */
+ /* Computed by stepm unit matrices, product of hstepm matrices, stored
+ in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */
+
+/* nhstepm age range expressed in number of stepm */
+ nstepm=(int) rint((agelim-bage)*YEARM/stepm); /* Biggest nstepm */
/* Typically if 20 years nstepm = 20*12/6=40 stepm */
/* if (stepm >= YEARM) hstepm=1;*/
nhstepm = nstepm/hstepm;/* Expressed in hstepm, typically nhstepm=40/4=10 */
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
- for (age=bage; age<=fage; age ++){ /* If stepm=6 months */
- /* Computed by stepm unit matrices, product of hstepm matrices, stored
- in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */
+ for (age=bage; age<=fage; age ++){
+ nstepma=(int) rint((agelim-bage)*YEARM/stepm); /* Biggest nstepm */
+ /* Typically if 20 years nstepm = 20*12/6=40 stepm */
+ /* if (stepm >= YEARM) hstepm=1;*/
+ nhstepma = nstepma/hstepm;/* Expressed in hstepm, typically nhstepma=40/4=10 */
+
+ /* If stepm=6 months */
+ /* Computed by stepm unit matrices, product of hstepma matrices, stored
+ in an array of nhstepma length: nhstepma=10, hstepm=4, stepm=6 months */
- hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, cij);
+ hpxij(p3mat,nhstepma,age,hstepm,x,nlstate,stepm,oldm, savm, cij);
hf=hstepm*stepm/YEARM; /* Duration of hstepm expressed in year unit. */
@@ -2562,6 +2582,7 @@ void cvevsij(char fileres[], double ***e
to initial status i, ei. .
*/
int i, j, nhstepm, hstepm, h, nstepm, k, cptj, cptj2, i2, j2, ij, ji;
+ int nhstepma, nstepma; /* Decreasing with age */
double age, agelim, hf;
double ***p3matp, ***p3matm, ***varhe;
double **dnewm,**doldm;
@@ -2635,7 +2656,7 @@ void cvevsij(char fileres[], double ***e
/* If stepm=6 months */
/* nhstepm age range expressed in number of stepm */
agelim=AGESUP;
- nstepm=(int) rint((agelim-age)*YEARM/stepm);
+ nstepm=(int) rint((agelim-bage)*YEARM/stepm);
/* Typically if 20 years nstepm = 20*12/6=40 stepm */
/* if (stepm >= YEARM) hstepm=1;*/
nhstepm = nstepm/hstepm;/* Expressed in hstepm, typically nhstepm=40/4=10 */
@@ -2648,10 +2669,15 @@ void cvevsij(char fileres[], double ***e
gm=matrix(0,nhstepm,1,nlstate*nlstate);
for (age=bage; age<=fage; age ++){
-
- /* Computed by stepm unit matrices, product of hstepm matrices, stored
- in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */
-
+ nstepma=(int) rint((agelim-bage)*YEARM/stepm); /* Biggest nstepm */
+ /* Typically if 20 years nstepm = 20*12/6=40 stepm */
+ /* if (stepm >= YEARM) hstepm=1;*/
+ nhstepma = nstepma/hstepm;/* Expressed in hstepm, typically nhstepma=40/4=10 */
+
+ /* If stepm=6 months */
+ /* Computed by stepm unit matrices, product of hstepma matrices, stored
+ in an array of nhstepma length: nhstepma=10, hstepm=4, stepm=6 months */
+
hf=hstepm*stepm/YEARM; /* Duration of hstepm expressed in year unit. */
/* Computing Variances of health expectancies */
@@ -2702,6 +2728,7 @@ void cvevsij(char fileres[], double ***e
varhe[ij][ji][(int)age] += doldm[ij][ji]*hf*hf;
}
}
+
/* Computing expectancies */
hpxij(p3matm,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, cij);
for(i=1; i<=nlstate;i++)
@@ -3485,9 +3512,11 @@ void printinghtml(char fileres[], char t
subdirf2(fileres,"pl"),subdirf2(fileres,"pl"));
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): \
- %s
\n",
+ %s
\n",
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e"));
-
+ fprintf(fichtm,"\
+ - Population projections by age and states: \
+ %s
\n", subdirf2(fileres,"f"),subdirf2(fileres,"f"));
fprintf(fichtm," \n
");