]> henry.ined.fr Git - .git/commitdiff
Fix on curr_time
authorN. Brouard <brouard@ined.fr>
Wed, 15 Sep 2004 10:38:38 +0000 (10:38 +0000)
committerN. Brouard <brouard@ined.fr>
Wed, 15 Sep 2004 10:38:38 +0000 (10:38 +0000)
src/imach.c

index e6b4a9b6c88a0f4e47c29d6278e5ed0ccc76d0a5..936d26dfac674fc73ea19756a8b1eba01e25d0ad 100644 (file)
@@ -1,6 +1,9 @@
 /* $Id$
   $State$
   $Log$
+  Revision 1.100  2004/07/12 18:29:06  brouard
+  Add version for Mac OS X. Just define UNIX in Makefile
+
   Revision 1.99  2004/06/05 08:57:40  brouard
   *** empty log message ***
 
@@ -876,11 +879,11 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret
     fprintf(ficrespow,"\n");fflush(ficrespow);
     if(*iter <=3){
       tm = *localtime(&curr_time.tv_sec);
-      strcpy(strcurr,asctime(&tmf));
+      strcpy(strcurr,asctime(&tm));
 /*       asctime_r(&tm,strcurr); */
-      forecast_time=curr_time;
+      forecast_time=curr_time; 
       itmp = strlen(strcurr);
-      if(strcurr[itmp-1]=='\n')
+      if(strcurr[itmp-1]=='\n')  /* Windows outputs with a new line */
        strcurr[itmp-1]='\0';
       printf("\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,curr_time.tv_sec-last_time.tv_sec);
       fprintf(ficlog,"\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,curr_time.tv_sec-last_time.tv_sec);
@@ -892,8 +895,8 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret
        itmp = strlen(strfor);
        if(strfor[itmp-1]=='\n')
        strfor[itmp-1]='\0';
-       printf("   - if your program needs %d iterations to converge, convergence will be \n   reached in %s or\n   on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
-       fprintf(ficlog,"   - if your program needs %d iterations to converge, convergence will be \n   reached in %s or\n   on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
+       printf("   - if your program needs %d iterations to converge, convergence will be \n   reached in %s i.e.\n   on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
+       fprintf(ficlog,"   - if your program needs %d iterations to converge, convergence will be \n   reached in %s i.e.\n   on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
       }
     }
     for (i=1;i<=n;i++) { 
@@ -1232,14 +1235,14 @@ double func( double *x)
        } /* end mult */
       
        /*lli=log(out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]]);*/ /* Original formula */
-       /* But now since version 0.9 we anticipate for bias and large stepm.
+       /* But now since version 0.9 we anticipate for bias at large stepm.
         * If stepm is larger than one month (smallest stepm) and if the exact delay 
         * (in months) between two waves is not a multiple of stepm, we rounded to 
         * the nearest (and in case of equal distance, to the lowest) interval but now
         * we keep into memory the bias bh[mi][i] and also the previous matrix product
-        * (i.e to dh[mi][i]-1) saved in 'savm'. The we inter(extra)polate the
+        * (i.e to dh[mi][i]-1) saved in 'savm'. Then we inter(extra)polate the
         * probability in order to take into account the bias as a fraction of the way
-        * from savm to out if bh is neagtive or even beyond if bh is positive. bh varies
+        * from savm to out if bh is negative or even beyond if bh is positive. bh varies
         * -stepm/2 to stepm/2 .
         * For stepm=1 the results are the same as for previous versions of Imach.
         * For stepm > 1 the results are less biased than in previous versions. 
@@ -1247,15 +1250,15 @@ double func( double *x)
        s1=s[mw[mi][i]][i];
        s2=s[mw[mi+1][i]][i];
        bbh=(double)bh[mi][i]/(double)stepm; 
-       /* bias is positive if real duration
+       /* bias bh is positive if real duration
         * is higher than the multiple of stepm and negative otherwise.
         */
        /* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/
        if( s2 > nlstate){ 
          /* i.e. if s2 is a death state and if the date of death is known then the contribution
             to the likelihood is the probability to die between last step unit time and current 
-            step unit time, which is also the differences between probability to die before dh 
-            and probability to die before dh-stepm . 
+            step unit time, which is also equal to probability to die before dh 
+            minus probability to die before dh-stepm . 
             In version up to 0.92 likelihood was computed
        as if date of death was unknown. Death was treated as any other
        health state: the date of the interview describes the actual state