/* $Id$
$State$
$Log$
+ Revision 1.337 2022/09/02 14:26:02 brouard
+ Summary: version 0.99r35
+
+ * src/imach.c: Version 0.99r35 because it outputs same results with
+ 1+age+V1+V1*age for females and 1+age for females only
+ (education=1 noweight)
+
Revision 1.336 2022/08/31 09:52:36 brouard
*** empty log message ***
/*TnsdVar[Tvar] 1 2 3 */
/*Tvaraff[nsd] 4 3 1 */ /* ID of single dummy cova fixed or timevary*/
/*TvarsD[nsd] 4 3 1 */ /* ID of single dummy cova fixed or timevary*/
-/*TvarsDind[k] 2 3 9 */ /* position K of single dummy cova */
+/*TvarsDind[nsd] 2 3 9 */ /* position K of single dummy cova */
/* nsq 1 2 */ /* Counting single quantit tv */
/* TvarsQ[k] 5 2 */ /* Number of single quantitative cova */
/* TvarsQind 1 6 */ /* position K of single quantitative cova */
xits=vector(1,n);
*fret=(*func)(p);
for (j=1;j<=n;j++) pt[j]=p[j];
- rcurr_time = time(NULL);
+ rcurr_time = time(NULL);
+ fp=(*fret); /* Initialisation */
for (*iter=1;;++(*iter)) {
ibig=0;
del=0.0;
double **prevalim(double **prlim, int nlstate, double x[], double age, double **oldm, double **savm, double ftolpl, int *ncvyear, int ij, int nres)
{
- /**< Computes the prevalence limit in each live state at age x and for covariate combination ij
+ /**< Computes the prevalence limit in each live state at age x and for covariate combination ij . Nicely done
* (and selected quantitative values in nres)
* by left multiplying the unit
* matrix by transitions matrix until convergence is reached with precision ftolpl
/* }else */ /* TODO TODO codtabm(j1,z1) or codtabm(j1,Tvaraff[z1]]z1)*/
/* if( iind >=imx-3) printf("Searching error iind=%d Tvaraff[z1]=%d covar[Tvaraff[z1]][iind]=%.f TnsdVar[Tvaraff[z1]]=%d, cptcoveff=%d, cptcovs=%d \n",iind, Tvaraff[z1], covar[Tvaraff[z1]][iind],TnsdVar[Tvaraff[z1]],cptcoveff, cptcovs); */
if(Tvaraff[z1]<1 || Tvaraff[z1]>=NCOVMAX)
- printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);
+ printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=1+age+%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);
if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]){ /* for combination j1 of covariates */
/* Tests if the value of the covariate z1 for this individual iind responded to combination j1 (V4=1 V3=0) */
bool=0; /* bool should be equal to 1 to be selected, one covariate value failed */
printf("# This combination (%d) is not valid and no result will be produced\n",j1);
invalidvarcomb[j1]=1;
}else{
- fprintf(ficresphtm,"\n <p> This combination (%d) is valid and result will be produced.</p>",j1);
+ fprintf(ficresphtm,"\n <p> This combination (%d) is valid and result will be produced (or no resultline).</p>",j1);
invalidvarcomb[j1]=0;
}
fprintf(ficresphtmfr,"</table>\n");
/* Including quantitative variables of the resultline to be done */
for (z1=1; z1<=cptcovs; z1++){ /* Loop on each variable of this resultline */
- printf("Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model);
- fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model);
- /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */
+ printf("Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model);
+ fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model);
+ /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */
if(Dummy[modelresult[nres][z1]]==0){/* Dummy variable of the variable in position modelresult in the model corresponding to z1 in resultline */
if(Fixed[modelresult[nres][z1]]==0){ /* Fixed referenced to model equation */
fprintf(ficresprob,"V%d=%d ",Tvresult[nres][z1],Tresult[nres][z1]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
fprintf(fichtm," \n<ul>");
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
/* k1=nres; */
- k1= TKresult[nres];
+ k1=TKresult[nres];
+ if(TKresult[nres]==0)k1=1; /* To be checked for no result */
/* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
/* k1=nres; */
- k1= TKresult[nres];
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
/* printf(" V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]);fflush(stdout); */
}
/* if(nqfveff+nqtveff 0) */ /* Test to be done */
- fprintf(fichtm," (model=%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\n<h3>Combination (%d) ignored because no cases </h3>\n",k1);
printf("\nCombination (%d) ignored because no cases \n",k1);
/* Period (forward stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability for a person being in state (1 to %d) at different ages, to be in state %d some years after. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br>", cpt, nlstate, cpt, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
- fprintf(fichtm," (data from text file <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"P_"),subdirf2(optionfilefiname,"P_"));
+ fprintf(fichtm," (data from text file <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
fprintf(fichtm,"<img src=\"%s_%d-%d-%d.svg\">" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
}
if(prevbcast==1){
/* Backward prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"<br>\n- Convergence to mixed (stable) back prevalence in state %d. Or probability for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \
-<img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
+ fprintf(fichtm,"<br>\n- Convergence to mixed (stable) back prevalence in state %d. Or probability for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br>", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file <a href=\"%s.txt\">%s.txt</a>)\n<br>",subdirf2(optionfilefiname,"PIJB_"),subdirf2(optionfilefiname,"PIJB_"));
+ fprintf(fichtm,"<img src=\"%s_%d-%d-%d.svg\">" ,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
}
}
if(prevfcast==1){
/* - Population forecasting (if popforecast=1): <a href=\"pop%s\">pop%s</a> <br>\n */
/* <br>",fileres,fileres,fileres,fileres); */
/* else */
-/* fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=%s (instead of .)<br><br></li>\n",popforecast, stepm, model); */
+/* fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=1+age+%s (instead of .)<br><br></li>\n",popforecast, stepm, model); */
fflush(fichtm);
m=pow(2,cptcoveff);
fprintf(fichtm," \n<ul>");
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
/* k1=nres; */
- k1= TKresult[nres];
+ k1=TKresult[nres];
/* for(k1=1; k1<=m;k1++){ /\* For each combination of covariate *\/ */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
/* k1=nres; */
- k1= TKresult[nres];
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* for(k1=1; k1<=m;k1++){ */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
/* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */
}
- fprintf(fichtm," (model=%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n<hr size=\"2\" color=\"#EC5E5E\">",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\n<h4>Combination (%d) ignored because no cases </h4>\n",k1);
/* for (k1=1; k1<= m ; k1 ++){ /\* For each valid combination of covariate *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres);
/* fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); */
- fprintf(ficgp,"set title \"Alive state %d %s model=%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);
+ fprintf(ficgp,"set title \"Alive state %d %s model=1+age+%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres);
/* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */
/* k1-1 error should be nres-1*/
/* for (k1=1; k1<= m ; k1 ++){ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files ");
/* for (k1=1; k1<= m ; k1 ++){ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
/* for (k1=1; k1<=m; k1++){ /\* For each covariate and each value *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/
/* for (k1=1; k1<= m ; k1++){ /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state */
/* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */
/* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life origin state */
/* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
/* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* if(m != 1 && TKresult[nres]!= k1) */
/* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
kl=0;
strcpy(gplotcondition,"(");
for (k=1; k<=cptcovs; k++){ /* For each covariate k of the resultline, get corresponding value lv for combination k1 */
- if(Dummy[Tvresult[nres][k]]==0){ /* To be verified */
+ if(Dummy[modelresult[nres][k]]==0){ /* To be verified */
/* for (k=1; k<=cptcoveff; k++){ /\* For each covariate writing the chain of conditions *\/ */
/* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
/* lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
/* sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]); */
sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%lg " ,kl,Tvresult[nres][k], kl+1,TinvDoQresult[nres][Tvresult[nres][k]]);
kl++;
- if(k <cptcoveff && cptcoveff>1)
+ if(k <cptcovs && cptcovs>1)
sprintf(gplotcondition+strlen(gplotcondition)," && ");
}
}
fprintf(ficgp,"#\n");
for(ng=1; ng<=3;ng++){ /* Number of graphics: first is logit, 2nd is probabilities, third is incidences per year*/
fprintf(ficgp,"#Number of graphics: first is logit, 2nd is probabilities, third is incidences per year\n");
- fprintf(ficgp,"#model=%s \n",model);
+ fprintf(ficgp,"#model=1+age+%s \n",model);
fprintf(ficgp,"# Type of graphic ng=%d\n",ng);
fprintf(ficgp,"# k1=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */
/* for(k1=1; k1 <=m; k1++) /\* For each combination of covariate *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
/* k1=nres; */
- k1= TKresult[nres];
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
fprintf(ficgp,"\n\n# Resultline k1=%d ",k1);
strcpy(gplotlabel,"(");
/*sprintf(gplotlabel+strlen(gplotlabel)," Dummy combination %d ",k1);*/
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
/* for(k=1; k<=i1;k++){ /\* We find the combination equivalent to result line values of dummies *\/ */
if(i1 != 1 && TKresult[nres]!= k)
continue;
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
/* for(k=1; k<=i1;k++){ */
/* if(i1 != 1 && TKresult[nres]!= k) */
/* continue; */
printf("\n#****** ");
fprintf(ficlog,"\n#****** ");
for (j=1; j<= cptcovs; j++){ /* For each selected (single) quantitative value */
- printf(" V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
- fprintf(ficresvbl," V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
- fprintf(ficlog," V%d=%lg ",Tvqresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
+ printf(" V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
+ fprintf(ficresvbl," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
+ fprintf(ficlog," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][resultmodel[nres][j]]);
/* for(j=1;j<=cptcoveff;j++) { */
/* fprintf(ficresvbl,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
/* fprintf(ficlog,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
}
}
if(match == 0){
- printf("Error in result line (Dummy single): V%d is missing in result: %s according to model=%s. Tvar[k1=%d]=%d is different from Tvarsel[k2=%d]=%d.\n",Tvar[k1], resultline, model,k1, Tvar[k1], k2, Tvarsel[k2]);
- fprintf(ficlog,"Error in result line (Dummy single): V%d is missing in result: %s according to model=%s\n",Tvar[k1], resultline, model);
+ printf("Error in result line (Dummy single): V%d is missing in result: %s according to model=1+age+%s. Tvar[k1=%d]=%d is different from Tvarsel[k2=%d]=%d.\n",Tvar[k1], resultline, model,k1, Tvar[k1], k2, Tvarsel[k2]);
+ fprintf(ficlog,"Error in result line (Dummy single): V%d is missing in result: %s according to model=1+age+%s\n",Tvar[k1], resultline, model);
return 1;
}
}else if(Typevar[k1]==1){ /* Product with age We want to get the position k2 in the resultline of the product k1 in the model line*/
}
}
if(match == 0){
- printf("Error in result line (Product with age): V%d is missing in result: %s according to model=%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
- fprintf(ficlog,"Error in result line (Product with age): V%d is missing in result: %s according to model=%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
+ printf("Error in result line (Product with age): V%d is missing in result: %s according to model=1+age+%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
+ fprintf(ficlog,"Error in result line (Product with age): V%d is missing in result: %s according to model=1+age+%s (Tvarsel[k2=%d]=%d)\n",Tvar[k1], resultline, model, k2, Tvarsel[k2]);
return 1;
}
}else if(Typevar[k1]==2){ /* Product No age We want to get the position in the resultline of the product in the model line*/
}
}
if(match == 0){
- printf("Error in result line (Product without age first variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][1], resultline, model);
- fprintf(ficlog,"Error in result line (Product without age first variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][1], resultline, model);
+ printf("Error in result line (Product without age first variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][1], resultline, model);
+ fprintf(ficlog,"Error in result line (Product without age first variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][1], resultline, model);
return 1;
}
match=0;
}
}
if(match == 0){
- printf("Error in result line (Product without age second variable): V%d is missing in result: %s according to model=%s\n",Tvardk[k1][2], resultline, model);
- fprintf(ficlog,"Error in result line (Product without age second variable): V%d is missing in result : %s according to model=%s\n",Tvardk[k1][2], resultline, model);
+ printf("Error in result line (Product without age second variable): V%d is missing in result: %s according to model=1+age+%s\n",Tvardk[k1][2], resultline, model);
+ fprintf(ficlog,"Error in result line (Product without age second variable): V%d is missing in result : %s according to model=1+age+%s\n",Tvardk[k1][2], resultline, model);
return 1;
}
}/* End of testing */
}
}
if(match == 0){
- printf("Error in result line: variable V%d is missing in model; result: %s, model=%s\n",Tvarsel[k2], resultline, model);
- fprintf(ficlog,"Error in result line: variable V%d is missing in model; result: %s, model=%s\n",Tvarsel[k2], resultline, model);
+ printf("Error in result line: variable V%d is missing in model; result: %s, model=1+age+%s\n",Tvarsel[k2], resultline, model);
+ fprintf(ficlog,"Error in result line: variable V%d is missing in model; result: %s, model=1+age+%s\n",Tvarsel[k2], resultline, model);
return 1;
}else if(match > 1){
- printf("Error in result line: %d doubled; result: %s, model=%s\n",k2, resultline, model);
- fprintf(ficlog,"Error in result line: %d doubled; result: %s, model=%s\n",k2, resultline, model);
+ printf("Error in result line: %d doubled; result: %s, model=1+age+%s\n",k2, resultline, model);
+ fprintf(ficlog,"Error in result line: %d doubled; result: %s, model=1+age+%s\n",k2, resultline, model);
return 1;
}
}
return 1;
}
if (strstr(model,"v") !=0){
- printf("Error. 'v' must be in upper case 'V' model=%s ",model);
- fprintf(ficlog,"Error. 'v' must be in upper case model=%s ",model);fflush(ficlog);
+ printf("Error. 'v' must be in upper case 'V' model=1+age+%s ",model);
+ fprintf(ficlog,"Error. 'v' must be in upper case model=1+age+%s ",model);fflush(ficlog);
return 1;
}
strcpy(modelsav,model);
if ((strpt=strstr(model,"age*age")) !=0){
- printf(" strpt=%s, model=%s\n",strpt, model);
+ printf(" strpt=%s, model=1+age+%s\n",strpt, model);
if(strpt != model){
- printf("Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \
+ printf("Error in model: 'model=1+age+%s'; 'age*age' should in first place before other covariates\n \
'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \
corresponding column of parameters.\n",model);
- fprintf(ficlog,"Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \
+ fprintf(ficlog,"Error in model: 'model=1+age+%s'; 'age*age' should in first place before other covariates\n \
'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \
corresponding column of parameters.\n",model); fflush(ficlog);
return 1;
if((Typevar[k1]==Typevar[k2]) && (Fixed[k1]==Fixed[k2]) && (Dummy[k1]==Dummy[k2] )){
if((Typevar[k1] == 0 || Typevar[k1] == 1)){ /* Simple or age product */
if(Tvar[k1]==Tvar[k2]){
- printf("Error duplication in the model=%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]);
- fprintf(ficlog,"Error duplication in the model=%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]); fflush(ficlog);
+ printf("Error duplication in the model=1+age+%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]);
+ fprintf(ficlog,"Error duplication in the model=1+age+%s at positions (+) %d and %d, Tvar[%d]=V%d, Tvar[%d]=V%d, Typevar=%d, Fixed=%d, Dummy=%d\n", model, k1,k2, k1, Tvar[k1], k2, Tvar[k2],Typevar[k1],Fixed[k1],Dummy[k1]); fflush(ficlog);
return(1);
}
}else if (Typevar[k1] ==2){
k3=Tposprod[k1];
k4=Tposprod[k2];
if( ((Tvard[k3][1]== Tvard[k4][1])&&(Tvard[k3][2]== Tvard[k4][2])) || ((Tvard[k3][1]== Tvard[k4][2])&&(Tvard[k3][2]== Tvard[k4][1])) ){
- printf("Error duplication in the model=%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]);
- fprintf(ficlog,"Error duplication in the model=%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]); fflush(ficlog);
+ printf("Error duplication in the model=1+age+%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]);
+ fprintf(ficlog,"Error duplication in the model=1+age+%s at positions (+) %d and %d, V%d*V%d, Typevar=%d, Fixed=%d, Dummy=%d\n",model, k1,k2, Tvard[k3][1], Tvard[k3][2],Typevar[k1],Fixed[Tvar[k1]],Dummy[Tvar[k1]]); fflush(ficlog);
return(1);
}
}
/* for(k=1; k<=i1;k++){ /\* For each combination k of dummy covariates in the model *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
/* if(i1 != 1 && TKresult[nres]!= k) /\* We found the combination k corresponding to the resultline value of dummies *\/ */
/* continue; */
if (cptcovn < 1){i1=1;}
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */
- if(i1 != 1 && TKresult[nres]!= k)
- continue;
- /*printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov));*/
+ /* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */
+ k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
+ /* if(i1 != 1 && TKresult[nres]!= k) */
+ /* continue; */
+ /* /\*printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov));*\/ */
fprintf(ficresplb,"#******");
printf("#******");
fprintf(ficlog,"#******");
- for(j=1;j<=cptcoveff ;j++) {/* all covariates */
- fprintf(ficresplb," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
- printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
- fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
- }
- for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */
- printf(" V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);
- fprintf(ficresplb," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);
- fprintf(ficlog," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]);
+ for(j=1;j<=cptcovs ;j++) {/**< cptcovs number of SIMPLE covariates in the model or resultline V2+V1 =2 (dummy or quantit or time varying) */
+ printf(" V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
+ fprintf(ficresplb," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
+ fprintf(ficlog," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
}
+ /* for(j=1;j<=cptcoveff ;j++) {/\* all covariates *\/ */
+ /* fprintf(ficresplb," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
+ /* printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
+ /* fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
+ /* } */
+ /* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ */
+ /* printf(" V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
+ /* fprintf(ficresplb," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
+ /* fprintf(ficlog," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */
+ /* } */
fprintf(ficresplb,"******\n");
printf("******\n");
fprintf(ficlog,"******\n");
}
fprintf(ficresplb,"#Age ");
- for(j=1;j<=cptcoveff;j++) {
- fprintf(ficresplb,"V%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
+ for(j=1;j<=cptcovs;j++) {
+ fprintf(ficresplb,"V%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
}
for(i=1; i<=nlstate;i++) fprintf(ficresplb," %d-%d ",i,i);
fprintf(ficresplb,"Total Years_to_converge\n");
/* exit(1); */
}
fprintf(ficresplb,"%.0f ",age );
- for(j=1;j<=cptcoveff;j++)
- fprintf(ficresplb,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
+ for(j=1;j<=cptcovs;j++)
+ fprintf(ficresplb,"%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
tot=0.;
for(i=1; i<=nlstate;i++){
tot += bprlim[i][i];
} /* Age */
/* was end of cptcod */
/*fprintf(ficresplb,"\n");*/ /* Seems to be necessary for gnuplot only if two result lines and no covariate. */
- } /* end of any combination */
+ /* } /\* end of any combination *\/ */
} /* end of nres */
/* hBijx(p, bage, fage); */
/* fclose(ficrespijb); */
/* k=k+1; */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
/* for(k=1; k<=i1;k++){ */
/* if(i1 != 1 && TKresult[nres]!= k) */
/* continue; */
/* k=k+1; */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
k=TKresult[nres];
+ if(TKresult[nres]==0) k=1; /* To be checked for noresult */
/* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */
/* if(i1 != 1 && TKresult[nres]!= k) */
/* continue; */
fprintf(ficrespijb,"\n#****** ");
for(j=1;j<=cptcovs;j++){
- fprintf(ficrespij," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
+ fprintf(ficrespijb," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]);
/* for(j=1;j<=cptcoveff;j++) */
/* fprintf(ficrespijb,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
/* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ */
strcpy(model,modeltemp);
}
}
- /* printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout); */
+ /* printf(" model=1+age%s modeltemp= %s, model=1+age+%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);
}
ncovcombmax=pow(2,cptcoveff);
- invalidvarcomb=ivector(1, ncovcombmax);
- for(i=1;i<ncovcombmax;i++)
+ invalidvarcomb=ivector(0, ncovcombmax);
+ for(i=0;i<ncovcombmax;i++)
invalidvarcomb[i]=0;
/* Nbcode gives the value of the lth modality (currently 1 to 2) of jth covariate, in
free_ivector(Tposprod,1,NCOVMAX);
free_ivector(Tprod,1,NCOVMAX);
free_ivector(Tvaraff,1,NCOVMAX);
- free_ivector(invalidvarcomb,1,ncovcombmax);
+ free_ivector(invalidvarcomb,0,ncovcombmax);
free_ivector(Tage,1,NCOVMAX);
free_ivector(Tmodelind,1,NCOVMAX);
free_ivector(TmodelInvind,1,NCOVMAX);