]> henry.ined.fr Git - .git/commitdiff
Summary: 0.98r4 Warning and status=-2
authorN. Brouard <brouard@ined.fr>
Fri, 18 Dec 2015 17:32:11 +0000 (17:32 +0000)
committerN. Brouard <brouard@ined.fr>
Fri, 18 Dec 2015 17:32:11 +0000 (17:32 +0000)
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.

src/imach.c

index ea1c8f5a6242bb88e67a1d48b3d52790a3719864..ee292ffc3bc1004e68f5b4e9318075fde6cf9d4b 100644 (file)
@@ -1,6 +1,9 @@
 /* $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
 
@@ -2443,27 +2446,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 */
@@ -2575,6 +2575,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 */
        }
@@ -2682,13 +2686,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);
@@ -3610,31 +3618,47 @@ void  concatwav(int wav[], int **dh, int **bh,  int **mw, int **s, double *agedc
     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;
@@ -6622,7 +6646,8 @@ int calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nb
     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;
@@ -8781,8 +8806,8 @@ Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpa
   
 
   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");