version 1.349, 2023/01/31 09:19:37
|
version 1.353, 2023/05/08 18:48:22
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.353 2023/05/08 18:48:22 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.352 2023/04/29 10:46:21 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.351 2023/04/29 10:43:47 brouard |
|
Summary: 099r45 |
|
|
|
Revision 1.350 2023/04/24 11:38:06 brouard |
|
*** empty log message *** |
|
|
Revision 1.349 2023/01/31 09:19:37 brouard |
Revision 1.349 2023/01/31 09:19:37 brouard |
Summary: Improvements in models with age*Vn*Vm |
Summary: Improvements in models with age*Vn*Vm |
|
|
Line 1362 double gnuplotversion=GNUPLOTVERSION;
|
Line 1374 double gnuplotversion=GNUPLOTVERSION;
|
/* $State$ */ |
/* $State$ */ |
#include "version.h" |
#include "version.h" |
char version[]=__IMACH_VERSION__; |
char version[]=__IMACH_VERSION__; |
char copyright[]="January 2023,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 copyright[]="April 2023,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$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
char strstart[80]; |
char strstart[80]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
Line 1598 int **nbcode, *Tvar; /**< model=V2 => Tv
|
Line 1610 int **nbcode, *Tvar; /**< model=V2 => Tv
|
/* Tprod[i]=k 1 2 */ /* Position in model of the ith prod without age */ |
/* Tprod[i]=k 1 2 */ /* Position in model of the ith prod without age */ |
/* cptcovage 1 2 3 */ /* Counting cov*age in the model equation */ |
/* cptcovage 1 2 3 */ /* Counting cov*age in the model equation */ |
/* Tage[cptcovage]=k 5 8 10 */ /* Position in the model of ith cov*age */ |
/* Tage[cptcovage]=k 5 8 10 */ /* Position in the model of ith cov*age */ |
|
/* model="V2+V3+V4+V6+V7+V6*V2+V7*V2+V6*V3+V7*V3+V6*V4+V7*V4+age*V2+age*V3+age*V4+age*V6+age*V7+age*V6*V2+age*V6*V3+age*V7*V3+age*V6*V4+age*V7*V4\r"*/ |
|
/* p Tvard[1][1]@21 = {6, 2, 7, 2, 6, 3, 7, 3, 6, 4, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}*/ |
|
/* p Tvard[2][1]@21 = {7, 2, 6, 3, 7, 3, 6, 4, 7, 4, 0 <repeats 11 times>} |
|
/* p Tvardk[1][1]@24 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 7, 2, 6, 3, 7, 3, 6, 4, 7, 4, 0, 0}*/ |
|
/* p Tvardk[1][1]@22 = {0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 7, 2, 6, 3, 7, 3, 6, 4, 7, 4, 0, 0} */ |
/* Tvard[1][1]@4={4,3,1,2} V4*V3 V1*V2 */ /* Position in model of the ith prod without age */ |
/* Tvard[1][1]@4={4,3,1,2} V4*V3 V1*V2 */ /* Position in model of the ith prod without age */ |
/* Tvardk[4][1]=4;Tvardk[4][2]=3;Tvardk[7][1]=1;Tvardk[7][2]=2 */ /* Variables of a prod at position in the model equation*/ |
/* Tvardk[4][1]=4;Tvardk[4][2]=3;Tvardk[7][1]=1;Tvardk[7][2]=2 */ /* Variables of a prod at position in the model equation*/ |
/* TvarF TvarF[1]=Tvar[6]=2, TvarF[2]=Tvar[7]=7, TvarF[3]=Tvar[9]=1 ID of fixed covariates or product V2, V1*V2, V1 */ |
/* TvarF TvarF[1]=Tvar[6]=2, TvarF[2]=Tvar[7]=7, TvarF[3]=Tvar[9]=1 ID of fixed covariates or product V2, V1*V2, V1 */ |
Line 1796 char *trimbb(char *out, char *in)
|
Line 1813 char *trimbb(char *out, char *in)
|
return s; |
return s; |
} |
} |
|
|
|
char *trimbtab(char *out, char *in) |
|
{ /* Trim blanks or tabs in line but keeps first blanks if line starts with blanks */ |
|
char *s; |
|
s=out; |
|
while (*in != '\0'){ |
|
while( (*in == ' ' || *in == '\t')){ /* && *(in+1) != '\0'){*/ |
|
in++; |
|
} |
|
*out++ = *in++; |
|
} |
|
*out='\0'; |
|
return s; |
|
} |
|
|
/* char *substrchaine(char *out, char *in, char *chain) */ |
/* char *substrchaine(char *out, char *in, char *chain) */ |
/* { */ |
/* { */ |
/* /\* Substract chain 'chain' from 'in', return and output 'out' *\/ */ |
/* /\* Substract chain 'chain' from 'in', return and output 'out' *\/ */ |
Line 4835 void likelione(FILE *ficres,double p[],
|
Line 4866 void likelione(FILE *ficres,double p[],
|
fprintf(fichtm,"<br>- Probability p<sub>%dj</sub> by origin %d and destination j. Dot's sizes are related to corresponding weight: <a href=\"%s-p%dj.png\">%s-p%dj.png</a><br>\n \ |
fprintf(fichtm,"<br>- Probability p<sub>%dj</sub> by origin %d and destination j. Dot's sizes are related to corresponding weight: <a href=\"%s-p%dj.png\">%s-p%dj.png</a><br>\n \ |
<img src=\"%s-p%dj.png\">\n",k,k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k); |
<img src=\"%s-p%dj.png\">\n",k,k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k); |
for(kf=1; kf <= ncovf; kf++){ /* For each simple dummy covariate of the model */ |
for(kf=1; kf <= ncovf; kf++){ /* For each simple dummy covariate of the model */ |
/* kvar=Tvar[TvarFind[kf]]; */ /* variable */ |
kvar=Tvar[TvarFind[kf]]; /* variable */ |
fprintf(fichtm,"<br>- Probability p<sub>%dj</sub> by origin %d and destination j with colored covariate V%d. Same dot size of all points but with a different color for transitions with dummy variable V%d=1 at beginning of transition (keeping former color for V%d=0): <a href=\"%s-p%dj.png\">%s-p%dj.png</a><br> \ |
fprintf(fichtm,"<br>- Probability p<sub>%dj</sub> by origin %d and destination j with colored covariate V%d. Same dot size of all points but with a different color for transitions with dummy variable V%d=1 at beginning of transition (keeping former color for V%d=0): ",k,k,Tvar[TvarFind[kf]],Tvar[TvarFind[kf]],Tvar[TvarFind[kf]]); |
<img src=\"%s-p%dj-%d.png\">",k,k,Tvar[TvarFind[kf]],Tvar[TvarFind[kf]],Tvar[TvarFind[kf]],subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,Tvar[TvarFind[kf]]); |
fprintf(fichtm,"<a href=\"%s-p%dj-%d.png\">%s-p%dj-%d.png</a><br>",subdirf2(optionfilefiname,"ILK_"),k,kvar,subdirf2(optionfilefiname,"ILK_"),k,kvar); |
|
fprintf(fichtm,"<img src=\"%s-p%dj-%d.png\">",subdirf2(optionfilefiname,"ILK_"),k,Tvar[TvarFind[kf]]); |
} |
} |
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Loop on the time varying extended covariates (with extension of Vn*Vm */ |
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Loop on the time varying extended covariates (with extension of Vn*Vm */ |
ipos=TvarVVind[ncovv]; /* TvarVVind={2, 5, 5] gives the position in the model of the ncovv th varying covariate */ |
ipos=TvarVVind[ncovv]; /* TvarVVind={2, 5, 5] gives the position in the model of the ncovv th varying covariate */ |
Line 8399 void printinggnuplot(char fileresu[], ch
|
Line 8431 void printinggnuplot(char fileresu[], ch
|
for(kf=1; kf <= ncovf; kf++){ /* For each simple dummy covariate of the model */ |
for(kf=1; kf <= ncovf; kf++){ /* For each simple dummy covariate of the model */ |
kvar=Tvar[TvarFind[kf]]; /* variable name */ |
kvar=Tvar[TvarFind[kf]]; /* variable name */ |
/* k=18+Tvar[TvarFind[kf]];/\*offset because there are 18 columns in the ILK_ file but could be placed else where *\/ */ |
/* k=18+Tvar[TvarFind[kf]];/\*offset because there are 18 columns in the ILK_ file but could be placed else where *\/ */ |
k=18+kf;/*offset because there are 18 columns in the ILK_ file */ |
/* k=18+kf;/\*offset because there are 18 columns in the ILK_ file *\/ */ |
|
k=19+kf;/*offset because there are 19 columns in the ILK_ file */ |
for (i=1; i<= nlstate ; i ++) { |
for (i=1; i<= nlstate ; i ++) { |
fprintf(ficgp,"\nset out \"%s-p%dj-%d.png\";set ylabel \"Probability for each individual/wave\";",subdirf2(optionfilefiname,"ILK_"),i,kvar); |
fprintf(ficgp,"\nset out \"%s-p%dj-%d.png\";set ylabel \"Probability for each individual/wave\";",subdirf2(optionfilefiname,"ILK_"),i,kvar); |
fprintf(ficgp,"unset log;\n# For each simple dummy covariate of the model \n plot \"%s\"",subdirf(fileresilk)); |
fprintf(ficgp,"unset log;\n# For each simple dummy covariate of the model \n plot \"%s\"",subdirf(fileresilk)); |
Line 9085 set ter svg size 640, 480\nunset log y\n
|
Line 9118 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",ioffset); |
kl=0; |
kl=0; |
strcpy(gplotcondition,"("); |
strcpy(gplotcondition,"("); |
for (k=1; k<=cptcoveff; k++){ /* For each covariate writing the chain of conditions */ |
/* 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= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */ |
lv=codtabm(k1,TnsdVar[Tvaraff[k]]); |
for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */ |
|
/* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */ |
|
lv=Tvresult[nres][k]; |
|
vlv=TinvDoQresult[nres][Tvresult[nres][k]]; |
/* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ |
/* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ |
/* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */ |
/* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */ |
/* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */ |
/* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */ |
/* vlv= nbcode[Tvaraff[k]][lv]; /\* Value of the modality of Tvaraff[k] *\/ */ |
/* vlv= nbcode[Tvaraff[k]][lv]; /\* Value of the modality of Tvaraff[k] *\/ */ |
vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; |
/* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */ |
kl++; |
kl++; |
sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]); |
/* sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]); */ |
|
sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,lv, kl+1, vlv ); |
kl++; |
kl++; |
if(k <cptcoveff && cptcoveff>1) |
if(k <cptcovs && cptcovs>1) |
sprintf(gplotcondition+strlen(gplotcondition)," && "); |
sprintf(gplotcondition+strlen(gplotcondition)," && "); |
} |
} |
strcpy(gplotcondition+strlen(gplotcondition),")"); |
strcpy(gplotcondition+strlen(gplotcondition),")"); |
Line 9180 set ter svg size 640, 480\nunset log y\n
|
Line 9217 set ter svg size 640, 480\nunset log y\n
|
}else{ |
}else{ |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp,",\\\n '' "); |
} |
} |
if(cptcoveff ==0){ /* No covariate */ |
/* if(cptcoveff ==0){ /\* No covariate *\/ */ |
|
if(cptcovs ==0){ /* No covariate */ |
ioffset=2; /* Age is in 2 */ |
ioffset=2; /* Age is in 2 */ |
/*# yearproj age p11 p21 p31 p.1 p12 p22 p32 p.2 p13 p23 p33 p.3 p14 p24 p34 p.4*/ |
/*# yearproj age p11 p21 p31 p.1 p12 p22 p32 p.2 p13 p23 p33 p.3 p14 p24 p34 p.4*/ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
Line 9292 set ter svg size 640, 480\nunset log y\n
|
Line 9330 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficgp,"#Number of graphics: first is logit, 2nd is probabilities, third is incidences per year\n"); |
fprintf(ficgp,"#Number of graphics: first is logit, 2nd is probabilities, third is incidences per year\n"); |
fprintf(ficgp,"#model=1+age+%s \n",model); |
fprintf(ficgp,"#model=1+age+%s \n",model); |
fprintf(ficgp,"# Type of graphic ng=%d\n",ng); |
fprintf(ficgp,"# Type of graphic ng=%d\n",ng); |
fprintf(ficgp,"# k1=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */ |
/* fprintf(ficgp,"# k1=1 to 2^%d=%d\n",cptcoveff,m);/\* to be checked *\/ */ |
|
fprintf(ficgp,"# k1=1 to 2^%d=%d\n",cptcovs,m);/* to be checked */ |
/* for(k1=1; k1 <=m; k1++) /\* For each combination of covariate *\/ */ |
/* for(k1=1; k1 <=m; k1++) /\* For each combination of covariate *\/ */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
/* k1=nres; */ |
/* k1=nres; */ |
Line 9421 set ter svg size 640, 480\nunset log y\n
|
Line 9460 set ter svg size 640, 480\nunset log y\n
|
if(cptcovdageprod >0){ |
if(cptcovdageprod >0){ |
/* if(j==Tprod[ijp]) { */ /* not necessary */ |
/* if(j==Tprod[ijp]) { */ /* not necessary */ |
/* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */ |
/* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */ |
if(ijp <=cptcovprod) { /* Product */ |
if(ijp <=cptcovprod) { /* Product Vn*Vm and age*VN*Vm*/ |
if(DummyV[Tvard[ijp][1]]==0){/* Vn is dummy */ |
if(DummyV[Tvardk[ijp][1]]==0){/* Vn is dummy */ |
if(DummyV[Tvard[ijp][2]]==0){/* Vn and Vm are dummy */ |
if(DummyV[Tvardk[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,nbcode[Tvard[ijp][1]][codtabm(k1,j)],nbcode[Tvard[ijp][2]][codtabm(k1,j)]); */ |
fprintf(ficgp,"+p%d*%d*%d*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]); |
fprintf(ficgp,"+p%d*%d*%d*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]); |
}else{ /* Vn is dummy and Vm is quanti */ |
}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,nbcode[Tvard[ijp][1]][codtabm(k1,j)],Tqinvresult[nres][Tvard[ijp][2]]); */ |
fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); |
fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvardk[ijp][1]],Tqinvresult[nres][Tvardk[ijp][2]]); |
} |
} |
}else{ /* Vn*Vm Vn is quanti */ |
}else{ /* age* Vn*Vm Vn is quanti HERE */ |
if(DummyV[Tvard[ijp][2]]==0){ |
if(DummyV[Tvard[ijp][2]]==0){ |
fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]); |
fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvardk[ijp][2]],Tqinvresult[nres][Tvardk[ijp][1]]); |
}else{ /* Both quanti */ |
}else{ /* Both quanti */ |
fprintf(ficgp,"+p%d*%f*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); |
fprintf(ficgp,"+p%d*%f*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvardk[ijp][1]],Tqinvresult[nres][Tvardk[ijp][2]]); |
} |
} |
} |
} |
ijp++; |
ijp++; |
Line 9533 set ter svg size 640, 480\nunset log y\n
|
Line 9572 set ter svg size 640, 480\nunset log y\n
|
/* if(j==Tprod[ijp]) { /\* *\/ */ |
/* if(j==Tprod[ijp]) { /\* *\/ */ |
/* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */ |
/* printf("Tprod[%d]=%d, j=%d\n", ij, Tprod[ijp], j); */ |
if(ijp <=cptcovprod) { /* Product */ |
if(ijp <=cptcovprod) { /* Product */ |
if(DummyV[Tvard[ijp][1]]==0){/* Vn is dummy */ |
if(DummyV[Tvardk[ijp][1]]==0){/* Vn is dummy */ |
if(DummyV[Tvard[ijp][2]]==0){/* Vn and Vm are dummy */ |
if(DummyV[Tvardk[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,nbcode[Tvard[ijp][1]][codtabm(k1,j)],nbcode[Tvard[ijp][2]][codtabm(k1,j)]); */ |
fprintf(ficgp,"+p%d*%d*%d*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvard[ijp][1]],Tinvresult[nres][Tvard[ijp][2]]); |
fprintf(ficgp,"+p%d*%d*%d*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvardk[ijp][1]],Tinvresult[nres][Tvardk[ijp][2]]); |
/* fprintf(ficgp,"+p%d*%d*%d",i+j+2+nagesqr-1,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 */ |
}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,nbcode[Tvard[ijp][1]][codtabm(k1,j)],Tqinvresult[nres][Tvard[ijp][2]]); */ |
fprintf(ficgp,"+p%d*%d*%f*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); |
fprintf(ficgp,"+p%d*%d*%f*x",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvardk[ijp][1]],Tqinvresult[nres][Tvardk[ijp][2]]); |
/* fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */ |
/* fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */ |
} |
} |
}else{ /* Vn*Vm Vn is quanti */ |
}else{ /* Vn*Vm Vn is quanti */ |
if(DummyV[Tvard[ijp][2]]==0){ |
if(DummyV[Tvardk[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",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tinvresult[nres][Tvardk[ijp][2]],Tqinvresult[nres][Tvardk[ijp][1]]); |
/* fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]); */ |
/* fprintf(ficgp,"+p%d*%d*%f*x",i+j+2+nagesqr-1,Tinvresult[nres][Tvard[ijp][2]],Tqinvresult[nres][Tvard[ijp][1]]); */ |
}else{ /* Both quanti */ |
}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",k3+(cpt-1)*ncovmodel+1+j+nagesqr,Tqinvresult[nres][Tvardk[ijp][1]],Tqinvresult[nres][Tvardk[ijp][2]]); |
/* fprintf(ficgp,"+p%d*%f*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */ |
/* fprintf(ficgp,"+p%d*%f*%f*x",i+j+2+nagesqr-1,Tqinvresult[nres][Tvard[ijp][1]],Tqinvresult[nres][Tvard[ijp][2]]); */ |
} |
} |
} |
} |
Line 9910 void prevforecast(char fileres[], double
|
Line 9949 void prevforecast(char fileres[], double
|
/* date2dmy(dateintmean,&jintmean,&mintmean,&aintmean); */ |
/* date2dmy(dateintmean,&jintmean,&mintmean,&aintmean); */ |
/* date2dmy(dateprojd,&jprojd, &mprojd, &anprojd); */ |
/* date2dmy(dateprojd,&jprojd, &mprojd, &anprojd); */ |
/* date2dmy(dateprojf,&jprojf, &mprojf, &anprojf); */ |
/* date2dmy(dateprojf,&jprojf, &mprojf, &anprojf); */ |
i1=pow(2,cptcoveff); |
/* i1=pow(2,cptcoveff); */ |
if (cptcovn < 1){i1=1;} |
/* if (cptcovn < 1){i1=1;} */ |
|
|
fprintf(ficresf,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
fprintf(ficresf,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
|
|
fprintf(ficresf,"#****** Routine prevforecast **\n"); |
fprintf(ficresf,"#****** Routine prevforecast **\n"); |
|
|
/* if (h==(int)(YEARM*yearp)){ */ |
/* if (h==(int)(YEARM*yearp)){ */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k=1; k<=i1;k++){ /* We want to find the combination k corresponding to the values of the dummies given in this resut line (to be cleaned one day) */ |
k=TKresult[nres]; |
if(i1 != 1 && TKresult[nres]!= k) |
if(TKresult[nres]==0) k=1; /* To be checked for noresult */ |
continue; |
/* for(k=1; k<=i1;k++){ /\* We want to find the combination k corresponding to the values of the dummies given in this resut line (to be cleaned one day) *\/ */ |
if(invalidvarcomb[k]){ |
/* if(i1 != 1 && TKresult[nres]!= k) */ |
printf("\nCombination (%d) projection ignored because no cases \n",k); |
/* continue; */ |
continue; |
/* if(invalidvarcomb[k]){ */ |
} |
/* printf("\nCombination (%d) projection ignored because no cases \n",k); */ |
|
/* continue; */ |
|
/* } */ |
fprintf(ficresf,"\n#****** hpijx=probability over h years, hp.jx is weighted by observed prev \n#"); |
fprintf(ficresf,"\n#****** hpijx=probability over h years, hp.jx is weighted by observed prev \n#"); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcovs;j++){ |
/* fprintf(ficresf," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,Tvaraff[j])]); */ |
/* for(j=1;j<=cptcoveff;j++) { */ |
fprintf(ficresf," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); |
/* /\* fprintf(ficresf," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,Tvaraff[j])]); *\/ */ |
} |
/* fprintf(ficresf," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */ |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
/* } */ |
fprintf(ficresf," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); |
/* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */ |
|
/* fprintf(ficresf," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */ |
|
/* } */ |
|
fprintf(ficresf," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
} |
} |
|
|
fprintf(ficresf," yearproj age"); |
fprintf(ficresf," yearproj age"); |
for(j=1; j<=nlstate+ndeath;j++){ |
for(j=1; j<=nlstate+ndeath;j++){ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
Line 9958 void prevforecast(char fileres[], double
|
Line 10003 void prevforecast(char fileres[], double
|
} |
} |
} |
} |
fprintf(ficresf,"\n"); |
fprintf(ficresf,"\n"); |
for(j=1;j<=cptcoveff;j++) |
/* for(j=1;j<=cptcoveff;j++) */ |
|
for(j=1;j<=cptcovs;j++) |
|
fprintf(ficresf,"%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
/* fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,Tvaraff[j])]); /\* Tvaraff not correct *\/ */ |
/* fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,Tvaraff[j])]); /\* Tvaraff not correct *\/ */ |
fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); /* TnsdVar[Tvaraff] correct */ |
/* fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); /\* TnsdVar[Tvaraff] correct *\/ */ |
fprintf(ficresf,"%.f %.f ",anprojd+yearp,agec+h*hstepm/YEARM*stepm); |
fprintf(ficresf,"%.f %.f ",anprojd+yearp,agec+h*hstepm/YEARM*stepm); |
|
|
for(j=1; j<=nlstate+ndeath;j++) { |
for(j=1; j<=nlstate+ndeath;j++) { |
Line 10052 void prevforecast(char fileres[], double
|
Line 10099 void prevforecast(char fileres[], double
|
/* if(jintmean==0) jintmean=1; */ |
/* if(jintmean==0) jintmean=1; */ |
/* if(mintmean==0) jintmean=1; */ |
/* if(mintmean==0) jintmean=1; */ |
|
|
i1=pow(2,cptcoveff); |
/* i1=pow(2,cptcoveff); */ |
if (cptcovn < 1){i1=1;} |
/* if (cptcovn < 1){i1=1;} */ |
|
|
fprintf(ficresfb,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
fprintf(ficresfb,"# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
printf("# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
printf("# Mean day of interviews %.lf/%.lf/%.lf (%.2f) between %.2f and %.2f \n",jintmean,mintmean,aintmean,dateintmean,dateprev1,dateprev2); |
|
|
fprintf(ficresfb,"#****** Routine prevbackforecast **\n"); |
fprintf(ficresfb,"#****** Routine prevbackforecast **\n"); |
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k=1; k<=i1;k++){ |
k=TKresult[nres]; |
if(i1 != 1 && TKresult[nres]!= k) |
if(TKresult[nres]==0) k=1; /* To be checked for noresult */ |
continue; |
/* for(k=1; k<=i1;k++){ */ |
if(invalidvarcomb[k]){ |
/* if(i1 != 1 && TKresult[nres]!= k) */ |
printf("\nCombination (%d) projection ignored because no cases \n",k); |
/* continue; */ |
continue; |
/* if(invalidvarcomb[k]){ */ |
} |
/* printf("\nCombination (%d) projection ignored because no cases \n",k); */ |
|
/* continue; */ |
|
/* } */ |
fprintf(ficresfb,"\n#****** hbijx=probability over h years, hb.jx is weighted by observed prev \n#"); |
fprintf(ficresfb,"\n#****** hbijx=probability over h years, hb.jx is weighted by observed prev \n#"); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcovs;j++){ |
fprintf(ficresfb," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); |
/* for(j=1;j<=cptcoveff;j++) { */ |
} |
/* fprintf(ficresfb," V%d (=) %d",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */ |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
/* } */ |
fprintf(ficresf," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); |
fprintf(ficresfb," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
} |
} |
|
/* fprintf(ficrespij,"******\n"); */ |
|
/* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */ |
|
/* fprintf(ficresfb," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */ |
|
/* } */ |
fprintf(ficresfb," yearbproj age"); |
fprintf(ficresfb," yearbproj age"); |
for(j=1; j<=nlstate+ndeath;j++){ |
for(j=1; j<=nlstate+ndeath;j++){ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
Line 10105 void prevforecast(char fileres[], double
|
Line 10158 void prevforecast(char fileres[], double
|
} |
} |
} |
} |
fprintf(ficresfb,"\n"); |
fprintf(ficresfb,"\n"); |
for(j=1;j<=cptcoveff;j++) |
/* for(j=1;j<=cptcoveff;j++) */ |
fprintf(ficresfb,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); |
for(j=1;j<=cptcovs;j++) |
|
fprintf(ficresfb,"%d %lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
|
/* fprintf(ficresfb,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */ |
fprintf(ficresfb,"%.f %.f ",anbackd+yearp,agec-h*hstepm/YEARM*stepm); |
fprintf(ficresfb,"%.f %.f ",anbackd+yearp,agec-h*hstepm/YEARM*stepm); |
for(i=1; i<=nlstate+ndeath;i++) { |
for(i=1; i<=nlstate+ndeath;i++) { |
ppij=0.;ppi=0.; |
ppij=0.;ppi=0.; |
Line 11070 int decoderesult( char resultline[], int
|
Line 11125 int decoderesult( char resultline[], int
|
if (strlen(resultsav) >1){ |
if (strlen(resultsav) >1){ |
j=nbocc(resultsav,'='); /**< j=Number of covariate values'=' in this resultline */ |
j=nbocc(resultsav,'='); /**< j=Number of covariate values'=' in this resultline */ |
} |
} |
if(j == 0){ /* Resultline but no = */ |
if(j == 0 && cptcovs== 0){ /* Resultline but no = and no covariate in the model */ |
TKresult[nres]=0; /* Combination for the nresult and the model */ |
TKresult[nres]=0; /* Combination for the nresult and the model */ |
return (0); |
return (0); |
} |
} |
if( j != cptcovs ){ /* Be careful if a variable is in a product but not single */ |
if( j != cptcovs ){ /* Be careful if a variable is in a product but not single */ |
printf("ERROR: the number of variables in the resultline which is %d, differs from the number %d of single variables used in the model line, %s.\n",j, cptcovs, model); |
fprintf(ficlog,"ERROR: the number of variables in the resultline which is %d, differs from the number %d of single variables used in the model line, 1+age+%s.\n",j, cptcovs, model);fflush(ficlog); |
fprintf(ficlog,"ERROR: the number of variables in the resultline which is %d, differs from the number %d of single variables used in the model line, %s.\n",j, cptcovs, model); |
printf("ERROR: the number of variables in the resultline which is %d, differs from the number %d of single variables used in the model line, 1+age+%s.\n",j, cptcovs, model);fflush(stdout); |
/* return 1;*/ |
if(j==0) |
|
return 1; |
} |
} |
for(k=1; k<=j;k++){ /* Loop on any covariate of the RESULT LINE */ |
for(k=1; k<=j;k++){ /* Loop on any covariate of the RESULT LINE */ |
if(nbocc(resultsav,'=') >1){ |
if(nbocc(resultsav,'=') >1){ |
Line 11260 int decoderesult( char resultline[], int
|
Line 11316 int decoderesult( char resultline[], int
|
precov[nres][k1]=Tvalsel[k3q]; |
precov[nres][k1]=Tvalsel[k3q]; |
/* printf("Decoderesult Quantitative nres=%d,precov[nres=%d][k1=%d]=%.f V(k2q=V%d)= Tvalsel[%d]=%d, Tvarsel[%d]=%f\n",nres, nres, k1,precov[nres][k1], k2q, k3q, Tvarsel[k3q], k3q, Tvalsel[k3q]); */ |
/* printf("Decoderesult Quantitative nres=%d,precov[nres=%d][k1=%d]=%.f V(k2q=V%d)= Tvalsel[%d]=%d, Tvarsel[%d]=%f\n",nres, nres, k1,precov[nres][k1], k2q, k3q, Tvarsel[k3q], k3q, Tvalsel[k3q]); */ |
k4q++;; |
k4q++;; |
}else if( Dummy[k1]==2 ){ /* For dummy with age product */ |
}else if( Dummy[k1]==2 ){ /* For dummy with age product "V2+V3+V4+V6+V7+V6*V2+V7*V2+V6*V3+V7*V3+V6*V4+V7*V4+age*V2+age*V3+age*V4+age*V6+age*V7+age*V6*V2+age*V6*V3+age*V7*V3+age*V6*V4+age*V7*V4\r"*/ |
/* Tvar[k1]; */ /* Age variable */ |
/* Tvar[k1]; */ /* Age variable */ /* 17 age*V6*V2 ?*/ |
/* Wrong we want the value of variable name Tvar[k1] */ |
/* Wrong we want the value of variable name Tvar[k1] */ |
|
if(Typevar[k1]==2 || Typevar[k1]==3 ){ /* For product quant or dummy (with or without age) */ |
k3= resultmodel[nres][k1]; /* nres=1 k1=2 resultmodel[2(V4)] = 1=k3 ; k1=3 resultmodel[3(V3)] = 2=k3*/ |
precov[nres][k1]=TinvDoQresult[nres][Tvardk[k1][1]] * TinvDoQresult[nres][Tvardk[k1][2]]; |
k2=(int)Tvarsel[k3]; /* nres=1 k1=2=>k3=1 Tvarsel[resultmodel[2]]= Tvarsel[1] = 4=k2 (V4); k1=3=>k3=2 Tvarsel[2]=3 (V3)*/ |
/* printf("Decoderesult Quantitative or Dummy (not with age) nres=%d k1=%d precov[nres=%d][k1=%d]=%.f V%d(=%.f) * V%d(=%.f) \n",nres, k1, nres, k1,precov[nres][k1], Tvardk[k1][1], TinvDoQresult[nres][Tvardk[k1][1]], Tvardk[k1][2], TinvDoQresult[nres][Tvardk[k1][2]]); */ |
TinvDoQresult[nres][(int)Tvarsel[k3]]=Tvalsel[k3]; /* TinvDoQresult[nres][4]=1 */ |
}else{ |
precov[nres][k1]=Tvalsel[k3]; |
k3= resultmodel[nres][k1]; /* nres=1 k1=2 resultmodel[2(V4)] = 1=k3 ; k1=3 resultmodel[3(V3)] = 2=k3*/ |
|
k2=(int)Tvarsel[k3]; /* nres=1 k1=2=>k3=1 Tvarsel[resultmodel[2]]= Tvarsel[1] = 4=k2 (V4); k1=3=>k3=2 Tvarsel[2]=3 (V3)*/ |
|
TinvDoQresult[nres][(int)Tvarsel[k3]]=Tvalsel[k3]; /* TinvDoQresult[nres][4]=1 */ |
|
precov[nres][k1]=Tvalsel[k3]; |
|
} |
/* printf("Decoderesult Dummy with age k=%d, k1=%d precov[nres=%d][k1=%d]=%.f Tvar[%d]=V%d k2=Tvarsel[%d]=%d Tvalsel[%d]=%d\n",k, k1, nres, k1,precov[nres][k1], k1, Tvar[k1], k3,(int)Tvarsel[k3], k3, (int)Tvalsel[k3]); */ |
/* printf("Decoderesult Dummy with age k=%d, k1=%d precov[nres=%d][k1=%d]=%.f Tvar[%d]=V%d k2=Tvarsel[%d]=%d Tvalsel[%d]=%d\n",k, k1, nres, k1,precov[nres][k1], k1, Tvar[k1], k3,(int)Tvarsel[k3], k3, (int)Tvalsel[k3]); */ |
}else if( Dummy[k1]==3 ){ /* For quant with age product */ |
}else if( Dummy[k1]==3 ){ /* For quant with age product */ |
k3q= resultmodel[nres][k1]; /* resultmodel[1(V5)] = 25.1=k3q */ |
if(Typevar[k1]==2 || Typevar[k1]==3 ){ /* For product quant or dummy (with or without age) */ |
k2q=(int)Tvarsel[k3q]; /* Tvarsel[resultmodel[1]]= Tvarsel[1] = 4=k2 */ |
precov[nres][k1]=TinvDoQresult[nres][Tvardk[k1][1]] * TinvDoQresult[nres][Tvardk[k1][2]]; |
TinvDoQresult[nres][(int)Tvarsel[k3q]]=Tvalsel[k3q]; /* TinvDoQresult[nres][5]=25.1 */ |
/* printf("Decoderesult Quantitative or Dummy (not with age) nres=%d k1=%d precov[nres=%d][k1=%d]=%.f V%d(=%.f) * V%d(=%.f) \n",nres, k1, nres, k1,precov[nres][k1], Tvardk[k1][1], TinvDoQresult[nres][Tvardk[k1][1]], Tvardk[k1][2], TinvDoQresult[nres][Tvardk[k1][2]]); */ |
precov[nres][k1]=Tvalsel[k3q]; |
}else{ |
|
k3q= resultmodel[nres][k1]; /* resultmodel[1(V5)] = 25.1=k3q */ |
|
k2q=(int)Tvarsel[k3q]; /* Tvarsel[resultmodel[1]]= Tvarsel[1] = 4=k2 */ |
|
TinvDoQresult[nres][(int)Tvarsel[k3q]]=Tvalsel[k3q]; /* TinvDoQresult[nres][5]=25.1 */ |
|
precov[nres][k1]=Tvalsel[k3q]; |
|
} |
/* printf("Decoderesult Quantitative with age nres=%d, k1=%d, precov[nres=%d][k1=%d]=%f Tvar[%d]=V%d V(k2q=%d)= Tvarsel[%d]=%d, Tvalsel[%d]=%f\n",nres, k1, nres, k1,precov[nres][k1], k1, Tvar[k1], k2q, k3q, Tvarsel[k3q], k3q, Tvalsel[k3q]); */ |
/* printf("Decoderesult Quantitative with age nres=%d, k1=%d, precov[nres=%d][k1=%d]=%f Tvar[%d]=V%d V(k2q=%d)= Tvarsel[%d]=%d, Tvalsel[%d]=%f\n",nres, k1, nres, k1,precov[nres][k1], k1, Tvar[k1], k2q, k3q, Tvarsel[k3q], k3q, Tvalsel[k3q]); */ |
}else if(Typevar[k1]==2 || Typevar[k1]==3 ){ /* For product quant or dummy (with or without age) */ |
}else if(Typevar[k1]==2 || Typevar[k1]==3 ){ /* For product quant or dummy (with or without age) */ |
precov[nres][k1]=TinvDoQresult[nres][Tvardk[k1][1]] * TinvDoQresult[nres][Tvardk[k1][2]]; |
precov[nres][k1]=TinvDoQresult[nres][Tvardk[k1][1]] * TinvDoQresult[nres][Tvardk[k1][2]]; |
Line 11356 int decodemodel( char model[], int lasto
|
Line 11421 int decodemodel( char model[], int lasto
|
if (strlen(modelsav) >1){ /* V2 +V3 +V4 +V6 +V7 +V6*V2 +V7*V2 +V6*V3 +V7*V3 +V6*V4 +V7*V4 +age*V2 +age*V3 +age*V4 +age*V6 +age*V7 +age*V6*V2 +V7*V2 +age*V6*V3 +age*V7*V3 +age*V6*V4 +age*V7*V4 */ |
if (strlen(modelsav) >1){ /* V2 +V3 +V4 +V6 +V7 +V6*V2 +V7*V2 +V6*V3 +V7*V3 +V6*V4 +V7*V4 +age*V2 +age*V3 +age*V4 +age*V6 +age*V7 +age*V6*V2 +V7*V2 +age*V6*V3 +age*V7*V3 +age*V6*V4 +age*V7*V4 */ |
j=nbocc(modelsav,'+'); /**< j=Number of '+' */ |
j=nbocc(modelsav,'+'); /**< j=Number of '+' */ |
j1=nbocc(modelsav,'*'); /**< j1=Number of '*' */ |
j1=nbocc(modelsav,'*'); /**< j1=Number of '*' */ |
cptcovs=j+1-j1; /**< Number of simple covariates V1 +V1*age +V3 +V3*V4 +age*age => V1 + V3 =4+1-3=2 */ |
cptcovs=0; /**< Number of simple covariates V1 +V1*age +V3 +V3*V4 +age*age => V1 + V3 =4+1-3=2 Wrong */ |
cptcovt= j+1; /* Number of total covariates in the model, not including |
cptcovt= j+1; /* Number of total covariates in the model, not including |
* cst, age and age*age |
* cst, age and age*age |
* V1+V1*age+ V3 + V3*V4+age*age=> 3+1=4*/ |
* V1+V1*age+ V3 + V3*V4+age*age=> 3+1=4*/ |
Line 11421 int decodemodel( char model[], int lasto
|
Line 11486 int decodemodel( char model[], int lasto
|
Tvar[k]=0; Tprod[k]=0; Tposprod[k]=0; |
Tvar[k]=0; Tprod[k]=0; Tposprod[k]=0; |
} |
} |
cptcovage=0; |
cptcovage=0; |
|
|
|
/* First loop in order to calculate */ |
|
/* for age*VN*Vm |
|
* Provides, Typevar[k], Tage[cptcovage], existcomb[n][m], FixedV[ncovcolt+k12] |
|
* Tprod[k1]=k Tposprod[k]=k1; Tvard[k1][1] =m; |
|
*/ |
|
/* Needs FixedV[Tvardk[k][1]] */ |
|
/* For others: |
|
* Sets Typevar[k]; |
|
* Tvar[k]=ncovcol+nqv+ntv+nqtv+k11; |
|
* Tposprod[k]=k11; |
|
* Tprod[k11]=k; |
|
* Tvardk[k][1] =m; |
|
* Needs FixedV[Tvardk[k][1]] == 0 |
|
*/ |
|
|
for(k=1; k<=cptcovt;k++){ /* Loop on total covariates of the model line */ |
for(k=1; k<=cptcovt;k++){ /* Loop on total covariates of the model line */ |
cutl(stra,strb,modelsav,'+'); /* keeps in strb after the first '+' cutl from left to right |
cutl(stra,strb,modelsav,'+'); /* keeps in strb after the first '+' cutl from left to right |
modelsav==V2+V1+V5*age+V4+V3*age strb=V3*age stra=V2+V1V5*age+V4 */ /* <model> "V5+V4+V3+V4*V3+V5*age+V1*age+V1" strb="V5" stra="V4+V3+V4*V3+V5*age+V1*age+V1" */ |
modelsav==V2+V1+V5*age+V4+V3*age strb=V3*age stra=V2+V1V5*age+V4 */ /* <model> "V5+V4+V3+V4*V3+V5*age+V1*age+V1" strb="V5" stra="V4+V3+V4*V3+V5*age+V1*age+V1" */ |
Line 11446 int decodemodel( char model[], int lasto
|
Line 11527 int decodemodel( char model[], int lasto
|
strcat(strb,stre); |
strcat(strb,stre); |
strcpy(strd,strb); /* in order for strd to not be "age" for next test (will be Vn*Vm */ |
strcpy(strd,strb); /* in order for strd to not be "age" for next test (will be Vn*Vm */ |
} |
} |
printf("DEBUG FIXED k=%d, Tage[k]=%d, Tvar[Tage[k]=%d,FixedV[Tvar[Tage[k]]]=%d\n",k,Tage[k],Tvar[Tage[k]],FixedV[Tvar[Tage[k]]]); |
/* printf("DEBUG FIXED k=%d, Tage[k]=%d, Tvar[Tage[k]=%d,FixedV[Tvar[Tage[k]]]=%d\n",k,Tage[k],Tvar[Tage[k]],FixedV[Tvar[Tage[k]]]); */ |
FixedV[Tvar[Tage[k]]]=0; /* HERY not sure */ |
/* FixedV[Tvar[Tage[k]]]=0; /\* HERY not sure if V7*V4*age Fixed might not exist yet*\/ */ |
}else{ /* strc=Vn*Vm (and strd=age) and should be strb=Vn*Vm but want to keep original strb double product */ |
}else{ /* strc=Vn*Vm (and strd=age) and should be strb=Vn*Vm but want to keep original strb double product */ |
strcpy(stre,strb); /* save full b in stre */ |
strcpy(stre,strb); /* save full b in stre */ |
strcpy(strb,strc); /* save short c in new short b for next block strb=Vn*Vm*/ |
strcpy(strb,strc); /* save short c in new short b for next block strb=Vn*Vm*/ |
Line 11480 int decodemodel( char model[], int lasto
|
Line 11561 int decodemodel( char model[], int lasto
|
Tvardk[k][1] =m; /* m 1 for V1*/ |
Tvardk[k][1] =m; /* m 1 for V1*/ |
Tvard[k1][2] =n; /* n 4 for V4*/ |
Tvard[k1][2] =n; /* n 4 for V4*/ |
Tvardk[k][2] =n; /* n 4 for V4*/ |
Tvardk[k][2] =n; /* n 4 for V4*/ |
/* Tvar[Tage[cptcovage]]=k1;*/ /* Tvar[6=age*V3*V2]=9 (new fixed covariate) */ |
/* Tvar[Tage[cptcovage]]=k1;*/ /* Tvar[6=age*V3*V2]=9 (new fixed covariate) */ /* We don't know about Fixed yet HERE */ |
if( FixedV[Tvardk[k][1]] == 0 && FixedV[Tvardk[k][2]] == 0){ /* If the product is a fixed covariate then we feed the new column with Vn*Vm */ |
if( FixedV[Tvardk[k][1]] == 0 && FixedV[Tvardk[k][2]] == 0){ /* If the product is a fixed covariate then we feed the new column with Vn*Vm */ |
for (i=1; i<=lastobs;i++){/* For fixed product */ |
for (i=1; i<=lastobs;i++){/* For fixed product */ |
/* Computes the new covariate which is a product of |
/* Computes the new covariate which is a product of |
Line 11630 int decodemodel( char model[], int lasto
|
Line 11711 int decodemodel( char model[], int lasto
|
/*printf("a=%s b=%s sav=%s\n", stra,strb,modelsav); |
/*printf("a=%s b=%s sav=%s\n", stra,strb,modelsav); |
scanf("%d",i);*/ |
scanf("%d",i);*/ |
} /* end of loop + on total covariates */ |
} /* end of loop + on total covariates */ |
|
|
|
|
} /* end if strlen(modelsave == 0) age*age might exist */ |
} /* end if strlen(modelsave == 0) age*age might exist */ |
} /* end if strlen(model == 0) */ |
} /* end if strlen(model == 0) */ |
cptcovs=cptcovt - cptcovdageprod - cptcovprod;/**< Number of simple covariates V1 +V1*age +V3 +V3*V4 +age*age + age*v4*V3=> V1 + V3 =4+1-3=2 */ |
cptcovs=cptcovt - cptcovdageprod - cptcovprod;/**< Number of simple covariates V1 +V1*age +V3 +V3*V4 +age*age + age*v4*V3=> V1 + V3 =4+1-3=2 */ |
Line 11668 Fixed[k] 0=fixed (product or simple), 1
|
Line 11751 Fixed[k] 0=fixed (product or simple), 1
|
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); |
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<=NCOVMAX; k++){ Fixed[k]=0; Dummy[k]=0;} |
for(k=-1;k<=NCOVMAX; k++){ Fixed[k]=0; Dummy[k]=0;} |
for(k=1;k<=NCOVMAX; k++){TvarFind[k]=0; TvarVind[k]=0;} |
for(k=1;k<=NCOVMAX; k++){TvarFind[k]=0; TvarVind[k]=0;} |
|
|
|
|
|
/* Second loop for calculating Fixed[k], Dummy[k]*/ |
|
|
|
|
for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0,ncovva=0,ncovvta=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0, ncovvt=0;k<=cptcovt; k++){ /* or cptocvt loop on k from model */ |
for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0,ncovva=0,ncovvta=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0, ncovvt=0;k<=cptcovt; k++){ /* or cptocvt loop on k from model */ |
if (Tvar[k] <=ncovcol && Typevar[k]==0 ){ /* Simple fixed dummy (<=ncovcol) covariates */ |
if (Tvar[k] <=ncovcol && Typevar[k]==0 ){ /* Simple fixed dummy (<=ncovcol) covariates */ |
Fixed[k]= 0; |
Fixed[k]= 0; |
Line 12921 int main(int argc, char *argv[])
|
Line 13009 int main(int argc, char *argv[])
|
/* double ***mobaverage; */ |
/* double ***mobaverage; */ |
double wald; |
double wald; |
|
|
char line[MAXLINE]; |
char line[MAXLINE], linetmp[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE]; |
|
|
char modeltemp[MAXLINE]; |
char modeltemp[MAXLINE]; |
Line 13254 int main(int argc, char *argv[])
|
Line 13342 int main(int argc, char *argv[])
|
}else |
}else |
break; |
break; |
} |
} |
if((num_filled=sscanf(line,"model=1+age%[^.\n]", model)) !=EOF){ |
if((num_filled=sscanf(line,"model=%[^.\n]", model)) !=EOF){ /* Every character after model but dot and return */ |
|
if (num_filled != 1){ |
|
printf("ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
|
fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
|
model[0]='\0'; |
|
goto end; |
|
}else{ |
|
trimbtab(linetmp,line); /* Trims multiple blanks in line */ |
|
strcpy(line, linetmp); |
|
} |
|
} |
|
if((num_filled=sscanf(line,"model=1+age%[^.\n]", model)) !=EOF){ /* Every character after 1+age but dot and return */ |
if (num_filled != 1){ |
if (num_filled != 1){ |
printf("ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
printf("ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age+' instead of '%s'\n",num_filled, line); |
Line 13627 Please run with mle=-1 to get a correct
|
Line 13726 Please run with mle=-1 to get a correct
|
Tvard=imatrix(1,NCOVMAX,1,2); /* n=Tvard[k1][1] and m=Tvard[k1][2] gives the couple n,m of the k1 th product Vn*Vm |
Tvard=imatrix(1,NCOVMAX,1,2); /* n=Tvard[k1][1] and m=Tvard[k1][2] gives the couple n,m of the k1 th product Vn*Vm |
* For V3*V2 (in V2+V1+V1*V4+age*V3+V3*V2), V3*V2 position is 2nd. |
* For V3*V2 (in V2+V1+V1*V4+age*V3+V3*V2), V3*V2 position is 2nd. |
* Tvard[k1=2][1]=3 (V3) Tvard[k1=2][2]=2(V2) */ |
* Tvard[k1=2][1]=3 (V3) Tvard[k1=2][2]=2(V2) */ |
Tvardk=imatrix(-1,NCOVMAX,1,2); |
Tvardk=imatrix(0,NCOVMAX,1,2); |
Tage=ivector(1,NCOVMAX); /* Gives the covariate id of covariates associated with age: V2 + V1 + age*V4 + V3*age |
Tage=ivector(1,NCOVMAX); /* Gives the covariate id of covariates associated with age: V2 + V1 + age*V4 + V3*age |
4 covariates (3 plus signs) |
4 covariates (3 plus signs) |
Tage[1=V3*age]= 4; Tage[2=age*V4] = 3 |
Tage[1=V3*age]= 4; Tage[2=age*V4] = 3 |
Line 14732 Please run with mle=-1 to get a correct
|
Line 14831 Please run with mle=-1 to get a correct
|
date2dmy(datebackf,&jbackf, &mbackf, &anbackf); |
date2dmy(datebackf,&jbackf, &mbackf, &anbackf); |
} |
} |
|
|
printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,bage, fage, prevfcast, prevbcast, pathc,p, (int)anprojd-bage, (int)anbackd-fage); |
printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,bage, fage, prevfcast, prevbcast, pathc,p, (int)anprojd-bage, (int)anbackd-fage);/* HERE valgrind Tvard*/ |
} |
} |
printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt, \ |
printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt, \ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,mobilav,prevfcast,mobilavproj,prevbcast, estepm, \ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,mobilav,prevfcast,mobilavproj,prevbcast, estepm, \ |
Line 14882 Please run with mle=-1 to get a correct
|
Line 14981 Please run with mle=-1 to get a correct
|
|
|
pstamp(ficreseij); |
pstamp(ficreseij); |
|
|
i1=pow(2,cptcoveff); /* Number of combination of dummy covariates */ |
/* i1=pow(2,cptcoveff); /\* Number of combination of dummy covariates *\/ */ |
if (cptcovn < 1){i1=1;} |
/* if (cptcovn < 1){i1=1;} */ |
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
/* for(k=1; k<=i1;k++){ /\* For any combination of dummy covariates, fixed and varying *\/ */ |
if(i1 != 1 && TKresult[nres]!= k) |
/* if(i1 != 1 && TKresult[nres]!= k) */ |
continue; |
/* continue; */ |
fprintf(ficreseij,"\n#****** "); |
fprintf(ficreseij,"\n#****** "); |
printf("\n#****** "); |
printf("\n#****** "); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcovs;j++){ |
fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); |
/* for(j=1;j<=cptcoveff;j++) { */ |
printf("V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); |
/* fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */ |
|
fprintf(ficreseij," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
|
printf(" V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); |
|
/* printf("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 */ |
for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */ |
printf(" V%d=%lg ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]); /* TvarsQ[j] gives the name of the jth quantitative (fixed or time v) */ |
printf(" V%d=%lg ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]); /* TvarsQ[j] gives the name of the jth quantitative (fixed or time v) */ |
Line 14962 Please run with mle=-1 to get a correct
|
Line 15064 Please run with mle=-1 to get a correct
|
/* */ |
/* */ |
if(i1 != 1 && TKresult[nres]!= k) /* TKresult[nres] is the combination of this nres resultline. All the i1 combinations are not output */ |
if(i1 != 1 && TKresult[nres]!= k) /* TKresult[nres] is the combination of this nres resultline. All the i1 combinations are not output */ |
continue; |
continue; |
printf("\n# model %s \n#****** Result for:", model); |
printf("\n# model %s \n#****** Result for:", model); /* HERE model is empty */ |
fprintf(ficrest,"\n# model %s \n#****** Result for:", model); |
fprintf(ficrest,"\n# model %s \n#****** Result for:", model); |
fprintf(ficlog,"\n# model %s \n#****** Result for:", model); |
fprintf(ficlog,"\n# model %s \n#****** Result for:", model); |
/* It might not be a good idea to mix dummies and quantitative */ |
/* It might not be a good idea to mix dummies and quantitative */ |
Line 15137 Please run with mle=-1 to get a correct
|
Line 15239 Please run with mle=-1 to get a correct
|
|
|
|
|
free_vector(weight,firstobs,lastobs); |
free_vector(weight,firstobs,lastobs); |
free_imatrix(Tvardk,-1,NCOVMAX,1,2); |
free_imatrix(Tvardk,0,NCOVMAX,1,2); |
free_imatrix(Tvard,1,NCOVMAX,1,2); |
free_imatrix(Tvard,1,NCOVMAX,1,2); |
free_imatrix(s,1,maxwav+1,firstobs,lastobs); |
free_imatrix(s,1,maxwav+1,firstobs,lastobs); |
free_matrix(anint,1,maxwav,firstobs,lastobs); |
free_matrix(anint,1,maxwav,firstobs,lastobs); |