--- imach/src/imach.c 2022/03/17 08:45:53 1.310
+++ imach/src/imach.c 2022/05/15 15:06:23 1.317
@@ -1,6 +1,33 @@
-/* $Id: imach.c,v 1.310 2022/03/17 08:45:53 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
+
+ Revision 1.315 2022/05/11 15:06:32 brouard
+ *** empty log message ***
+
+ Revision 1.314 2022/04/13 17:43:09 brouard
+ * imach.c (Module): Adding link to text data files
+
+ Revision 1.313 2022/04/11 15:57:42 brouard
+ * imach.c (Module): Error in rewriting the 'r' file with yearsfproj or yearsbproj fixed
+
+ Revision 1.312 2022/04/05 21:24:39 brouard
+ *** empty log message ***
+
+ Revision 1.311 2022/04/05 21:03:51 brouard
+ Summary: Fixed quantitative covariates
+
+ Fixed covariates (dummy or quantitative)
+ with missing values have never been allowed but are ERRORS and
+ program quits. Standard deviations of fixed covariates were
+ wrongly computed. Mean and standard deviations of time varying
+ covariates are still not computed.
+
Revision 1.310 2022/03/17 08:45:53 brouard
Summary: 99r25
@@ -1159,12 +1186,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.310 2022/03/17 08:45:53 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[]="March 2021,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, INED 2000-2021";
-char fullversion[]="$Revision: 1.310 $ $Date: 2022/03/17 08:45:53 $";
+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.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 */
@@ -1862,7 +1889,9 @@ char *subdirf(char fileres[])
/*************** function subdirf2 ***********/
char *subdirf2(char fileres[], char *preop)
{
-
+ /* Example subdirf2(optionfilefiname,"FB_") with optionfilefiname="texte", result="texte/FB_texte"
+ Errors in subdirf, 2, 3 while printing tmpout is
+ rewritten within the same printf. Workaround: many printfs */
/* Caution optionfilefiname is hidden */
strcpy(tmpout,optionfilefiname);
strcat(tmpout,"/");
@@ -2233,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) */
@@ -2294,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.
*/
@@ -2778,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);
@@ -3847,7 +3884,7 @@ double funcone( double *x)
/* Fixed */
/* for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i]; */
/* for (k=1; k<=ncoveff;k++){ /\* Simple and product fixed Dummy covariates without age* products *\/ */
- for (k=1; k<=ncovf;k++){ /* Simple and product fixed covariates without age* products */
+ for (k=1; k<=ncovf;k++){ /* Simple and product fixed covariates without age* products *//* Missing values are set to -1 but should be dropped */
cov[ioffset+TvarFind[k]]=covar[Tvar[TvarFind[k]]][i];/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, only V1 is fixed (k=6)*/
/* cov[ioffset+TvarFind[1]]=covar[Tvar[TvarFind[1]]][i]; */
/* cov[2+6]=covar[Tvar[6]][i]; */
@@ -4702,10 +4739,13 @@ Title=%s
Datafile=%s Firstpass=%d La
if(s[m][iind]==-1)
printf(" num=%ld m=%d, iind=%d s1=%d s2=%d agev at m=%d agebegin=%.2f ageend=%.2f, agemed=%d\n", num[iind], m, iind,s[m][iind],s[m+1][iind], (int)agev[m][iind],agebegin, ageend, (int)((agebegin+ageend)/2.));
freq[s[m][iind]][s[m+1][iind]][(int)agev[m][iind]] += weight[iind]; /* At age of beginning of transition, where status is known */
- for (z1=1; z1<= nqfveff; z1++) { /* Quantitative variables, calculating mean */
- idq[z1]=idq[z1]+weight[iind];
- meanq[z1]+=covar[ncovcol+z1][iind]*weight[iind]; /* Computes mean of quantitative with selected filter */
- stdq[z1]+=covar[ncovcol+z1][iind]*covar[ncovcol+z1][iind]*weight[iind]*weight[iind]; /* *weight[iind];*/ /* Computes mean of quantitative with selected filter */
+ for (z1=1; z1<= nqfveff; z1++) { /* Quantitative variables, calculating mean on known values only */
+ if(!isnan(covar[ncovcol+z1][iind])){
+ idq[z1]=idq[z1]+weight[iind];
+ meanq[z1]+=covar[ncovcol+z1][iind]*weight[iind]; /* Computes mean of quantitative with selected filter */
+ /* stdq[z1]+=covar[ncovcol+z1][iind]*covar[ncovcol+z1][iind]*weight[iind]*weight[iind]; *//*error*/
+ stdq[z1]+=covar[ncovcol+z1][iind]*covar[ncovcol+z1][iind]*weight[iind]; /* *weight[iind];*/ /* Computes mean of quantitative with selected filter */
+ }
}
/* if((int)agev[m][iind] == 55) */
/* printf("j=%d, j1=%d Age %d, iind=%d, num=%09ld m=%d\n",j,j1,(int)agev[m][iind],iind, num[iind],m); */
@@ -4768,16 +4808,19 @@ Title=%s
Datafile=%s Firstpass=%d La
Printing means of quantitative variables if any
*/
for (z1=1; z1<= nqfveff; z1++) {
- fprintf(ficlog,"Mean of fixed quantitative variable V%d on %.0f individuals sum=%f", ncovcol+z1, idq[z1], meanq[z1]);
+ fprintf(ficlog,"Mean of fixed quantitative variable V%d on %.3g (weighted) individuals sum=%f", ncovcol+z1, idq[z1], meanq[z1]);
fprintf(ficlog,", mean=%.3g\n",meanq[z1]/idq[z1]);
if(weightopt==1){
printf(" Weighted mean and standard deviation of");
fprintf(ficlog," Weighted mean and standard deviation of");
fprintf(ficresphtmfr," Weighted mean and standard deviation of");
}
- printf(" fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1]));
- fprintf(ficlog," fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1]));
- fprintf(ficresphtmfr," fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)
\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1])); + /* mu = \frac{w x}{\sum w} + var = \frac{\sum w (x-mu)^2}{\sum w} = \frac{w x^2}{\sum w} - mu^2 + */ + printf(" fixed quantitative variable V%d on %.3g (weighted) representatives of the population : %8.5g (%8.5g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt(stdq[z1]/idq[z1]-meanq[z1]*meanq[z1]/idq[z1]/idq[z1])); + fprintf(ficlog," fixed quantitative variable V%d on %.3g (weighted) representatives of the population : %8.5g (%8.5g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt(stdq[z1]/idq[z1]-meanq[z1]*meanq[z1]/idq[z1]/idq[z1])); + fprintf(ficresphtmfr," fixed quantitative variable V%d on %.3g (weighted) representatives of the population : %8.5g (%8.5g)
\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt(stdq[z1]/idq[z1]-meanq[z1]*meanq[z1]/idq[z1]/idq[z1]));
}
/* for (z1=1; z1<= nqtveff; z1++) { */
/* for(m=1;m<=lastpass;m++){ */
@@ -5295,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;
}
@@ -5373,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 ");
+ fprintf(fichtm," \n ");
jj1=0;
@@ -6975,7 +7043,7 @@ void printinghtml(char fileresu[], char
fprintf(fichtm,"");
} /* cptcovn >0 */
}
- fprintf(fichtm," \n ");
m=pow(2,cptcoveff);
if (cptcovn < 1) {m=1;ncodemax[1]=1;}
+ fprintf(fichtm," ");
+
+ jj1=0;
+
+ fprintf(fichtm," \n ");
+
fprintf(fichtm,"
");
jj1=0;
@@ -7054,8 +7122,10 @@ divided by h: hPij
if(prevfcast==1){
/* Projection of prevalence up to period (forward stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"
");
+ fprintf(fichtm," \n
\n- Projection of cross-sectional prevalence (estimated with cases observed from %.1f to %.1f and mobil_average=%d), from year %.1f up to year %.1f tending to period (stable) forward prevalence in state %d. Or probability to be in state %d being in an observed weighted state (from 1 to %d). %s_%d-%d-%d.svg
\
-", dateprev1, dateprev2, mobilavproj, dateprojd, dateprojf, cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres);
+ fprintf(fichtm,"
\n- Projection of cross-sectional prevalence (estimated with cases observed from %.1f to %.1f and mobil_average=%d), from year %.1f up to year %.1f tending to period (stable) forward prevalence in state %d. Or probability to be in state %d being in an observed weighted state (from 1 to %d). %s_%d-%d-%d.svg", dateprev1, dateprev2, mobilavproj, dateprojd, dateprojf, cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"F_"),subdirf2(optionfilefiname,"F_"));
+ fprintf(fichtm,"",
+ subdirf2(optionfilefiname,"PROJ_"),cpt,k1,nres);
}
}
if(prevbcast==1){
@@ -7064,14 +7134,16 @@ divided by h: hPij
fprintf(fichtm,"
\n- Back projection of cross-sectional prevalence (estimated with cases observed from %.1f to %.1f and mobil_average=%d), \
from year %.1f up to year %.1f (probably close to stable [mixed] back prevalence in state %d (randomness in cross-sectional prevalence is not taken into \
account but can visually be appreciated). Or probability to have been in an state %d, knowing that the person was in either state (1 or %d) \
-with weights corresponding to observed prevalence at different ages. %s_%d-%d-%d.svg
\
- ", dateprev1, dateprev2, mobilavproj, dateback1, dateback2, cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres);
+with weights corresponding to observed prevalence at different ages. %s_%d-%d-%d.svg", dateprev1, dateprev2, mobilavproj, dateback1, dateback2, cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"FB_"),subdirf2(optionfilefiname,"FB_"));
+ fprintf(fichtm," ", subdirf2(optionfilefiname,"PROJB_"),cpt,k1,nres);
}
}
for(cpt=1; cpt<=nlstate;cpt++) {
- fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) (or area under each survival functions): %s_%d-%d-%d.svg
\
-",cpt,nlstate,subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres,subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres,subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres);
+ fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) (or area under each survival functions): %s_%d-%d-%d.svg",cpt,nlstate,subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres,subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"E_"),subdirf2(optionfilefiname,"E_"));
+ fprintf(fichtm,"", subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres );
}
/* } /\* end i1 *\/ */
}/* End k1 */
@@ -7123,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," ");
+ for(nres=1; nres <= nresult; nres++) /* For each resultline */
+ for(k1=1; k1<=m;k1++){ /* For each combination of covariate */
+ if(m != 1 && TKresult[nres]!= k1)
+ continue;
+ jj1++;
+ if (cptcovn > 0) {
+ fprintf(fichtm,"\n
");
+
jj1=0;
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
@@ -7137,10 +7245,21 @@ See page 'Matrix of variance-covariance
/* for(i1=1; i1<=ncodemax[k1];i1++){ */
jj1++;
if (cptcovn > 0) {
+ fprintf(fichtm,"\n
************ Results for covariates");
- for (cpt=1; cpt<=cptcoveff;cpt++) /**< cptcoveff number of variables */
+ for (cpt=1; cpt<=cptcoveff;cpt++){ /**< cptcoveff number of variables */
fprintf(fichtm," V%d=%d ",Tvresult[nres][cpt],Tresult[nres][cpt]);
+ printf(" V%d=%d ",Tvresult[nres][cpt],Tresult[nres][cpt]);fflush(stdout);
/* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */
+ }
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
fprintf(fichtm," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
}
@@ -7154,15 +7273,17 @@ See page 'Matrix of variance-covariance
}
for(cpt=1; cpt<=nlstate;cpt++) {
fprintf(fichtm,"\n
- Observed (cross-sectional with mov_average=%d) and period (incidence based) \
-prevalence (with 95%% confidence interval) in state (%d): %s_%d-%d-%d.svg\n
\
-",mobilav,cpt,subdirf2(optionfilefiname,"V_"),cpt,k1,nres,subdirf2(optionfilefiname,"V_"),cpt,k1,nres,subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
+prevalence (with 95%% confidence interval) in state (%d): %s_%d-%d-%d.svg",mobilav,cpt,subdirf2(optionfilefiname,"V_"),cpt,k1,nres,subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s)\n
",subdirf2(fileresu,"VPL_"),subdirf2(fileresu,"VPL_"));
+ fprintf(fichtm,"",subdirf2(optionfilefiname,"V_"), cpt,k1,nres);
}
fprintf(fichtm,"\n
- Total life expectancy by age and \
-health expectancies in states (1) and (2). If popbased=1 the smooth (due to the model) \
+health expectancies in each live states (1 to %d). If popbased=1 the smooth (due to the model) \
true period expectancies (those weighted with period prevalences are also\
drawn in addition to the population based expectancies computed using\
- observed and cahotic prevalences: %s_%d-%d.svg\n
\
-",subdirf2(optionfilefiname,"E_"),k1,nres,subdirf2(optionfilefiname,"E_"),k1,nres,subdirf2(optionfilefiname,"E_"),k1,nres);
+ observed and cahotic prevalences: %s_%d-%d.svg",nlstate, subdirf2(optionfilefiname,"E_"),k1,nres,subdirf2(optionfilefiname,"E_"),k1,nres);
+ fprintf(fichtm," (data from text file %s.txt) \n
",subdirf2(optionfilefiname,"T_"),subdirf2(optionfilefiname,"T_"));
+ fprintf(fichtm,"",subdirf2(optionfilefiname,"E_"),k1,nres);
/* } /\* end i1 *\/ */
}/* End k1 */
}/* End nres */
@@ -9507,6 +9628,8 @@ int readdata(char datafile[], int firsto
cutv(stra, strb, line, ' ');
if(strb[0]=='.') { /* Missing value */
lval=-1;
+ coqvar[iv][i]=NAN;
+ covar[ncovcol+iv][i]=NAN; /* including qvar in standard covar for performance reasons */
}else{
errno=0;
/* what_kind_of_number(strb); */
@@ -10980,7 +11103,8 @@ int main(int argc, char *argv[])
double ftolpl=FTOL;
double **prlim;
double **bprlim;
- double ***param; /* Matrix of parameters */
+ double ***param; /* Matrix of parameters, param[i][j][k] param=ma3x(1,nlstate,1,nlstate+ndeath-1,1,ncovmodel)
+ state of origin, state of destination including death, for each covariate: constante, age, and V1 V2 etc. */
double ***paramstart; /* Matrix of starting parameter values */
double *p, *pstart; /* p=param[1][1] pstart is for starting values guessed by freqsummary */
double **matcov; /* Matrix of covariance */
@@ -11907,7 +12031,7 @@ Title=%s
Datafile=%s Firstpass=%d La
", subdirf2(optionfilefiname,"D_"),subdirf2(optionfilefiname,"D_"),subdirf2(optionfilefiname,"D_"));
- fprintf(fichtm,"\nSome descriptive statistics
\n
Total number of observations=%d
\n\
+ fprintf(fichtm,"\nSome descriptive statistics
\n
Number of (used) observations=%d
\n\
Youngest age at first (selected) pass %.2f, oldest age %.2f
\n\
Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf
\n",\
imx,agemin,agemax,jmin,jmax,jmean);
@@ -12478,9 +12602,9 @@ Please run with mle=-1 to get a correct
prvforecast = 1;
}
else if((num_filled=sscanf(line,"prevforecast=%d yearsfproj=%lf mobil_average=%d\n",&prevfcast,&yrfproj,&mobilavproj)) !=EOF){/* && (num_filled == 3))*/
- printf("prevforecast=%d yearsfproj=%lf.2 mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
- fprintf(ficlog,"prevforecast=%d yearsfproj=%lf.2 mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
- fprintf(ficres,"prevforecast=%d yearsfproj=%lf.2 mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
+ printf("prevforecast=%d yearsfproj=%.2lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
+ fprintf(ficlog,"prevforecast=%d yearsfproj=%.2lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
+ fprintf(ficres,"prevforecast=%d yearsfproj=%.2lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
prvforecast = 2;
}
else {
@@ -12501,9 +12625,9 @@ Please run with mle=-1 to get a correct
prvbackcast = 1;
}
else if((num_filled=sscanf(line,"prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",&prevbcast,&yrbproj,&mobilavproj)) ==3){/* && (num_filled == 3))*/
- printf("prevbackcast=%d yearsbproj=%lf.2 mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
- fprintf(ficlog,"prevbackcast=%d yearsbproj=%lf.2 mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
- fprintf(ficres,"prevbackcast=%d yearsbproj=%lf.2 mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
+ printf("prevbackcast=%d yearsbproj=%.2lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
+ fprintf(ficlog,"prevbackcast=%d yearsbproj=%.2lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
+ fprintf(ficres,"prevbackcast=%d yearsbproj=%.2lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
prvbackcast = 2;
}
else {
@@ -12522,15 +12646,19 @@ Please run with mle=-1 to get a correct
goto end;
}
if(!decoderesult(resultline, nresult)){ /* Fills TKresult[nresult] combination and Tresult[nresult][k4+1] combination values */
- fprintf(ficparo,"result: %s\n",resultline);
- fprintf(ficres,"result: %s\n",resultline);
- fprintf(ficlog,"result: %s\n",resultline);
+ fprintf(ficparo,"result: %s\n",resultline);
+ fprintf(ficres,"result: %s\n",resultline);
+ fprintf(ficlog,"result: %s\n",resultline);
} else
goto end;
break;
case 14:
printf("Error: Unknown command '%s'\n",line);
fprintf(ficlog,"Error: Unknown command '%s'\n",line);
+ if(line[0] == ' ' || line[0] == '\n'){
+ printf("It should not be an empty line '%s'\n",line);
+ fprintf(ficlog,"It should not be an empty line '%s'\n",line);
+ }
if(ncovmodel >=2 && nresult==0 ){
printf("ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line);
fprintf(ficlog,"ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line);