- Graphs
");
@@ -4552,6 +4624,7 @@ int main(int argc, char *argv[])
free_ma3x(delti3,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel);
fclose (ficparo);
fclose (ficlog);
+ goto end;
exit(0);
}
else if(mle==-3) {
@@ -4582,7 +4655,9 @@ int main(int argc, char *argv[])
j++;
fscanf(ficpar,"%1d%1d",&i1,&j1);
if ((i1 != i) && (j1 != j)){
- printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n",numlinepar, i,j, i1, j1);
+ printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \
+It might be a problem of design; if ncovcol and the model are correct\n \
+run imach with mle=-1 to get a correct template of the parameter file.\n",numlinepar, i,j, i1, j1);
exit(1);
}
fprintf(ficparo,"%1d%1d",i1,j1);
@@ -4806,12 +4881,12 @@ int main(int argc, char *argv[])
cutv(stra, strb,line,' ');
errno=0;
- lval=strtol(strb,&endptr,10);
+ dval=strtod(strb,&endptr);
if( strb[0]=='\0' || (*endptr != '\0')){
- printf("Error reading data around '%d' at line number %ld %s for individual %d\nShould be a weight. Exiting.\n",lval, i,line,linei);
+ printf("Error reading data around '%f' at line number %ld, \"%s\" for individual %d\nShould be a weight. Exiting.\n",dval, i,line,linei);
exit(1);
}
- weight[i]=(double)(lval);
+ weight[i]=dval;
strcpy(line,stra);
for (j=ncovcol;j>=1;j--){
@@ -4823,7 +4898,15 @@ int main(int argc, char *argv[])
exit(1);
}
if(lval <-1 || lval >1){
- printf("Error reading data around '%d' at line number %ld %s for individual %d, '%s'\nShould be a value of the %d covar (meaning 0 for the reference or 1. IMaCh does not build design variables, do it your self). Exiting.\n",lval,linei, i,line,j);
+ printf("Error reading data around '%d' at line number %ld for individual %d, '%s'\n \
+ Should be a value of %d(nth) covariate (0 should be the value for the reference and 1\n \
+ for the alternative. IMaCh does not build design variables automatically, do it yourself.\n \
+ For example, for multinomial values like 1, 2 and 3,\n \
+ build V1=0 V2=0 for the reference value (1),\n \
+ V1=1 V2=0 for (2) \n \
+ and V1=0 V2=1 for (3). V1=1 V2=1 should not exist and the corresponding\n \
+ output of IMaCh is often meaningless.\n \
+ Exiting.\n",lval,linei, i,line,j);
exit(1);
}
covar[j][i]=(double)(lval);
@@ -5119,13 +5202,13 @@ int main(int argc, char *argv[])
printf("Problem with %s \n",optionfilehtmcov), exit(0);
}
else{
- fprintf(fichtmcov,"
\nIMaCh Cov %s\n %s
%s \
+ fprintf(fichtmcov,"\nIMaCh Cov %s\n %s
%s \
\n\
Title=%s
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s
\n",\
- fileres,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model);
+ optionfilehtmcov,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model);
}
- fprintf(fichtm,"\nIMaCh %s\n %s
%s \
+ fprintf(fichtm,"\nIMaCh %s\n %s
%s \
\n\
Title=%s
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s
\n\
\n\
@@ -5136,7 +5219,7 @@ Title=%s
Datafile=%s Firstpass=%d La
- Log file of the run: %s
\n\
- Gnuplot file name: %s
\n\
- Date and time at start: %s
\n",\
- fileres,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model,\
+ optionfilehtm,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model,\
optionfilefiname,optionfilext,optionfilefiname,optionfilext,\
fileres,fileres,\
filelog,filelog,optionfilegnuplot,optionfilegnuplot,strstart);
@@ -5319,9 +5402,9 @@ Interval (in months) between two waves:
fprintf(ficlog,"%d%d ",i,k);
fprintf(ficres,"%1d%1d ",i,k);
for(j=1; j <=ncovmodel; j++){
- printf("%f ",p[jk]);
- fprintf(ficlog,"%f ",p[jk]);
- fprintf(ficres,"%f ",p[jk]);
+ printf("%lf ",p[jk]);
+ fprintf(ficlog,"%lf ",p[jk]);
+ fprintf(ficres,"%lf ",p[jk]);
jk++;
}
printf("\n");
@@ -5668,18 +5751,24 @@ Interval (in months) between two waves:
}
- /*---------- Health expectancies and variances ------------*/
+ /* Computes prevalence between agemin (i.e minimal age computed) and no more ageminpar */
- strcpy(filerest,"t");
- strcat(filerest,fileres);
- if((ficrest=fopen(filerest,"w"))==NULL) {
- printf("Problem with total LE resultfile: %s\n", filerest);goto end;
- fprintf(ficlog,"Problem with total LE resultfile: %s\n", filerest);goto end;
+ prevalence(probs, agemin, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass);
+ /* printf("ageminpar=%f, agemax=%f, s[lastpass][imx]=%d, agev[lastpass][imx]=%f, nlstate=%d, imx=%d, mint[lastpass][imx]=%f, anint[lastpass][imx]=%f,dateprev1=%f, dateprev2=%f, firstpass=%d, lastpass=%d\n",\
+ ageminpar, agemax, s[lastpass][imx], agev[lastpass][imx], nlstate, imx, mint[lastpass][imx],anint[lastpass][imx], dateprev1, dateprev2, firstpass, lastpass);
+ */
+
+ if (mobilav!=0) {
+ mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
+ if (movingaverage(probs, bage, fage, mobaverage,mobilav)!=0){
+ fprintf(ficlog," Error in movingaverage mobilav=%d\n",mobilav);
+ printf(" Error in movingaverage mobilav=%d\n",mobilav);
+ }
}
- printf("Computing Total Life expectancies with their standard errors: file '%s' \n", filerest);
- fprintf(ficlog,"Computing Total Life expectancies with their standard errors: file '%s' \n", filerest);
+ /*---------- Health expectancies, no variances ------------*/
+
strcpy(filerese,"e");
strcat(filerese,fileres);
if((ficreseij=fopen(filerese,"w"))==NULL) {
@@ -5688,6 +5777,37 @@ Interval (in months) between two waves:
}
printf("Computing Health Expectancies: result on file '%s' \n", filerese);
fprintf(ficlog,"Computing Health Expectancies: result on file '%s' \n", filerese);
+ for(cptcov=1,k=0;cptcov<=i1;cptcov++){
+ for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){
+ k=k+1;
+ fprintf(ficreseij,"\n#****** ");
+ for(j=1;j<=cptcoveff;j++) {
+ fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
+ }
+ fprintf(ficreseij,"******\n");
+
+ eij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage);
+ oldm=oldms;savm=savms;
+ evsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, strstart);
+
+ free_ma3x(eij,1,nlstate,1,nlstate,(int) bage, (int)fage);
+ }
+ }
+ fclose(ficreseij);
+
+
+ /*---------- Health expectancies and variances ------------*/
+
+
+ strcpy(filerest,"t");
+ strcat(filerest,fileres);
+ if((ficrest=fopen(filerest,"w"))==NULL) {
+ printf("Problem with total LE resultfile: %s\n", filerest);goto end;
+ fprintf(ficlog,"Problem with total LE resultfile: %s\n", filerest);goto end;
+ }
+ printf("Computing Total Life expectancies with their standard errors: file '%s' \n", filerest);
+ fprintf(ficlog,"Computing Total Life expectancies with their standard errors: file '%s' \n", filerest);
+
strcpy(fileresstde,"stde");
strcat(fileresstde,fileres);
@@ -5716,20 +5836,6 @@ Interval (in months) between two waves:
printf("Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);
fprintf(ficlog,"Computing Variance-covariance of DFLEs: file '%s' \n", fileresv);
- /* Computes prevalence between agemin (i.e minimal age computed) and no more ageminpar */
- prevalence(probs, agemin, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass);
- /* printf("ageminpar=%f, agemax=%f, s[lastpass][imx]=%d, agev[lastpass][imx]=%f, nlstate=%d, imx=%d, mint[lastpass][imx]=%f, anint[lastpass][imx]=%f,dateprev1=%f, dateprev2=%f, firstpass=%d, lastpass=%d\n",\
- ageminpar, agemax, s[lastpass][imx], agev[lastpass][imx], nlstate, imx, mint[lastpass][imx],anint[lastpass][imx], dateprev1, dateprev2, firstpass, lastpass);
- */
-
- if (mobilav!=0) {
- mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
- if (movingaverage(probs, bage, fage, mobaverage,mobilav)!=0){
- fprintf(ficlog," Error in movingaverage mobilav=%d\n",mobilav);
- printf(" Error in movingaverage mobilav=%d\n",mobilav);
- }
- }
-
for(cptcov=1,k=0;cptcov<=i1;cptcov++){
for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){
k=k+1;
@@ -5738,15 +5844,12 @@ Interval (in months) between two waves:
fprintf(ficrest,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
fprintf(ficrest,"******\n");
- fprintf(ficreseij,"\n#****** ");
fprintf(ficresstdeij,"\n#****** ");
fprintf(ficrescveij,"\n#****** ");
for(j=1;j<=cptcoveff;j++) {
- fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
fprintf(ficresstdeij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
fprintf(ficrescveij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
}
- fprintf(ficreseij,"******\n");
fprintf(ficresstdeij,"******\n");
fprintf(ficrescveij,"******\n");
@@ -5757,8 +5860,7 @@ Interval (in months) between two waves:
eij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage);
oldm=oldms;savm=savms;
- evsij(fileres, eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, strstart);
- cvevsij(fileres, eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart);
+ cvevsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart);
vareij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage);
oldm=oldms;savm=savms;
@@ -5815,7 +5917,6 @@ Interval (in months) between two waves:
free_matrix(mint,1,maxwav,1,n);
free_ivector(cod,1,n);
free_ivector(tab,1,NCOVMAX);
- fclose(ficreseij);
fclose(ficresstdeij);
fclose(ficrescveij);
fclose(ficresvij);
@@ -5901,8 +6002,9 @@ Interval (in months) between two waves:
fprintf(ficlog,"Total time was %d Sec.\n", end_time.tv_sec -start_time.tv_sec);
/* printf("Total time was %d uSec.\n", total_usecs);*/
/* if(fileappend(fichtm,optionfilehtm)){ */
- fprintf(fichtm,"