void evsij(char fileres[], double ***eij, double x[], int nlstate, int stepm, int bage, int fage, double **oldm, double **savm, int ij)\r
{\r
/* Health expectancies */\r
- int i, j, nhstepm, hstepm, h;\r
+ int i, j, nhstepm, hstepm, h, nstepm, k;\r
double age, agelim,hf;\r
double ***p3mat;\r
\r
fprintf(ficreseij," %1d-%1d",i,j);\r
fprintf(ficreseij,"\n");\r
\r
- hstepm=1*YEARM; /* Every j years of age (in month) */\r
- hstepm=hstepm/stepm; /* Typically in stepm units, if j= 2 years, = 2/6 months = 4 */ \r
+ k=1; /* For example stepm=6 months */\r
+ hstepm=k*YEARM; /* (a) Every k years of age (in months), for example every k=2 years 24 m */\r
+ hstepm=1; /* or (b) We decided to compute the life expectancy with the smallest unit */\r
+ /* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. \r
+ nhstepm is the number of hstepm from age to agelim \r
+ nstepm is the number of stepm from age to agelin. \r
+ Look at hpijx to understand the reason of that which relies in memory size\r
+ and note for a fixed period like k years */\r
+ /* We decided (b) to get a life expectancy respecting the most precise curvature of the\r
+ survival function given par stepm (the optimization length). Unfortunately it\r
+ means that if the survival funtion is printed only each two years of age and if\r
+ you sum them up and add 1 year (area under the trapezoids) you won't get the same \r
+ results. So we changed our mind and took the option of the best precision.\r
+ */\r
+ hstepm=hstepm/stepm; /* Typically in stepm units, if k= 2 years, = 2/6 months = 4 */ \r
\r
agelim=AGESUP;\r
for (age=bage; age<=fage; age ++){ /* If stepm=6 months */\r
/* nhstepm age range expressed in number of stepm */\r
- nhstepm=(int) rint((agelim-age)*YEARM/stepm); \r
- /* Typically if 20 years = 20*12/6=40 stepm */ \r
- /*if (stepm >= YEARM) hstepm=1;*/\r
-hstepm=1;\r
- nhstepm = nhstepm/hstepm;/* Expressed in hstepm, typically 40/4=10 */\r
+ nstepm=(int) rint((agelim-age)*YEARM/stepm); \r
+ /* Typically if 20 years nstepm = 20*12/6=40 stepm */ \r
+ if (stepm >= YEARM) hstepm=1;\r
+ nhstepm = nstepm/hstepm;/* Expressed in hstepm, typically nhstepm=40/4=10 */\r
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
/* Computed by stepm unit matrices, product of hstepm matrices, stored\r
in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */\r
hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, ij); \r
-hf=stepm/YEARM;\r
-/*printf("stepm=%d nhstepm=%d hstepm=%d age=%lf ",stepm, nhstepm, hstepm, age);*/\r
+ hf=hstepm/YEARM; /* Duration of hstepm expressed in year unit. */\r
for(i=1; i<=nlstate;i++)\r
for(j=1; j<=nlstate;j++)\r
for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){\r
- eij[i][j][(int)age] +=hf*(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0;\r
+ eij[i][j][(int)age] += (p3mat[i][j][h]+p3mat[i][j][h+1])/2.0*hf;\r
+ /* 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]);*/\r
}\r
- \r
- /* hf=1;\r
- if (stepm >= YEARM) hf=stepm/YEARM;*/\r
-hf=stepm/YEARM;\r
- \r
fprintf(ficreseij,"%3.0f",age );\r
for(i=1; i<=nlstate;i++)\r
for(j=1; j<=nlstate;j++){\r
printf("Problem with %s \n",optionfilehtm), exit(0);\r
}\r
\r
- fprintf(fichtm,"<body><ul> <font size=\"6\">Imach, Version 0.71 </font> <hr size=\"2\" color=\"#EC5E5E\"> \r
+ fprintf(fichtm,"<body><ul> <font size=\"6\">Imach, Version 0.71a </font> <hr size=\"2\" color=\"#EC5E5E\"> \r
Title=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br>\r
\r
Total number of observations=%d <br>\r
double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2;\r
\r
\r
- char version[80]="Imach version 0.71, February 2002, INED-EUROREVES ";\r
+ char version[80]="Imach version 0.71a, March 2002, INED-EUROREVES ";\r
char *alph[]={"a","a","b","c","d","e"}, str[4];\r
\r
\r