Datafile=%s Firstpass=%d La
}/* Some are varying covariates, we tried to speed up if all fixed covariates in the model, avoiding waves loop */
} /* end j==0 */
/* bool =0 we keep that guy which corresponds to the combination of dummy values */
- if(bool==1){
+ if(bool==1){ /*Selected */
/* dh[m][iind] or dh[mw[mi][iind]][iind] is the delay between two effective (mi) waves m=mw[mi][iind]
and mw[mi+1][iind]. dh depends on stepm. */
agebegin=agev[m][iind]; /* Age at beginning of wave before transition*/
@@ -4566,6 +4580,11 @@ 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 */
+ }
/* 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); */
/* freq[s[m][iind]][s[m+1][iind]][(int)((agebegin+ageend)/2.)] += weight[iind]; */
@@ -4581,6 +4600,11 @@ Title=%s
Datafile=%s Firstpass=%d La
bool=1;
}/* end bool 2 */
} /* end m */
+ /* 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 *\/ */
+ /* } */
} /* end bool */
} /* end iind = 1 to imx */
/* prop[s][age] is feeded for any initial and valid live state as well as
@@ -4618,6 +4642,27 @@ Title=%s
Datafile=%s Firstpass=%d La
fprintf(ficresphtmfr, "**********\n");
fprintf(ficlog, "**********\n");
}
+ /*
+ 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=%.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]));
+ }
+ /* for (z1=1; z1<= nqtveff; z1++) { */
+ /* for(m=1;m<=lastpass;m++){ */
+ /* fprintf(ficresphtmfr,"V quantitative id %d, pass id=%d, mean=%f
\n", z1, m, meanqt[m][z1]); */
+ /* } */
+ /* } */
+
fprintf(ficresphtm,"
");
if((cptcoveff==0 && nj==1)|| nj==2 ) /* no covariate and first pass */
fprintf(ficresp, " Age");
@@ -4852,7 +4897,7 @@ Title=%s
Datafile=%s Firstpass=%d La
fprintf(ficlog,"\n");
}
}
- }
+ } /* end of state i */
printf("#Freqsummary\n");
fprintf(ficlog,"\n");
for(s1=-1; s1 <=nlstate+ndeath; s1++){
@@ -4898,7 +4943,9 @@ Title=%s
Datafile=%s Firstpass=%d La
fclose(ficresp);
fclose(ficresphtm);
fclose(ficresphtmfr);
+ free_vector(idq,1,nqfveff);
free_vector(meanq,1,nqfveff);
+ free_vector(stdq,1,nqfveff);
free_matrix(meanqt,1,lastpass,1,nqtveff);
free_vector(x, iagemin-AGEMARGE, iagemax+4+AGEMARGE);
free_vector(y, iagemin-AGEMARGE, iagemax+4+AGEMARGE);
@@ -5314,6 +5361,9 @@ void concatwav(int wav[], int **dh, int
/* *cptcov=0; */
for (k=1; k <= maxncov; k++) ncodemax[k]=0; /* Horrible constant again replaced by NCOVMAX */
+ for (k=1; k <= maxncov; k++)
+ for(j=1; j<=2; j++)
+ nbcode[k][j]=0; /* Valgrind */
/* Loop on covariates without age and products and no quantitative variable */
/* for (j=1; j<=(cptcovs); j++) { /\* From model V1 + V2*age+ V3 + V3*V4 keeps V1 + V3 = 2 only *\/ */
@@ -6865,7 +6915,7 @@ divided by h: hPij
for(cpt=1; cpt<=nlstate;cpt++){
fprintf(fichtm,"
\n- Survival functions from state %d in each live state and total.\
Or probability to survive in various states (1 to %d) being in state %d at different ages. \
- %s_%d%d-%d.svg
", cpt, nlstate, cpt, subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres);
+ %s_%d-%d-%d.svg
", cpt, nlstate, cpt, subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres);
}
/* Period (stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
@@ -9689,7 +9739,7 @@ Dummy[k] 0=dummy (0 1), 1 quantitative (
Typevar: 0 for simple covariate (dummy, quantitative, fixed or varying), 1 for age product, 2 for product \n\
Fixed[k] 0=fixed (product or simple), 1 varying, 2 fixed with age product, 3 varying with age product \n\
Dummy[k] 0=dummy (0 1), 1 quantitative (single or product without age), 2 dummy with age product, 3 quant with age product\n",model);
- for(k=1;k<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;}
+ for(k=-1;k<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;}
for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0;k<=cptcovt; k++){ /* or cptocvt */
if (Tvar[k] <=ncovcol && Typevar[k]==0 ){ /* Simple fixed dummy (<=ncovcol) covariates */
Fixed[k]= 0;
@@ -9939,11 +9989,12 @@ Dummy[k] 0=dummy (0 1), 1 quantitative (
/* Searching for doublons in the model */
for(k1=1; k1<= cptcovt;k1++){
for(k2=1; k2 maxwav){
+ printf("Error (lastpass = %d) > (maxwav = %d)\n",lastpass, maxwav);
+ fprintf(ficlog,"Error (lastpass = %d) > (maxwav = %d)\n",lastpass, maxwav);
+ fflush(ficlog);
+ goto end;
+ }
+ printf("ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
+ fprintf(ficparo,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
+ fprintf(ficres,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, 0, weightopt);
+ fprintf(ficlog,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
}
/* ftolpl=6*ftol*1.e5; /\* 6.e-3 make convergences in less than 80 loops for the prevalence limit *\/ */
/*ftolpl=6.e-4; *//* 6.e-3 make convergences in less than 80 loops for the prevalence limit */
@@ -10980,10 +11047,10 @@ int main(int argc, char *argv[])
/* If line starts with a # it is a comment */
if (line[0] == '#') {
numlinepar++;
- fputs(line,stdout);
- fputs(line,ficparo);
- fputs(line,ficres);
- fputs(line,ficlog);
+ printf("%s",line);
+ fprintf(ficres,"%s",line);
+ fprintf(ficparo,"%s",line);
+ fprintf(ficlog,"%s",line);
continue;
}else
break;
@@ -11004,12 +11071,15 @@ int main(int argc, char *argv[])
}
/* printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout); */
printf("model=1+age+%s\n",model);fflush(stdout);
+ fprintf(ficparo,"model=1+age+%s\n",model);fflush(stdout);
+ fprintf(ficres,"model=1+age+%s\n",model);fflush(stdout);
+ fprintf(ficlog,"model=1+age+%s\n",model);fflush(stdout);
}
/* fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model); */
/* numlinepar=numlinepar+3; /\* In general *\/ */
/* printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); */
- fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol, nqv, ntv, nqtv, nlstate,ndeath,maxwav, mle, weightopt,model);
- fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol, nqv, ntv, nqtv, nlstate,ndeath,maxwav, mle, weightopt,model);
+ /* fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol, nqv, ntv, nqtv, nlstate,ndeath,maxwav, mle, weightopt,model); */
+ /* fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol, nqv, ntv, nqtv, nlstate,ndeath,maxwav, mle, weightopt,model); */
fflush(ficlog);
/* if(model[0]=='#'|| model[0]== '\0'){ */
if(model[0]=='#'){
@@ -11576,7 +11646,7 @@ Title=%s
Datafile=%s Firstpass=%d La
firstpass, lastpass, stepm, weightopt, model);
fprintf(fichtm,"\n");
- fprintf(fichtm,"Parameter line 2
- Tolerance for the convergence of the likelihood: ftol=%f \n
- Interval for the elementary matrix (in month): stepm=%d",\
+ fprintf(fichtm,"
Parameter line 2
- Tolerance for the convergence of the likelihood: ftol=%g \n
- Interval for the elementary matrix (in month): stepm=%d",\
ftol, stepm);
fprintf(fichtm,"\n
- Number of fixed dummy covariates: ncovcol=%d ", ncovcol);
ncurrv=1;
@@ -11872,7 +11942,7 @@ Please run with mle=-1 to get a correct
printf("\n");
/*--------- results files --------------*/
- fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, weightopt,model);
+ /* fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, weightopt,model); */
fprintf(ficres,"# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n");
@@ -12740,5 +12810,6 @@ end:
printf("\nType q for exiting: "); fflush(stdout);
scanf("%s",z);
}
+ printf("End\n");
exit(0);
}