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*/
@@ -4549,6 +4583,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]; */
@@ -4564,6 +4603,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
@@ -4601,6 +4645,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");
@@ -4835,7 +4900,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++){
@@ -4881,7 +4946,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);
@@ -5297,9 +5364,11 @@ 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 *\/ */
for (k=1; k<=cptcovt; k++) { /* From model V1 + V2*age + V3 + V3*V4 keeps V1 + V3 = 2 only */
for (j=-1; (j < maxncov); j++) Ndum[j]=0;
if(Dummy[k]==0 && Typevar[k] !=1){ /* Dummy covariate and not age product */
@@ -5317,7 +5386,11 @@ void concatwav(int wav[], int **dh, int
modmaxcovj=ij;
else if (ij < modmincovj)
modmincovj=ij;
- if ((ij < -1) && (ij > NCOVMAX)){
+ if (ij <0 || ij >1 ){
+ printf("Information, IMaCh doesn't treat covariate with missing values (-1), individual %d will be skipped.\n",i);
+ fprintf(ficlog,"Information, currently IMaCh doesn't treat covariate with missing values (-1), individual %d will be skipped.\n",i);
+ }
+ if ((ij < -1) || (ij > NCOVMAX)){
printf( "Error: minimal is less than -1 or maximal is bigger than %d. Exiting. \n", NCOVMAX );
exit(1);
}else
@@ -5363,12 +5436,18 @@ void concatwav(int wav[], int **dh, int
/* nbcode[Tvar[j]][3]=2; */
/* To be continued (not working yet). */
ij=0; /* ij is similar to i but can jump over null modalities */
- for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
+
+ /* for (i=modmincovj; i<=modmaxcovj; i++) { */ /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
+ /* Skipping the case of missing values by reducing nbcode to 0 and 1 and not -1, 0, 1 */
+ /* model=V1+V2+V3, if V2=-1, 0 or 1, then nbcode[2][1]=0 and nbcode[2][2]=1 instead of
+ * nbcode[2][1]=-1, nbcode[2][2]=0 and nbcode[2][3]=1 */
+ /*, could be restored in the future */
+ for (i=0; i<=1; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
if (Ndum[i] == 0) { /* If nobody responded to this modality k */
break;
}
ij++;
- nbcode[Tvar[k]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality. nbcode[1][1]=0 nbcode[1][2]=1*/
+ nbcode[Tvar[k]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality. nbcode[1][1]=0 nbcode[1][2]=1 . Could be -1*/
cptcode = ij; /* New max modality for covar j */
} /* end of loop on modality i=-1 to 1 or more */
break;
@@ -5384,21 +5463,7 @@ void concatwav(int wav[], int **dh, int
break;
} /* end switch */
} /* end dummy test */
-
- /* for (k=0; k<= cptcode; k++) { /\* k=-1 ? k=0 to 1 *\//\* Could be 1 to 4 *\//\* cptcode=modmaxcovj *\/ */
- /* /\*recode from 0 *\/ */
- /* k is a modality. If we have model=V1+V1*sex */
- /* then: nbcode[1][1]=0 ; nbcode[1][2]=1; nbcode[2][1]=0 ; nbcode[2][2]=1; */
- /* But if some modality were not used, it is recoded from 0 to a newer modmaxcovj=cptcode *\/ */
- /* } */
- /* /\* cptcode = ij; *\/ /\* New max modality for covar j *\/ */
- /* if (ij > ncodemax[j]) { */
- /* printf( " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */
- /* fprintf(ficlog, " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */
- /* break; */
- /* } */
- /* } /\* end of loop on modality k *\/ */
- } /* end of loop on model-covariate j. nbcode[Tvarj][1]=0 and nbcode[Tvarj][2]=1 sets the value of covariate j*/
+ } /* end of loop on model-covariate k. nbcode[Tvark][1]=-1, nbcode[Tvark][1]=0 and nbcode[Tvark][2]=1 sets the value of covariate k*/
for (k=-1; k< maxncov; k++) Ndum[k]=0;
/* Look at fixed dummy (single or product) covariates to check empty modalities */
@@ -5772,10 +5837,11 @@ void concatwav(int wav[], int **dh, int
/************ Variance ******************/
void varevsij(char optionfilefiname[], double ***vareij, double **matcov, double x[], double delti[], int nlstate, int stepm, double bage, double fage, double **oldm, double **savm, double **prlim, double ftolpl, int *ncvyearp, int ij, int estepm, int cptcov, int cptcod, int popbased, int mobilav, char strstart[], int nres)
{
- /* Variance of health expectancies */
- /* double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double ** savm,double ftolpl);*/
- /* double **newm;*/
- /* int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav)*/
+ /** Variance of health expectancies
+ * double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double ** savm,double ftolpl);
+ * double **newm;
+ * int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav)
+ */
/* int movingaverage(); */
double **dnewm,**doldm;
@@ -5783,11 +5849,11 @@ void concatwav(int wav[], int **dh, int
int i, j, nhstepm, hstepm, h, nstepm ;
int k;
double *xp;
- double **gp, **gm; /* for var eij */
- double ***gradg, ***trgradg; /*for var eij */
- double **gradgp, **trgradgp; /* for var p point j */
- double *gpp, *gmp; /* for var p point j */
- double **varppt; /* for var p point j nlstate to nlstate+ndeath */
+ double **gp, **gm; /**< for var eij */
+ double ***gradg, ***trgradg; /**< for var eij */
+ double **gradgp, **trgradgp; /**< for var p point j */
+ double *gpp, *gmp; /**< for var p point j */
+ double **varppt; /**< for var p point j nlstate to nlstate+ndeath */
double ***p3mat;
double age,agelim, hf;
/* double ***mobaverage; */
@@ -5848,7 +5914,7 @@ void concatwav(int wav[], int **dh, int
/* fprintf(fichtm, "#Local time at start: %s", strstart);*/
fprintf(fichtm,"\n Computing probabilities of dying over estepm months as a weighted average (i.e global mortality independent of initial healh state)
\n");
fprintf(fichtm,"\n
%s
\n",digitp);
- /* } */
+
varppt = matrix(nlstate+1,nlstate+ndeath,nlstate+1,nlstate+ndeath);
pstamp(ficresvij);
fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are ");
@@ -5903,9 +5969,12 @@ void concatwav(int wav[], int **dh, int
for(i=1; i<=npar; i++){ /* Computes gradient x + delta*/
xp[i] = x[i] + (i==theta ?delti[theta]:0);
}
-
+ /**< Computes the prevalence limit with parameter theta shifted of delta up to ftolpl precision and
+ * returns into prlim .
+ */
prevalim(prlim,nlstate,xp,age,oldm,savm,ftolpl,ncvyearp,ij, nres);
-
+
+ /* If popbased = 1 we use crossection prevalences. Previous step is useless but prlim is created */
if (popbased==1) {
if(mobilav ==0){
for(i=1; i<=nlstate;i++)
@@ -5915,23 +5984,28 @@ void concatwav(int wav[], int **dh, int
prlim[i][i]=mobaverage[(int)age][i][ij];
}
}
-
- hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij,nres); /* Returns p3mat[i][j][h] for h=1 to nhstepm */
+ /**< Computes the shifted transition matrix \f$ {}{h}_p^{ij}_x\f$ at horizon h.
+ */
+ hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij,nres); /* Returns p3mat[i][j][h] for h=0 to nhstepm */
+ /**< And for each alive state j, sums over i \f$ w^i_x {}{h}_p^{ij}_x\f$, which are the probability
+ * at horizon h in state j including mortality.
+ */
for(j=1; j<= nlstate; j++){
for(h=0; h<=nhstepm; h++){
for(i=1, gp[h][j]=0.;i<=nlstate;i++)
gp[h][j] += prlim[i][i]*p3mat[i][j][h];
}
}
- /* Next for computing probability of death (h=1 means
+ /* Next for computing shifted+ probability of death (h=1 means
computed over hstepm matrices product = hstepm*stepm months)
- as a weighted average of prlim.
+ as a weighted average of prlim(i) * p(i,j) p.3=w1*p13 + w2*p23 .
*/
for(j=nlstate+1;j<=nlstate+ndeath;j++){
for(i=1,gpp[j]=0.; i<= nlstate; i++)
gpp[j] += prlim[i][i]*p3mat[i][j][1];
- }
- /* end probability of death */
+ }
+
+ /* Again with minus shift */
for(i=1; i<=npar; i++) /* Computes gradient x - delta */
xp[i] = x[i] - (i==theta ?delti[theta]:0);
@@ -5964,19 +6038,23 @@ void concatwav(int wav[], int **dh, int
for(i=1,gmp[j]=0.; i<= nlstate; i++)
gmp[j] += prlim[i][i]*p3mat[i][j][1];
}
- /* end probability of death */
-
+ /* end shifting computations */
+
+ /**< Computing gradient matrix at horizon h
+ */
for(j=1; j<= nlstate; j++) /* vareij */
for(h=0; h<=nhstepm; h++){
gradg[h][theta][j]= (gp[h][j]-gm[h][j])/2./delti[theta];
}
-
- for(j=nlstate+1; j<= nlstate+ndeath; j++){ /* var mu */
+ /**< Gradient of overall mortality p.3 (or p.j)
+ */
+ for(j=nlstate+1; j<= nlstate+ndeath; j++){ /* var mu mortality from j */
gradgp[theta][j]= (gpp[j]-gmp[j])/2./delti[theta];
}
} /* End theta */
-
+
+ /* We got the gradient matrix for each theta and state j */
trgradg =ma3x(0,nhstepm,1,nlstate,1,npar); /* veij */
for(h=0; h<=nhstepm; h++) /* veij */
@@ -5987,13 +6065,19 @@ void concatwav(int wav[], int **dh, int
for(j=nlstate+1; j<=nlstate+ndeath;j++) /* mu */
for(theta=1; theta <=npar; theta++)
trgradgp[j][theta]=gradgp[theta][j];
-
+ /**< as well as its transposed matrix
+ */
hf=hstepm*stepm/YEARM; /* Duration of hstepm expressed in year unit. */
for(i=1;i<=nlstate;i++)
for(j=1;j<=nlstate;j++)
vareij[i][j][(int)age] =0.;
-
+
+ /* Computing trgradg by matcov by gradg at age and summing over h
+ * and k (nhstepm) formula 15 of article
+ * Lievre-Brouard-Heathcote
+ */
+
for(h=0;h<=nhstepm;h++){
for(k=0;k<=nhstepm;k++){
matprod2(dnewm,trgradg[h],1,nlstate,1,npar,1,npar,matcov);
@@ -6004,7 +6088,11 @@ void concatwav(int wav[], int **dh, int
}
}
- /* pptj */
+ /* pptj is p.3 or p.j = trgradgp by cov by gradgp, variance of
+ * p.j overall mortality formula 49 but computed directly because
+ * we compute the grad (wix pijx) instead of grad (pijx),even if
+ * wix is independent of theta.
+ */
matprod2(dnewmp,trgradgp,nlstate+1,nlstate+ndeath,1,npar,1,npar,matcov);
matprod2(doldmp,dnewmp,nlstate+1,nlstate+ndeath,1,npar,nlstate+1,nlstate+ndeath,gradgp);
for(j=nlstate+1;j<=nlstate+ndeath;j++)
@@ -6613,7 +6701,12 @@ To be simple, these graphs help to under
}
/* Eigen vectors */
- v11=(1./sqrt(1+(v1-lc1)*(v1-lc1)/cv12/cv12));
+ if(1+(v1-lc1)*(v1-lc1)/cv12/cv12 <1.e-5){
+ printf(" Error sqrt of a negative number: %lf\n",1+(v1-lc1)*(v1-lc1)/cv12/cv12);
+ fprintf(ficlog," Error sqrt of a negative number: %lf\n",1+(v1-lc1)*(v1-lc1)/cv12/cv12);
+ v11=(1./sqrt(fabs(1+(v1-lc1)*(v1-lc1)/cv12/cv12)));
+ }else
+ v11=(1./sqrt(1+(v1-lc1)*(v1-lc1)/cv12/cv12));
/*v21=sqrt(1.-v11*v11); *//* error */
v21=(lc1-v1)/cv12*v11;
v12=-v21;
@@ -6644,8 +6737,8 @@ To be simple, these graphs help to under
fprintf(ficgp,"\nset label \"%d\" at %11.3e,%11.3e center",(int) age, mu1,mu2);
fprintf(ficgp,"\n# Age %d, p%1d%1d - p%1d%1d",(int) age, k1,l1,k2,l2);
fprintf(ficgp,"\nplot [-pi:pi] %11.3e+ %.3f*(%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)), %11.3e +%.3f*(%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)) not", \
- mu1,std,v11,sqrt(lc1),v12,sqrt(fabs(lc2)), \
- mu2,std,v21,sqrt(lc1),v22,sqrt(fabs(lc2))); /* For gnuplot only */
+ mu1,std,v11,sqrt(fabs(lc1)),v12,sqrt(fabs(lc2)), \
+ mu2,std,v21,sqrt(fabs(lc1)),v22,sqrt(fabs(lc2))); /* For gnuplot only */
}else{
first=0;
fprintf(fichtmcov," %d (%.3f),",(int) age, c12);
@@ -6820,7 +6913,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++){
@@ -9644,7 +9737,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;
@@ -9894,11 +9987,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 */
@@ -10932,23 +11045,18 @@ 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;
}
if((num_filled=sscanf(line,"model=1+age%[^.\n]", model)) !=EOF){
- if (num_filled == 0){
- printf("ERROR %d: Model should be at minimum 'model=1+age.' WITHOUT space:'%s'\n",num_filled, line);
- fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age.' WITHOUT space:'%s'\n",num_filled, line);
- model[0]='\0';
- goto end;
- } else if (num_filled != 1){
- printf("ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line);
- fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line);
+ if (num_filled != 1){
+ printf("ERROR %d: Model should be at minimum 'model=1+age' %s\n",num_filled, line);
+ fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age' %s\n",num_filled, line);
model[0]='\0';
goto end;
}
@@ -10961,20 +11069,23 @@ 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]=='#'){
- printf("Error in 'model' line: model should start with 'model=1+age+' and end with '.' \n \
- 'model=1+age+.' or 'model=1+age+V1.' or 'model=1+age+age*age+V1+V1*age.' or \n \
- 'model=1+age+V1+V2.' or 'model=1+age+V1+V2+V1*V2.' etc. \n"); \
+ printf("Error in 'model' line: model should start with 'model=1+age+' and end without space \n \
+ 'model=1+age+' or 'model=1+age+V1.' or 'model=1+age+age*age+V1+V1*age' or \n \
+ 'model=1+age+V1+V2' or 'model=1+age+V1+V2+V1*V2' etc. \n"); \
if(mle != -1){
- printf("Fix the model line and run imach with mle=-1 to get a correct template of the parameter file.\n");
+ printf("Fix the model line and run imach with mle=-1 to get a correct template of the parameter vectors and subdiagonal covariance matrix.\n");
exit(1);
}
}
@@ -11533,7 +11644,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;
@@ -11829,7 +11940,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");
@@ -12627,6 +12738,8 @@ Please run with mle=-1 to get a correct
fclose(ficlog);
/*------ End -----------*/
+
+/* Executes gnuplot */
printf("Before Current directory %s!\n",pathcd);
#ifdef WIN32
@@ -12695,4 +12808,6 @@ end:
printf("\nType q for exiting: "); fflush(stdout);
scanf("%s",z);
}
+ printf("End\n");
+ exit(0);
}