--- imach/src/imach.c 2022/09/02 14:26:02 1.337
+++ imach/src/imach.c 2022/09/04 17:40:33 1.338
@@ -1,6 +1,13 @@
-/* $Id: imach.c,v 1.337 2022/09/02 14:26:02 brouard Exp $
+/* $Id: imach.c,v 1.338 2022/09/04 17:40:33 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.338 2022/09/04 17:40:33 brouard
+ Summary: 0.99r36
+
+ * imach.c (Module): Now the easy runs i.e. without result or
+ model=1+age only did not work. The defautl combination should be 1
+ and not 0 because everything hasn't been tranformed yet.
+
Revision 1.337 2022/09/02 14:26:02 brouard
Summary: version 0.99r35
@@ -1294,12 +1301,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.337 2022/09/02 14:26:02 brouard Exp $ */
+/* $Id: imach.c,v 1.338 2022/09/04 17:40:33 brouard Exp $ */
/* $State: Exp $ */
#include "version.h"
char version[]=__IMACH_VERSION__;
char copyright[]="September 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.337 $ $Date: 2022/09/02 14:26:02 $";
+char fullversion[]="$Revision: 1.338 $ $Date: 2022/09/04 17:40:33 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -1517,7 +1524,7 @@ int **nbcode, *Tvar; /**< model=V2 => Tv
/*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 */
@@ -2510,7 +2517,8 @@ void powell(double p[], double **xi, int
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;
@@ -2824,7 +2832,7 @@ void powell(double p[], double **xi, int
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
@@ -5129,7 +5137,7 @@ Title=%s
Datafile=%s Firstpass=%d La
/* }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 */
@@ -5439,7 +5447,7 @@ Title=%s
Datafile=%s Firstpass=%d La
printf("# This combination (%d) is not valid and no result will be produced\n",j1);
invalidvarcomb[j1]=1;
}else{
- fprintf(ficresphtm,"\n
This combination (%d) is valid and result will be produced.
",j1);
+ fprintf(ficresphtm,"\n This combination (%d) is valid and result will be produced (or no resultline).
",j1);
invalidvarcomb[j1]=0;
}
fprintf(ficresphtmfr,"\n");
@@ -7208,9 +7216,9 @@ To be simple, these graphs help to under
/* 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 */
@@ -7581,7 +7589,8 @@ void printinghtml(char fileresu[], char
fprintf(fichtm," \n");
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; */
@@ -7624,7 +7633,8 @@ void printinghtml(char fileresu[], char
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; */
@@ -7649,7 +7659,7 @@ void printinghtml(char fileresu[], char
/* 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
",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n
",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\nCombination (%d) ignored because no cases
\n",k1);
printf("\nCombination (%d) ignored because no cases \n",k1);
@@ -7685,14 +7695,15 @@ divided by h: hPij
/* Period (forward stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
fprintf(fichtm,"
\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. %s_%d-%d-%d.svg
", cpt, nlstate, cpt, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
- fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"P_"),subdirf2(optionfilefiname,"P_"));
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
fprintf(fichtm,"" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
}
if(prevbcast==1){
/* Backward prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"
\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. %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,"
\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. %s_%d-%d-%d.svg
", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJB_"),subdirf2(optionfilefiname,"PIJB_"));
+ fprintf(fichtm,"" ,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
}
}
if(prevfcast==1){
@@ -7769,7 +7780,7 @@ See page 'Matrix of variance-covariance
/* - Population forecasting (if popforecast=1): pop%s
\n */
/*
",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 .)
\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 .)
\n",popforecast, stepm, model); */
fflush(fichtm);
m=pow(2,cptcoveff);
@@ -7782,7 +7793,7 @@ See page 'Matrix of variance-covariance
fprintf(fichtm," \n");
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; */
@@ -7812,7 +7823,8 @@ See page 'Matrix of variance-covariance
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; */
@@ -7832,7 +7844,7 @@ See page 'Matrix of variance-covariance
/* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */
}
- fprintf(fichtm," (model=%s) ************\n
",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n
",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\nCombination (%d) ignored because no cases
\n",k1);
@@ -7933,6 +7945,7 @@ void printinggnuplot(char fileresu[], ch
/* 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; */
@@ -7973,7 +7986,7 @@ void printinggnuplot(char fileresu[], ch
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*/
@@ -8080,6 +8093,7 @@ void printinggnuplot(char fileresu[], ch
/* 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 ");
@@ -8151,6 +8165,7 @@ void printinggnuplot(char fileresu[], ch
/* 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; */
@@ -8212,6 +8227,7 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
/* 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*/
@@ -8269,6 +8285,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 */
@@ -8334,6 +8351,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 */
@@ -8391,6 +8409,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 */
@@ -8453,6 +8472,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 */
@@ -8574,6 +8594,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 */
@@ -8651,7 +8672,7 @@ set ter svg size 640, 480\nunset log y\n
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 *\/ */
@@ -8666,7 +8687,7 @@ set ter svg size 640, 480\nunset log y\n
/* 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 1)
+ if(k 1)
sprintf(gplotcondition+strlen(gplotcondition)," && ");
}
}
@@ -8733,13 +8754,14 @@ set ter svg size 640, 480\nunset log y\n
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);*/
@@ -9555,6 +9577,7 @@ void prevforecast(char fileres[], double
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;
@@ -9615,6 +9638,7 @@ void prevforecast(char fileres[], double
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; */
@@ -9622,9 +9646,9 @@ void prevforecast(char fileres[], double
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]])]); */
@@ -10520,8 +10544,8 @@ int decoderesult( char resultline[], int
}
}
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*/
@@ -10537,8 +10561,8 @@ int decoderesult( char resultline[], int
}
}
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*/
@@ -10553,8 +10577,8 @@ int decoderesult( char resultline[], int
}
}
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;
@@ -10567,8 +10591,8 @@ int decoderesult( char resultline[], int
}
}
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 */
@@ -10588,12 +10612,12 @@ int decoderesult( char resultline[], int
}
}
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;
}
}
@@ -10725,18 +10749,18 @@ int decodemodel( char model[], int lasto
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;
@@ -11185,16 +11209,16 @@ Dummy[k] 0=dummy (0 1), 1 quantitative (
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);
}
}
@@ -11553,6 +11577,7 @@ int prevalence_limit(double *p, double *
/* 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; */
@@ -11658,23 +11683,30 @@ int back_prevalence_limit(double *p, dou
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");
@@ -11686,8 +11718,8 @@ int back_prevalence_limit(double *p, dou
}
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");
@@ -11710,8 +11742,8 @@ int back_prevalence_limit(double *p, dou
/* 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];
@@ -11721,7 +11753,7 @@ int back_prevalence_limit(double *p, dou
} /* 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); */
@@ -11765,6 +11797,7 @@ int hPijx(double *p, int bage, int fage)
/* 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; */
@@ -11846,12 +11879,13 @@ int hPijx(double *p, int bage, int fage)
/* 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 *\/ */
@@ -12291,7 +12325,7 @@ int main(int argc, char *argv[])
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);
@@ -12722,8 +12756,8 @@ Please run with mle=-1 to get a correct
}
ncovcombmax=pow(2,cptcoveff);
- invalidvarcomb=ivector(1, ncovcombmax);
- for(i=1;i