Diff for /imach/src/imach.c between versions 1.30 and 1.31

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

Removed from v.1.30  
changed lines
  Added in v.1.31


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>