/* $Id$
$State$
$Log$
+ Revision 1.215 2015/12/16 08:52:24 brouard
+ Summary: 0.98r4 working
+
Revision 1.214 2015/12/16 06:57:54 brouard
Summary: temporary not working
/* else */
/* lli=log(out[s1][s2] - savm[s1][s2]); */
/* #endif */
- lli=log(out[s1][s2] - savm[s1][s2]);
-
- } else if (s2==-2) {
+ lli=log(out[s1][s2] - savm[s1][s2]);
+
+ } else if ( s2==-1 ) { /* alive */
for (j=1,survp=0. ; j<=nlstate; j++)
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j];
/*survp += out[s1][j]; */
lli= log(survp);
}
-
else if (s2==-4) {
for (j=3,survp=0. ; j<=nlstate; j++)
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j];
lli= log(survp);
}
-
else if (s2==-5) {
for (j=1,survp=0. ; j<=2; j++)
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j];
lli= log(survp);
}
-
else{
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */
/* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */
s2=s[mw[mi+1][i]][i];
if( s2 > nlstate){
lli=log(out[s1][s2] - savm[s1][s2]);
+ } else if ( s2==-1 ) { /* alive */
+ for (j=1,survp=0. ; j<=nlstate; j++)
+ survp += out[s1][j];
+ lli= log(survp);
}else{
lli=log(out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]]); /* Original formula */
}
s1=s[mw[mi][i]][i];
s2=s[mw[mi+1][i]][i];
+ if(s2==-1){
+ printf(" s1=%d, s2=%d i=%d \n", s1, s2, i);
+ /* exit(1); */
+ }
bbh=(double)bh[mi][i]/(double)stepm;
/* bias is positive if real duration
* is higher than the multiple of stepm and negative otherwise.
*/
if( s2 > nlstate && (mle <5) ){ /* Jackson */
lli=log(out[s1][s2] - savm[s1][s2]);
- } else if (s2==-2) {
+ } else if ( s2==-1 ) { /* alive */
for (j=1,survp=0. ; j<=nlstate; j++)
survp += (1.+bbh)*out[s1][j]- bbh*savm[s1][j];
lli= log(survp);
mi=0;
m=firstpass;
while(s[m][i] <= nlstate){ /* a live state */
- if(s[m][i]>=1 || s[m][i]==-2 || s[m][i]==-4 || s[m][i]==-5)
+ if(s[m][i]>=1 || s[m][i]==-4 || s[m][i]==-5){ /* Since 0.98r4 if status=-2 vital status is really unknown, wave should be skipped */
mw[++mi][i]=m;
- if(m >=lastpass)
+ }
+ if(m >=lastpass){
+ if(s[m][i]==-1 && (int) andc[i] == 9999 && (int)anint[m][i] != 9999){
+ printf("Information! Unknown health status for individual %ld line=%d occurred at last wave %d at known date %d/%d. Please, check if your unknown date of death %d/%d means a live state %d at wave %d. This case(%d)/wave(%d) contributes to the likelihood.\nOthers in log file only\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], (int) moisdc[i], (int) andc[i], s[m][i], m, i, m);
+ fprintf(ficlog,"Information! Unknown status for individual %ld line=%d occurred at last wave %d at known date %d/%d. Please, check if your unknown date of death %d/%d means a live state %d at wave %d. This case(%d)/wave(%d) contributes to the likelihood.\nOthers in log file only\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], (int) moisdc[i], (int) andc[i], s[m][i], m, i, m);
+ mw[++mi][i]=m;
+ }
+ if(s[m][i]==-2){ /* Vital status is really unknown */
+ nbwarn++;
+ if((int)anint[m][i] == 9999){ /* Has the vital status really been verified? */
+ printf("Warning! Vital status for individual %ld (line=%d) at last wave %d interviewed at date %d/%d is unknown %d. Please, check if the vital status and the date of death %d/%d are really unknown. This case (%d)/wave (%d) is skipped, no contribution to likelihood.\nOthers in log file only\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], s[m][i], (int) moisdc[i], (int) andc[i], i, m);
+ fprintf(ficlog,"Warning! Vital status for individual %ld (line=%d) at last wave %d interviewed at date %d/%d is unknown %d. Please, check if the vital status and the date of death %d/%d are really unknown. This case (%d)/wave (%d) is skipped, no contribution to likelihood.\nOthers in log file only\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], s[m][i], (int) moisdc[i], (int) andc[i], i, m);
+ }
+ break;
+ }
break;
+ }
else
m++;
}/* end while */
+
+ /* After last pass */
if (s[m][i] > nlstate){ /* In a death state */
mi++; /* Death is another wave */
/* if(mi==0) never been interviewed correctly before death */
/* Only death is a correct wave */
mw[mi][i]=m;
- }else if (andc[i] != 9999) { /* A death occured after lastpass */
- m++;
- mi++;
- s[m][i]=nlstate+1; /* We are setting the status to the last of non live state */
- mw[mi][i]=m;
- nbwarn++;
+ }else if ((int) andc[i] != 9999) { /* Status is either death or negative. A death occured after lastpass, we can't take it into account because of potential bias */
+ /* m++; */
+ /* mi++; */
+ /* s[m][i]=nlstate+1; /\* We are setting the status to the last of non live state *\/ */
+ /* mw[mi][i]=m; */
+ nberr++;
if(firstwo==0){
- printf("Warning! Death for individual %ld line=%d occurred after last wave %d. Since 0.98r4 we considered a status %d at wave %d\nOthers in log file only\n",num[i],i,lastpass,nlstate+1, m);
- fprintf(ficlog,"Warning! Death for individual %ld line=%d occurred after last wave %d. Since 0.98r4 we considered a status %d at wave %d\n",num[i],i,lastpass,nlstate+1, m);
+ printf("Error! Death for individual %ld line=%d occurred %d/%d after last wave %d interviewed at %d/%d. Potential bias if other individuals are still alive at this date but ignored. This case (%d)/wave (%d) is skipped, no contribution to likelihood.\nOthers in log file only\n",num[i],i,(int) moisdc[i], (int) andc[i], lastpass,(int)mint[m][i],(int)anint[m][i], i,m );
+ fprintf(ficlog,"Error! Death for individual %ld line=%d occurred %d/%d after last wave %d interviewed at %d/%d. Potential bias if other individuals are still alive at this date but ignored. This case (%d)/wave (%d) is skipped, no contribution to likelihood.\nOthers in log file only\n",num[i],i,(int) moisdc[i], (int) andc[i], lastpass,(int)mint[m][i],(int)anint[m][i], i,m );
firstwo=1;
- }
- if(firstwo==1){
- fprintf(ficlog,"Warning! Death for individual %ld line=%d occurred after last wave %d. Since 0.98r4 we considered a status %d at wave %d\n",num[i],i,lastpass,nlstate+1, m);
+ }else if(firstwo==1){
+ fprintf(ficlog,"Error! Death for individual %ld line=%d occurred %d/%d after last wave %d interviewed at %d/%d. Potential bias if other individuals are still alive at this date but ignored. This case (%d)/wave (%d) is skipped, no contribution to likelihood.\nOthers in log file only\n",num[i],i,(int) moisdc[i], (int) andc[i], lastpass,(int)mint[m][i],(int)anint[m][i], i,m );
}
}
wav[i]=mi;
for(m=2; (m<= maxwav); m++) {
if (((int)mint[m][i]== 99) && (s[m][i] <= nlstate)){
anint[m][i]=9999;
- s[m][i]=-1;
+ if (s[m][i] != -2) /* Keeping initial status of unknown vital status */
+ s[m][i]=-1;
}
if((int)moisdc[i]==99 && (int)andc[i]==9999 && s[m][i]>nlstate){
*nberr = *nberr + 1;
if((nberr >0) || (nbwarn>0)){
- printf("End of Imach with %d errors and/or %d warnings\n",nberr,nbwarn);
- fprintf(ficlog,"End of Imach with %d errors and/or warnings %d\n",nberr,nbwarn);
+ printf("End of Imach with %d errors and/or %d warnings. Please look at the log file for details.\n",nberr,nbwarn);
+ fprintf(ficlog,"End of Imach with %d errors and/or warnings %d. Please look at the log file for details.\n",nberr,nbwarn);
}else{
printf("End of Imach\n");
fprintf(ficlog,"End of Imach\n");