hPijx is the probability to be observed in state i at age x+h
conditional to the observed state i at age x. The delay 'h' can be
split into an exact number (nh*stepm) of unobserved intermediate
- states. This elementary transition (by month or quarter trimester,
- semester or year) is model as a multinomial logistic. The hPx
+ states. This elementary transition (by month, quarter,
+ semester or year) is modelled as a multinomial logistic. The hPx
matrix is simply the matrix product of nh*stepm elementary matrices
and the contribution of each individual to the likelihood is simply
hPijx.
#define ODIRSEPARATOR '\\'
#endif
-char version[80]="Imach version 0.9, November 2002, INED-EUROREVES ";
+char version[80]="Imach version 0.91, November 2002, INED-EUROREVES ";
int erreur; /* Error number */
int nvar;
int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov;
double ***hpxij(double ***po, int nhstepm, double age, int hstepm, double *x, int nlstate, int stepm, double **oldm, double **savm, int ij )
{
- /* Computes the transition matrix starting at age 'age' over 'nhstepm*hstepm*stepm' month
- duration (i.e. until
- age (in years) age+nhstepm*stepm/12) by multiplying nhstepm*hstepm matrices.
+ /* Computes the transition matrix starting at age 'age' over
+ 'nhstepm*hstepm*stepm' months (i.e. until
+ age (in years) age+nhstepm*hstepm*stepm/12) by multiplying
+ nhstepm*hstepm matrices.
Output is stored in matrix po[i][j][h] for h every 'hstepm' step
- (typically every 2 years instead of every month which is too big).
+ (typically every 2 years instead of every month which is too big
+ for the memory).
Model is determined by parameters x and covariates have to be
included manually here.
* This is mainly to measure the difference between two models: for example
* if stepm=24 months pijx are given only every 2 years and by summing them
* we are calculating an estimate of the Life Expectancy assuming a linear
- * progression inbetween and thus overestimating or underestimating according
+ * progression in between and thus overestimating or underestimating according
* to the curvature of the survival function. If, for the same date, we
* estimate the model with stepm=1 month, we can keep estepm to 24 months
* to compare the new estimate of Life expectancy with the same linear
}
printf("Computing total mortality p.j=w1*p1j+w2*p2j+..: result on file '%s' \n",fileresprobmorprev);
fprintf(ficlog,"Computing total mortality p.j=w1*p1j+w2*p2j+..: result on file '%s' \n",fileresprobmorprev);
- fprintf(ficresprobmorprev,"# probabilities of dying during a year and weighted mean w1*p1j+w2*p2j+... stand dev in()\n");
+ fprintf(ficresprobmorprev,"# probabilities of dying before estepm=%d months for people of exact age and weighted probabilities w1*p1j+w2*p2j+... stand dev in()\n",estepm);
fprintf(ficresprobmorprev,"# Age cov=%-d",ij);
for(j=nlstate+1; j<=(nlstate+ndeath);j++){
fprintf(ficresprobmorprev," p.%-d SE",j);
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 by stepm (the optimization length). Unfortunately it
- means that if the survival funtion is printed only each two years of age and if
+ means that if the survival funtion is printed every 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.
*/
for(theta=1; theta <=npar; theta++){
- for(i=1; i<=npar; i++){ /* Computes gradient */
+ for(i=1; i<=npar; i++){ /* Computes gradient x + delta*/
xp[i] = x[i] + (i==theta ?delti[theta]:0);
}
hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij);
gp[h][j] += prlim[i][i]*p3mat[i][j][h];
}
}
- /* This for computing forces of mortality (h=1)as a weighted average */
+ /* This for computing probability of death (h=1 means
+ computed over hstepm matrices product = hstepm*stepm months)
+ as a weighted average of prlim.
+ */
for(j=nlstate+1,gpp[j]=0.;j<=nlstate+ndeath;j++){
for(i=1; i<= nlstate; i++)
gpp[j] += prlim[i][i]*p3mat[i][j][1];
}
- /* end force of mortality */
+ /* end probability of death */
- for(i=1; i<=npar; i++) /* Computes gradient */
+ for(i=1; i<=npar; i++) /* Computes gradient x - delta */
xp[i] = x[i] - (i==theta ?delti[theta]:0);
hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij);
prevalim(prlim,nlstate,xp,age,oldm,savm,ftolpl,ij);
gm[h][j] += prlim[i][i]*p3mat[i][j][h];
}
}
- /* This for computing force of mortality (h=1)as a weighted average */
+ /* This for computing probability of death (h=1 means
+ computed over hstepm matrices product = hstepm*stepm months)
+ as a weighted average of prlim.
+ */
for(j=nlstate+1,gmp[j]=0.;j<=nlstate+ndeath;j++){
for(i=1; i<= nlstate; i++)
gmp[j] += prlim[i][i]*p3mat[i][j][1];
}
- /* end force of mortality */
+ /* end probability of death */
for(j=1; j<= nlstate; j++) /* vareij */
for(h=0; h<=nhstepm; h++){
for(i=nlstate+1;i<=nlstate+ndeath;i++)
varppt[j][i]=doldmp[j][i];
/* end ppptj */
+ /* x centered again */
hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm,savm, ij);
prevalim(prlim,nlstate,x,age,oldm,savm,ftolpl,ij);
}
}
- /* This for computing force of mortality (h=1)as a weighted average */
+ /* This for computing probability of death (h=1 means
+ computed over hstepm (estepm) matrices product = hstepm*stepm months)
+ as a weighted average of prlim.
+ */
for(j=nlstate+1,gmp[j]=0.;j<=nlstate+ndeath;j++){
for(i=1; i<= nlstate; i++)
gmp[j] += prlim[i][i]*p3mat[i][j][1];
}
- /* end force of mortality */
+ /* end probability of death */
fprintf(ficresprobmorprev,"%3d %d ",(int) age, ij);
for(j=nlstate+1; j<=(nlstate+ndeath);j++){
fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm);
fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm);
fprintf(fichtm,"\n<br> File (multiple files are possible if covariates are present): <A href=\"%s\">%s</a>\n",fileresprobmorprev,fileresprobmorprev);
- fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"varmuptjgr%s%s.png\"> <br>\n", stepm,digitp,digit);
+ fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"varmuptjgr%s%s.png\"> <br>\n", estepm,digitp,digit);
/* fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months and then divided by estepm and multiplied by %.0f in order to have the probability to die over a year <br> <img src=\"varmuptjgr%s%s.png\"> <br>\n", stepm,YEARM,digitp,digit);
*/
fprintf(ficgp,"\nset out \"varmuptjgr%s%s.png\";replot;",digitp,digit);