--- imach/src/imach.c 2015/12/16 08:52:24 1.215 +++ imach/src/imach.c 2015/12/18 17:32:11 1.216 @@ -1,6 +1,14 @@ -/* $Id: imach.c,v 1.215 2015/12/16 08:52:24 brouard Exp $ +/* $Id: imach.c,v 1.216 2015/12/18 17:32:11 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.216 2015/12/18 17:32:11 brouard + Summary: 0.98r4 Warning and status=-2 + + Version 0.98r4 is now: + - displaying an error when status is -1, date of interview unknown and date of death known; + - permitting a status -2 when the vital status is unknown at a known date of right truncation. + Older changes concerning s=-2, dating from 2005 have been supersed. + Revision 1.215 2015/12/16 08:52:24 brouard Summary: 0.98r4 working @@ -792,12 +800,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.215 2015/12/16 08:52:24 brouard Exp $ */ +/* $Id: imach.c,v 1.216 2015/12/18 17:32:11 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; char copyright[]="October 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; -char fullversion[]="$Revision: 1.215 $ $Date: 2015/12/16 08:52:24 $"; +char fullversion[]="$Revision: 1.216 $ $Date: 2015/12/18 17:32:11 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -2446,27 +2454,24 @@ double func( double *x) /* 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 */ @@ -2578,6 +2583,10 @@ double func( double *x) 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 */ } @@ -2685,13 +2694,17 @@ double funcone( double *x) 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); @@ -3613,31 +3626,47 @@ void concatwav(int wav[], int **dh, int 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; @@ -6625,7 +6654,8 @@ int calandcheckages(int imx, int maxwav, 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; @@ -8784,8 +8814,8 @@ Please run with mle=-1 to get a correct 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");