--- imach/src/imach.c 2004/07/12 18:29:06 1.100 +++ imach/src/imach.c 2004/09/15 10:38:38 1.101 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.100 2004/07/12 18:29:06 brouard Exp $ +/* $Id: imach.c,v 1.101 2004/09/15 10:38:38 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.101 2004/09/15 10:38:38 brouard + Fix on curr_time + Revision 1.100 2004/07/12 18:29:06 brouard Add version for Mac OS X. Just define UNIX in Makefile @@ -238,11 +241,11 @@ #define ODIRSEPARATOR '/' #endif -/* $Id: imach.c,v 1.100 2004/07/12 18:29:06 brouard Exp $ */ +/* $Id: imach.c,v 1.101 2004/09/15 10:38:38 brouard Exp $ */ /* $State: Exp $ */ char version[]="Imach version 0.97b, May 2004, INED-EUROREVES "; -char fullversion[]="$Revision: 1.100 $ $Date: 2004/07/12 18:29:06 $"; +char fullversion[]="$Revision: 1.101 $ $Date: 2004/09/15 10:38:38 $"; int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ int nvar; int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov; @@ -879,11 +882,11 @@ void powell(double p[], double **xi, int 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); @@ -895,8 +898,8 @@ void powell(double p[], double **xi, int 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++) { @@ -1235,14 +1238,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. @@ -1250,15 +1253,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