--- imach/src/imach.c 2022/07/26 17:33:55 1.326
+++ imach/src/imach.c 2022/08/03 17:29:54 1.329
@@ -1,6 +1,15 @@
-/* $Id: imach.c,v 1.326 2022/07/26 17:33:55 brouard Exp $
+/* $Id: imach.c,v 1.329 2022/08/03 17:29:54 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.329 2022/08/03 17:29:54 brouard
+ * imach.c (Module): Many errors in graphs fixed with Vn*age covariates.
+
+ Revision 1.328 2022/07/27 17:40:48 brouard
+ Summary: valgrind bug fixed by initializing to zero DummyV as well as Tage
+
+ Revision 1.327 2022/07/27 14:47:35 brouard
+ Summary: Still a problem for one-step probabilities in case of quantitative variables
+
Revision 1.326 2022/07/26 17:33:55 brouard
Summary: some test with nres=1
@@ -1186,7 +1195,7 @@ typedef struct {
#define GNUPLOTPROGRAM "gnuplot"
/*#define GNUPLOTPROGRAM "..\\gp37mgw\\wgnuplot"*/
-#define FILENAMELENGTH 132
+#define FILENAMELENGTH 256
#define GLOCK_ERROR_NOPATH -1 /* empty path */
#define GLOCK_ERROR_GETCWD -2 /* cannot get cwd */
@@ -1221,12 +1230,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.326 2022/07/26 17:33:55 brouard Exp $ */
+/* $Id: imach.c,v 1.329 2022/08/03 17:29:54 brouard Exp $ */
/* $State: Exp $ */
#include "version.h"
char version[]=__IMACH_VERSION__;
char copyright[]="July 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.326 $ $Date: 2022/07/26 17:33:55 $";
+char fullversion[]="$Revision: 1.329 $ $Date: 2022/08/03 17:29:54 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -2818,8 +2827,8 @@ void powell(double p[], double **xi, int
}
for (k=1; k<=cptcovprod;k++){ /* For product without age */
/* printf("prevalim Prod ij=%d k=%d Tprod[%d]=%d Tvard[%d][1]=V%d, Tvard[%d][2]=V%d\n",ij,k,k,Tprod[k], k,Tvard[k][1], k,Tvard[k][2]); */
- if(Dummy[Tvard[k][1]==0]){
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][1]]==0){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)];
/* cov[++k1]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)]; */
}else{
@@ -2827,7 +2836,7 @@ void powell(double p[], double **xi, int
/* cov[++k1]=nbcode[Tvard[k][1]][codtabm(ij,k)] * Tqresult[nres][k]; */
}
}else{
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]];
/* cov[++k1]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]]; */
}else{
@@ -2997,14 +3006,14 @@ void powell(double p[], double **xi, int
}
for (k=1; k<=cptcovprod;k++){ /* For product without age */
/* printf("prevalim Prod ij=%d k=%d Tprod[%d]=%d Tvard[%d][1]=V%d, Tvard[%d][2]=V%d\n",ij,k,k,Tprod[k], k,Tvard[k][1], k,Tvard[k][2]); */
- if(Dummy[Tvard[k][1]==0]){
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][1]]==0){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)];
}else{
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * Tqresult[nres][k];
}
}else{
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]];
}else{
cov[2+nagesqr+Tprod[k]]=Tqinvresult[nres][Tvard[k][1]]* Tqinvresult[nres][Tvard[k][2]];
@@ -3451,14 +3460,14 @@ double ***hpxij(double ***po, int nhstep
for (k=1; k<=cptcovprod;k++){ /* For product without age */
/* printf("hPxij Prod ij=%d k=%d Tprod[%d]=%d Tvard[%d][1]=V%d, Tvard[%d][2]=V%d\n",ij,k,k,Tprod[k], k,Tvard[k][1], k,Tvard[k][2]); */
/* cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)]; */
- if(Dummy[Tvard[k][1]==0]){
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][1]]==0){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)];
}else{
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * Tqresult[nres][k];
}
}else{
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]];
}else{
cov[2+nagesqr+Tprod[k]]=Tqinvresult[nres][Tvard[k][1]]* Tqinvresult[nres][Tvard[k][2]];
@@ -3572,14 +3581,14 @@ double ***hbxij(double ***po, int nhstep
}
for (k=1; k<=cptcovprod;k++){ /* Useless because included in cptcovn */
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)]*nbcode[Tvard[k][2]][codtabm(ij,k)];
- if(Dummy[Tvard[k][1]==0]){
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][1]]==0){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)];
}else{
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * Tqresult[nres][k];
}
}else{
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]];
}else{
cov[2+nagesqr+Tprod[k]]=Tqinvresult[nres][Tvard[k][1]]* Tqinvresult[nres][Tvard[k][2]];
@@ -5900,6 +5909,8 @@ void concatwav(int wav[], int **dh, int
{
/* Health expectancies, no variances */
+ /* cij is the combination in the list of combination of dummy covariates */
+ /* strstart is a string of time at start of computing */
int i, j, nhstepm, hstepm, h, nstepm;
int nhstepma, nstepma; /* Decreasing with age */
double age, agelim, hf;
@@ -6968,14 +6979,16 @@ To be simple, these graphs help to under
cov[2+nagesqr+Tage[k]]=nbcode[Tvar[Tage[k]]][codtabm(j1,k)]*cov[2];
/* cov[++k1]=nbcode[Tvar[Tage[k]]][codtabm(ij,k)]*cov[2]; */
} else if(Dummy[Tage[k]]==3){ /* quantitative with age */
- cov[2+nagesqr+Tage[k]]=Tqresult[nres][k];
+ printf("Internal IMaCh error, don't know which value for quantitative covariate with age, Tage[k]%d, k=%d, Tvar[Tage[k]]=V%d, age=%d\n",Tage[k],k ,Tvar[Tage[k]], (int)cov[2]);
+ exit(1);
+ /* cov[2+nagesqr+Tage[k]]=meanq[k]/idq[k]*cov[2];/\* Using the mean of quantitative variable Tvar[Tage[k]] /\* Tqresult[nres][k]; *\/ */
/* cov[++k1]=Tqresult[nres][k]; */
}
/* cov[2+Tage[k]+nagesqr]=nbcode[Tvar[Tage[k]]][codtabm(ij,k)]*cov[2]; */
}
for (k=1; k<=cptcovprod;k++){/* For product without age */
- if(Dummy[Tvard[k][1]==0]){
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][1]]==0){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(j1,k)] * nbcode[Tvard[k][2]][codtabm(j1,k)];
/* cov[++k1]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)]; */
}else{ /* Should we use the mean of the quantitative variables? */
@@ -6983,7 +6996,7 @@ To be simple, these graphs help to under
/* cov[++k1]=nbcode[Tvard[k][1]][codtabm(ij,k)] * Tqresult[nres][k]; */
}
}else{
- if(Dummy[Tvard[k][2]==0]){
+ if(Dummy[Tvard[k][2]]==0){
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][2]][codtabm(j1,k)] * Tqinvresult[nres][Tvard[k][1]];
/* cov[++k1]=nbcode[Tvard[k][2]][codtabm(ij,k)] * Tqinvresult[nres][Tvard[k][1]]; */
}else{
@@ -7329,19 +7342,23 @@ divided by h: hPij
",stepm,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres);
/* Survival functions (period) in state j */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"
\n- Survival functions in state %d. And probability to be observed in state %d being in state (1 to %d) at different ages. %s_%d-%d-%d.svg
\
-", cpt, cpt, nlstate, subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres);
+ fprintf(fichtm,"
\n- Survival functions in state %d. And probability to be observed in state %d being in state (1 to %d) at different ages. %s_%d-%d-%d.svg
", cpt, cpt, nlstate, subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
+ fprintf(fichtm,"",subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres);
}
/* State specific survival functions (period) */
for(cpt=1; cpt<=nlstate;cpt++){
fprintf(fichtm,"
\n- Survival functions in state %d and in any other live state (total).\
And probability to be observed in various states (up 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);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
+ fprintf(fichtm,"",subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres);
}
/* 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,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
+ 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,"" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
}
if(prevbcast==1){
/* Backward prevalence in each health state */
@@ -8402,41 +8419,49 @@ set ter svg size 640, 480\nunset log y\n
/* for(j=3; j <=ncovmodel-nagesqr; j++) { */
for(j=1; j <=cptcovt; j++) { /* For each covariate of the simplified model */
/* printf("Tage[%d]=%d, j=%d\n", ij, Tage[ij], j); */
- if(cptcovage >0){ /* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, 2 V5 and V1 */
- if(j==Tage[ij]) { /* Product by age To be looked at!!*//* Bug valgrind */
- if(ij <=cptcovage) { /* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, 2 V5 and V1 */
- if(DummyV[j]==0){/* Bug valgrind */
- fprintf(ficgp,"+p%d*%d*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]);;
- }else{ /* quantitative */
- fprintf(ficgp,"+p%d*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /* Tqinvresult in decoderesult */
- /* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
+ switch(Typevar[j]){
+ case 1:
+ if(cptcovage >0){ /* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, 2 V5 and V1 */
+ if(j==Tage[ij]) { /* Product by age To be looked at!!*//* Bug valgrind */
+ if(ij <=cptcovage) { /* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, 2 V5 and V1 */
+ if(DummyV[j]==0){/* Bug valgrind */
+ fprintf(ficgp,"+p%d*%d*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]);;
+ }else{ /* quantitative */
+ fprintf(ficgp,"+p%d*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /* Tqinvresult in decoderesult */
+ /* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
+ }
+ ij++;
}
- ij++;
}
- }
- }else if(cptcovprod >0){
- if(j==Tprod[ijp]) { /* */
- /* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */
- if(ijp <=cptcovprod) { /* Product */
- if(DummyV[Tvard[ijp][1]]==0){/* Vn is dummy */
- if(DummyV[Tvard[ijp][2]]==0){/* Vn and Vm are dummy */
- /* fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],nbcode[Tvard[ijp][2]][codtabm(k1,j)]); */
- fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]);
- }else{ /* Vn is dummy and Vm is quanti */
- /* fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],Tqinvresult[nres][Tvard[ijp][2]]); */
- fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
- }
- }else{ /* Vn*Vm Vn is quanti */
- if(DummyV[Tvard[ijp][2]]==0){
- fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]);
- }else{ /* Both quanti */
- fprintf(ficgp,"+p%d*%f*%f",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
+ }
+ break;
+ case 2:
+ if(cptcovprod >0){
+ if(j==Tprod[ijp]) { /* */
+ /* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */
+ if(ijp <=cptcovprod) { /* Product */
+ if(DummyV[Tvard[ijp][1]]==0){/* Vn is dummy */
+ if(DummyV[Tvard[ijp][2]]==0){/* Vn and Vm are dummy */
+ /* fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],nbcode[Tvard[ijp][2]][codtabm(k1,j)]); */
+ fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]);
+ }else{ /* Vn is dummy and Vm is quanti */
+ /* fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],Tqinvresult[nres][Tvard[ijp][2]]); */
+ fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
+ }
+ }else{ /* Vn*Vm Vn is quanti */
+ if(DummyV[Tvard[ijp][2]]==0){
+ fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]);
+ }else{ /* Both quanti */
+ fprintf(ficgp,"+p%d*%f*%f",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
+ }
}
+ ijp++;
}
- ijp++;
- }
- } /* end Tprod */
- } else{ /* simple covariate */
+ } /* end Tprod */
+ }
+ break;
+ case 0:
+ /* simple covariate */
/* fprintf(ficgp,"+p%d*%d",i+j+2+nagesqr-1,nbcode[Tvar[j]][codtabm(k1,j)]); /\* Valgrind bug nbcode *\/ */
if(Dummy[j]==0){
fprintf(ficgp,"+p%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]); /* */
@@ -8444,12 +8469,17 @@ set ter svg size 640, 480\nunset log y\n
fprintf(ficgp,"+p%d*%f",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /* */
/* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
}
- } /* end simple */
+ /* end simple */
+ break;
+ default:
+ break;
+ } /* end switch */
} /* end j */
- }else{
- i=i-ncovmodel;
- if(ng !=1 ) /* For logit formula of log p11 is more difficult to get */
- fprintf(ficgp," (1.");
+ }else{ /* k=k2 */
+ if(ng !=1 ){ /* For logit formula of log p11 is more difficult to get */
+ fprintf(ficgp," (1.");i=i-ncovmodel;
+ }else
+ i=i-ncovmodel;
}
if(ng != 1){
@@ -8462,17 +8492,78 @@ set ter svg size 640, 480\nunset log y\n
fprintf(ficgp,"+exp(p%d+p%d*x+p%d*x*x",k3+(cpt-1)*ncovmodel,k3+(cpt-1)*ncovmodel+1,k3+(cpt-1)*ncovmodel+1+nagesqr);
ij=1;
- for(j=3; j <=ncovmodel-nagesqr; j++){
- if(cptcovage >0){
- if((j-2)==Tage[ij]) { /* Bug valgrind */
- if(ij <=cptcovage) { /* Bug valgrind */
- fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,j-2)]);
- /* fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
- ij++;
- }
- }
- }else
- fprintf(ficgp,"+p%d*%d",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,j-2)]);/* Valgrind bug nbcode */
+ ijp=1;
+ /* for(j=3; j <=ncovmodel-nagesqr; j++){ */
+ for(j=1; j <=cptcovt; j++) { /* For each covariate of the simplified model */
+ switch(Typevar[j]){
+ case 1:
+ if(cptcovage >0){
+ if(j==Tage[ij]) { /* Bug valgrind */
+ if(ij <=cptcovage) { /* Bug valgrind */
+ if(DummyV[j]==0){/* Bug valgrind */
+ /* fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,j-2)]); */
+ /* fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,nbcode[Tvar[j]][codtabm(k1,j)]); */
+ fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvar[j]]);
+ /* fprintf(ficgp,"+p%d*%d*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]);; */
+ /* fprintf(ficgp,"+p%d*%d*x",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
+ }else{ /* quantitative */
+ /* fprintf(ficgp,"+p%d*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /\* Tqinvresult in decoderesult *\/ */
+ fprintf(ficgp,"+p%d*%f*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tqinvresult[nres][Tvar[j]]); /* Tqinvresult in decoderesult */
+ /* fprintf(ficgp,"+p%d*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /\* Tqinvresult in decoderesult *\/ */
+ /* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
+ }
+ ij++;
+ }
+ }
+ }
+ break;
+ case 2:
+ if(cptcovprod >0){
+ if(j==Tprod[ijp]) { /* */
+ /* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */
+ if(ijp <=cptcovprod) { /* Product */
+ if(DummyV[Tvard[ijp][1]]==0){/* Vn is dummy */
+ if(DummyV[Tvard[ijp][2]]==0){/* Vn and Vm are dummy */
+ /* fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],nbcode[Tvard[ijp][2]][codtabm(k1,j)]); */
+ fprintf(ficgp,"+p%d*%d*%d",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]);
+ /* fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]); */
+ }else{ /* Vn is dummy and Vm is quanti */
+ /* fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,nbcode[Tvard[ijp][1]][codtabm(k1,j)],Tqinvresult[nres][Tvard[ijp][2]]); */
+ fprintf(ficgp,"+p%d*%d*%f",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
+ /* fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */
+ }
+ }else{ /* Vn*Vm Vn is quanti */
+ if(DummyV[Tvard[ijp][2]]==0){
+ fprintf(ficgp,"+p%d*%d*%f",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]);
+ /* fprintf(ficgp,"+p%d*%d*%f",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]); */
+ }else{ /* Both quanti */
+ fprintf(ficgp,"+p%d*%f*%f",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]);
+ /* fprintf(ficgp,"+p%d*%f*%f",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */
+ }
+ }
+ ijp++;
+ }
+ } /* end Tprod */
+ } /* end if */
+ break;
+ case 0:
+ /* simple covariate */
+ /* fprintf(ficgp,"+p%d*%d",i+j+2+nagesqr-1,nbcode[Tvar[j]][codtabm(k1,j)]); /\* Valgrind bug nbcode *\/ */
+ if(Dummy[j]==0){
+ /* fprintf(ficgp,"+p%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]); /\* *\/ */
+ fprintf(ficgp,"+p%d*%d",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvar[j]]); /* */
+ /* fprintf(ficgp,"+p%d*%d",i+j+2+nagesqr-1,Tinvresult[nres][Tvar[j]]); /\* *\/ */
+ }else{ /* quantitative */
+ fprintf(ficgp,"+p%d*%f",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tqinvresult[nres][Tvar[j]]); /* */
+ /* fprintf(ficgp,"+p%d*%f",i+j+2+nagesqr-1,Tqinvresult[nres][Tvar[j]]); /\* *\/ */
+ /* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(k1,Tvar[j-2])]); */
+ }
+ /* end simple */
+ /* fprintf(ficgp,"+p%d*%d",k3+(cpt-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(k1,j-2)]);/\* Valgrind bug nbcode *\/ */
+ break;
+ default:
+ break;
+ } /* end switch */
}
fprintf(ficgp,")");
}
@@ -8481,7 +8572,7 @@ set ter svg size 640, 480\nunset log y\n
fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"p%d%d\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k);
else /* ng= 3 */
fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"i%d%d\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k);
- }else{ /* end ng <> 1 */
+ }else{ /* end ng <> 1 */
if( k !=k2) /* logit p11 is hard to draw */
fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"logit(p%d%d)\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k);
}
@@ -9595,6 +9686,10 @@ int readdata(char datafile[], int firsto
DummyV=ivector(1,NCOVMAX); /* 1 to 3 */
FixedV=ivector(1,NCOVMAX); /* 1 to 3 */
+ for(v=1;v> (k-1)) + 1;
* #define codtabm(h,k) (1 & (h-1) >> (k-1))+1
- * h\k 1 2 3 4
- *______________________________
- * 1 i=1 1 i=1 1 i=1 1 i=1 1
- * 2 2 1 1 1
- * 3 i=2 1 2 1 1
- * 4 2 2 1 1
- * 5 i=3 1 i=2 1 2 1
- * 6 2 1 2 1
- * 7 i=4 1 2 2 1
- * 8 2 2 2 1
- * 9 i=5 1 i=3 1 i=2 1 2
- * 10 2 1 1 2
- * 11 i=6 1 2 1 2
- * 12 2 2 1 2
- * 13 i=7 1 i=4 1 2 2
- * 14 2 1 2 2
- * 15 i=8 1 2 2 2
- * 16 2 2 2 2
- */
+ * h\k 1 2 3 4 * h-1\k-1 4 3 2 1
+ *______________________________ *______________________
+ * 1 i=1 1 i=1 1 i=1 1 i=1 1 * 0 0 0 0 0
+ * 2 2 1 1 1 * 1 0 0 0 1
+ * 3 i=2 1 2 1 1 * 2 0 0 1 0
+ * 4 2 2 1 1 * 3 0 0 1 1
+ * 5 i=3 1 i=2 1 2 1 * 4 0 1 0 0
+ * 6 2 1 2 1 * 5 0 1 0 1
+ * 7 i=4 1 2 2 1 * 6 0 1 1 0
+ * 8 2 2 2 1 * 7 0 1 1 1
+ * 9 i=5 1 i=3 1 i=2 1 2 * 8 1 0 0 0
+ * 10 2 1 1 2 * 9 1 0 0 1
+ * 11 i=6 1 2 1 2 * 10 1 0 1 0
+ * 12 2 2 1 2 * 11 1 0 1 1
+ * 13 i=7 1 i=4 1 2 2 * 12 1 1 0 0
+ * 14 2 1 2 2 * 13 1 1 0 1
+ * 15 i=8 1 2 2 2 * 14 1 1 1 0
+ * 16 2 2 2 2 * 15 1 1 1 1
+ */
/* How to do the opposite? From combination h (=1 to 2**k) how to get the value on the covariates? */
/* from h=5 and m, we get then number of covariates k=log(m)/log(2)=4
* and the value of each covariate?