--- imach/src/imach.c 2022/05/11 15:11:31 1.316 +++ imach/src/imach.c 2022/05/15 15:06:23 1.317 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.316 2022/05/11 15:11:31 brouard Exp $ +/* $Id: imach.c,v 1.317 2022/05/15 15:06:23 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.317 2022/05/15 15:06:23 brouard + * imach.c (Module): Some minor improvements + Revision 1.316 2022/05/11 15:11:31 brouard Summary: r27 @@ -1183,12 +1186,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.316 2022/05/11 15:11:31 brouard Exp $ */ +/* $Id: imach.c,v 1.317 2022/05/15 15:06:23 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; char copyright[]="May 2022,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020, Nihon University 2021-202, INED 2000-2022"; -char fullversion[]="$Revision: 1.316 $ $Date: 2022/05/11 15:11:31 $"; +char fullversion[]="$Revision: 1.317 $ $Date: 2022/05/15 15:06:23 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -2259,10 +2262,10 @@ void linmin(double p[], double xi[], int #endif #ifdef LINMINORIGINAL #else - if(fb == fx){ /* Flat function in the direction */ - xmin=xx; + if(fb == fx){ /* Flat function in the direction */ + xmin=xx; *flat=1; - }else{ + }else{ *flat=0; #endif /*Flat mnbrak2 shift (*ax=0.000000000000, *fa=51626.272983130431), (*bx=-1.618034000000, *fb=51590.149499362531), (*cx=-4.236068025156, *fc=51590.149499362531) */ @@ -2320,10 +2323,10 @@ void linmin(double p[], double xi[], int /*************** powell ************************/ /* -Minimization of a function func of n variables. Input consists of an initial starting point -p[1..n] ; an initial matrix xi[1..n][1..n] , whose columns contain the initial set of di- -rections (usually the n unit vectors); and ftol , the fractional tolerance in the function value -such that failure to decrease by more than this amount on one iteration signals doneness. On +Minimization of a function func of n variables. Input consists in an initial starting point +p[1..n] ; an initial matrix xi[1..n][1..n] whose columns contain the initial set of di- +rections (usually the n unit vectors); and ftol, the fractional tolerance in the function value +such that failure to decrease by more than this amount in one iteration signals doneness. On output, p is set to the best point found, xi is the then-current direction set, fret is the returned function value at p , and iter is the number of iterations taken. The routine linmin is used. */ @@ -2804,8 +2807,16 @@ void powell(double p[], double **xi, int if(!first){ first=1; printf("Warning: the stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.d years and %d loops. Try to lower 'ftolpl'. Youngest age to start was %d=(%d-%d). Others in log file only...\n", (int)age, maxmax, ftolpl, *ncvyear, ncvloop, (int)(agefin+stepm/YEARM), (int)(age-stepm/YEARM), (int)delaymax); + fprintf(ficlog, "Warning: the stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.d years and %d loops. Try to lower 'ftolpl'. Youngest age to start was %d=(%d-%d).\n", (int)age, maxmax, ftolpl, *ncvyear, ncvloop, (int)(agefin+stepm/YEARM), (int)(age-stepm/YEARM), (int)delaymax); + }else if (first >=1 && first <10){ + fprintf(ficlog, "Warning: the stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.d years and %d loops. Try to lower 'ftolpl'. Youngest age to start was %d=(%d-%d).\n", (int)age, maxmax, ftolpl, *ncvyear, ncvloop, (int)(agefin+stepm/YEARM), (int)(age-stepm/YEARM), (int)delaymax); + first++; + }else if (first ==10){ + fprintf(ficlog, "Warning: the stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.d years and %d loops. Try to lower 'ftolpl'. Youngest age to start was %d=(%d-%d).\n", (int)age, maxmax, ftolpl, *ncvyear, ncvloop, (int)(agefin+stepm/YEARM), (int)(age-stepm/YEARM), (int)delaymax); + printf("Warning: the stable prevalence dit not converge. This warning came too often, IMaCh will stop notifying, even in its log file. Look at the graphs to appreciate the non convergence.\n"); + fprintf(ficlog,"Warning: the stable prevalence no convergence; too many cases, giving up noticing, even in log file\n"); + first++; } - fprintf(ficlog, "Warning: the stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.d years and %d loops. Try to lower 'ftolpl'. Youngest age to start was %d=(%d-%d).\n", (int)age, maxmax, ftolpl, *ncvyear, ncvloop, (int)(agefin+stepm/YEARM), (int)(age-stepm/YEARM), (int)delaymax); /* Try to lower 'ftol', for example from 1.e-8 to 6.e-9.\n", ftolpl, (int)age, (int)delaymax, (int)agefin, ncvloop, (int)age-(int)agefin); */ free_vector(min,1,nlstate); @@ -5327,12 +5338,20 @@ void concatwav(int wav[], int **dh, int #ifdef UNKNOWNSTATUSNOTCONTRIBUTING break; #else - if(s[m][i]==-1 && (int) andc[i] == 9999 && (int)anint[m][i] != 9999){ /* case -2 (vital status unknown is warned later */ + if(s[m][i]==-1 && (int) andc[i] == 9999 && (int)anint[m][i] != 9999){ /* no death date and known date of interview, case -2 (vital status unknown is warned later */ if(firsthree == 0){ printf("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 as 1-p_{%d%d} .\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, s[m][i], nlstate+ndeath); firsthree=1; + }else if(firsthree >=1 && firsthree < 10){ + 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 as 1-p_{%d%d} .\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, s[m][i], nlstate+ndeath); + firsthree++; + }else if(firsthree == 10){ + printf("Information, too many Information flags: no more reported to log either\n"); + fprintf(ficlog,"Information, too many Information flags: no more reported to log either\n"); + firsthree++; + }else{ + firsthree++; } - 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 as 1-p_{%d%d} .\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, s[m][i], nlstate+ndeath); mw[++mi][i]=m; /* Valid transition with unknown status */ mli=m; } @@ -5405,7 +5424,10 @@ void concatwav(int wav[], int **dh, int } /* End individuals */ /* wav and mw are no more changed */ - + printf("Information, you have to check %d informations which haven't been logged!\n",firsthree); + fprintf(ficlog,"Information, you have to check %d informations which haven't been logged!\n",firsthree); + + for(i=1; i<=imx; i++){ for(mi=1; mi
  • Graphs
  • "); + fprintf(fichtm," \n

    "); + fprintf(fichtm," \n"); jj1=0; @@ -7173,11 +7195,47 @@ See page 'Matrix of variance-covariance /* else */ /* fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=%s (instead of .)

    \n",popforecast, stepm, model); */ fflush(fichtm); - fprintf(fichtm,"