version 1.344, 2022/09/14 19:33:30
|
version 1.348, 2022/09/20 00:01:38
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.348 2022/09/20 00:01:38 brouard |
|
Summary: version 0.99r43 |
|
|
|
* imach.c (Module): Version 0.99r42 needed a newer version of |
|
Gnuplot. But newer version 0.99r43 should run with the Gnuplot |
|
version 5.0 or 5.1 distributed with IMaCh. |
|
|
|
Revision 1.347 2022/09/18 14:36:44 brouard |
|
Summary: version 0.99r42 |
|
|
|
Revision 1.346 2022/09/16 13:52:36 brouard |
|
* src/imach.c (Module): 0.99r41 Was an error when product of timevarying and fixed. Using FixedV[of name] now. Thank you Feinuo |
|
|
|
Revision 1.345 2022/09/16 13:40:11 brouard |
|
Summary: Version 0.99r41 |
|
|
|
* imach.c (Module): 0.99r41 Was an error when product of timevarying and fixed. Using FixedV[of name] now. Thank you Feinuo |
|
|
Revision 1.344 2022/09/14 19:33:30 brouard |
Revision 1.344 2022/09/14 19:33:30 brouard |
Summary: version 0.99r40 |
Summary: version 0.99r40 |
|
|
Line 3949 double func( double *x)
|
Line 3967 double func( double *x)
|
*/ |
*/ |
ioffset=2+nagesqr ; |
ioffset=2+nagesqr ; |
/* Fixed */ |
/* Fixed */ |
for (kf=1; kf<=ncovf;kf++){ /* For each fixed covariate dummu or quant or prod */ |
for (kf=1; kf<=ncovf;kf++){ /* For each fixed covariate dummy or quant or prod */ |
/* # V1=sex, V2=raedyrs Quant Fixed, State=livarnb4..livarnb11, V3=iadl4..iald11, V4=adlw4..adlw11, V5=r4bmi..r11bmi */ |
/* # V1=sex, V2=raedyrs Quant Fixed, State=livarnb4..livarnb11, V3=iadl4..iald11, V4=adlw4..adlw11, V5=r4bmi..r11bmi */ |
/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ |
/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ |
/* 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[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 3978 double func( double *x)
|
Line 3996 double func( double *x)
|
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Varying covariates (single and product but no age )*/ |
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Varying covariates (single and product but no age )*/ |
itv=TvarVV[ncovv]; /* TvarVV={3, 1, 3} gives the name of each varying covariate */ |
itv=TvarVV[ncovv]; /* TvarVV={3, 1, 3} gives the name of each varying covariate */ |
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*/ |
if(TvarFind[itv]==0){ /* Not a fixed covariate */ |
if(FixedV[itv]!=0){ /* Not a fixed covariate */ |
cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* cotvar[wav][ncovcol+nqv+iv][i] */ |
cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* cotvar[wav][ncovcol+nqv+iv][i] */ |
}else{ /* fixed covariate */ |
}else{ /* fixed covariate */ |
cotvarv=covar[Tvar[TvarFind[itv]]][i]; |
cotvarv=covar[itv][i]; /* Error: TvarFind gives the name, that is the true column of fixed covariates, but Tvar of the model */ |
} |
} |
if(ipos!=iposold){ /* Not a product or first of a product */ |
if(ipos!=iposold){ /* Not a product or first of a product */ |
cotvarvold=cotvarv; |
cotvarvold=cotvarv; |
Line 4384 double funcone( double *x)
|
Line 4402 double funcone( double *x)
|
* TvarVVind 2 3 7 7 8 8 9 9 |
* TvarVVind 2 3 7 7 8 8 9 9 |
* TvarFind[k] 1 0 0 0 0 0 0 0 0 |
* TvarFind[k] 1 0 0 0 0 0 0 0 0 |
*/ |
*/ |
|
/* Other model ncovcol=5 nqv=0 ntv=3 nqtv=0 nlstate=3 |
|
* V2 V3 V4 are fixed V6 V7 are timevarying so V8 and V5 are not in the model and product column will start at 9 Tvar[4]=6 |
|
* FixedV[ncovcol+qv+ntv+nqtv] V5 |
|
* V1 V2 V3 V4 V5 V6 V7 V8 |
|
* 0 0 0 0 0 1 1 1 |
|
* model= V2 + V3 + V4 + V6 + V7 + V6*V2 + V7*V2 + V6*V3 + V7*V3 + V6*V4 + V7*V4 |
|
* kmodel 1 2 3 4 5 6 7 8 9 10 11 |
|
* ncovf 1 2 3 |
|
* ncovvt=14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
* TvarVV[1]@14 = itv {6, 7, 6, 2, 7, 2, 6, 3, 7, 3, 6, 4, 7, 4} |
|
* TvarVVind[1]@14= {4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11} |
|
* TvarFind[1]@14= {1, 2, 3, 0 <repeats 12 times>} |
|
* Tvar[1]@20= {2, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14} |
|
* TvarFind[itv] 0 0 0 |
|
* FixedV[itv] 1 1 1 0 1 0 1 0 1 0 0 |
|
* Tvar[TvarFind[ncovf]]=[1]=2 [2]=3 [4]=4 |
|
* Tvar[TvarFind[itv]] [0]=? ?ncovv 1 à ncovvt] |
|
* Not a fixed cotvar[mw][itv][i] 6 7 6 2 7, 2, 6, 3, 7, 3, 6, 4, 7, 4} |
|
* fixed covar[itv] [6] [7] [6][2] |
|
*/ |
|
|
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Varying covariates (single and product but no age) including individual from products */ |
for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Varying covariates (single and product but no age) including individual from products */ |
itv=TvarVV[ncovv]; /* TvarVV={3, 1, 3} gives the name of each varying covariate */ |
itv=TvarVV[ncovv]; /* TvarVV={3, 1, 3} gives the name of each varying covariate, exploding product */ |
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*/ |
if(TvarFind[itv]==0){ /* Not a fixed covariate */ |
/* if(TvarFind[itv]==0){ /\* Not a fixed covariate? Could be a fixed covariate of a product with a higher than ncovcol+nqv, itv *\/ */ |
cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ |
if(FixedV[itv]!=0){ /* Not a fixed covariate? Could be a fixed covariate of a product with a higher than ncovcol+nqv, itv */ |
|
cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* because cotvar starts now at first ncovcol+nqv+ntv+nqtv (1 to nqtv) */ |
}else{ /* fixed covariate */ |
}else{ /* fixed covariate */ |
cotvarv=covar[Tvar[TvarFind[itv]]][i]; |
/* cotvarv=covar[Tvar[TvarFind[itv]]][i]; /\* Error: TvarFind gives the name, that is the true column of fixed covariates, but Tvar of the model *\/ */ |
|
cotvarv=covar[itv][i]; /* Error: TvarFind gives the name, that is the true column of fixed covariates, but Tvar of the model */ |
} |
} |
if(ipos!=iposold){ /* Not a product or first of a product */ |
if(ipos!=iposold){ /* Not a product or first of a product */ |
cotvarvold=cotvarv; |
cotvarvold=cotvarv; |
Line 8193 void printinggnuplot(char fileresu[], ch
|
Line 8234 void printinggnuplot(char fileresu[], ch
|
fprintf(ficgp,"\nset ter pngcairo size 640, 480"); |
fprintf(ficgp,"\nset ter pngcairo size 640, 480"); |
/* if(debugILK==1){ */ |
/* if(debugILK==1){ */ |
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 name */ |
k=18+Tvar[TvarFind[kf]];/*offset because there are 18 columns in the ILK_ file */ |
/* 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 */ |
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)); |
fprintf(ficgp," u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable \\\n",i,1,k,k,i,1,kvar); |
if(gnuplotversion >=5.2){ /* Former gnuplot versions do not have variable pointsize!! */ |
for (j=2; j<= nlstate+ndeath ; j ++) { |
fprintf(ficgp," u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable \\\n",i,1,k,k,i,1,kvar); |
fprintf(ficgp,",\\\n \"\" u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable ",i,j,k,k,i,j,kvar); |
for (j=2; j<= nlstate+ndeath ; j ++) { |
|
fprintf(ficgp,",\\\n \"\" u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable ",i,j,k,k,i,j,kvar); |
|
} |
|
}else{ |
|
fprintf(ficgp," u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt 7 ps 0.4 lc variable \\\n",i,1,k,i,1,kvar); |
|
for (j=2; j<= nlstate+ndeath ; j ++) { |
|
fprintf(ficgp,",\\\n \"\" u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt 7 ps 0.4 lc variable ",i,j,k,i,j,kvar); |
|
} |
} |
} |
fprintf(ficgp,";\nset out; unset ylabel;\n"); |
fprintf(ficgp,";\nset out; unset ylabel;\n"); |
} |
} |
Line 8230 void printinggnuplot(char fileresu[], ch
|
Line 8279 void printinggnuplot(char fileresu[], ch
|
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)); |
|
|
|
/* printf("Before DebugILK gnuplotversion=%g >=5.2\n",gnuplotversion); */ |
if(gnuplotversion >=5.2){ /* Former gnuplot versions do not have variable pointsize!! */ |
if(gnuplotversion >=5.2){ /* Former gnuplot versions do not have variable pointsize!! */ |
/* printf("DebugILK gnuplotversion=%g >=5.2\n",gnuplotversion); */ |
/* printf("DebugILK gnuplotversion=%g >=5.2\n",gnuplotversion); */ |
fprintf(ficgp," u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable \\\n",i,1,k,k,i,1,kvar); |
fprintf(ficgp," u 2:($5 == %d && $6==%d ? $10 : 1/0):($%d==0 ? 7 : 9):($%d==0 ? $6 : $6+4) t \"p%d%d V%d\" with points pt variable ps 0.4 lc variable \\\n",i,1,k,k,i,1,kvar); |
Line 10619 int readdata(char datafile[], int firsto
|
Line 10669 int readdata(char datafile[], int firsto
|
errno=0; |
errno=0; |
lval=strtol(strb,&endptr,10); |
lval=strtol(strb,&endptr,10); |
/* if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))*/ |
/* if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))*/ |
if( strb[0]=='\0' || (*endptr != '\0')){ |
if( strb[0]=='\0' || (*endptr != '\0' )){ |
printf("Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n", strb, linei,i,line,j,maxwav); |
printf("Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n", strb, linei,i,line,j,maxwav); |
fprintf(ficlog,"Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n", strb, linei,i,line,j,maxwav);fflush(ficlog); |
fprintf(ficlog,"Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n", strb, linei,i,line,j,maxwav);fflush(ficlog); |
|
return 1; |
|
}else if( lval==0 || lval > nlstate+ndeath){ |
|
printf("Error in data around '%s' at line number %d for individual %d, '%s'\n Should be a state at wave %d. A state should be 1 to %d and not %ld.\n Fix your data file '%s'! Exiting.\n", strb, linei,i,line,j,nlstate+ndeath, lval, datafile);fflush(stdout); |
|
fprintf(ficlog,"Error in data around '%s' at line number %d for individual %d, '%s'\n Should be a state at wave %d. A state should be 1 to %d and not %ld.\n Fix your data file '%s'! Exiting.\n", strb, linei,i,line,j,nlstate+ndeath, lval, datafile); fflush(ficlog); |
return 1; |
return 1; |
} |
} |
} |
} |
Line 11120 int decodemodel( char model[], int lasto
|
Line 11174 int decodemodel( char model[], int lasto
|
* Model V2 + V1 + V3*age + V3 + V5*V6 + V7*V8 + V8*age + V8 |
* Model V2 + V1 + V3*age + V3 + V5*V6 + V7*V8 + V8*age + V8 |
* k= 1 2 3 4 5 6 7 8 |
* k= 1 2 3 4 5 6 7 8 |
* cptcovn number of covariates (not including constant and age ) = # of + plus 1 = 7+1=8 |
* cptcovn number of covariates (not including constant and age ) = # of + plus 1 = 7+1=8 |
* covar[k,i], value of kth covariate if not including age for individual i: |
* covar[k,i], are for fixed covariates, value of kth covariate if not including age for individual i: |
* covar[1][i]= (V1), covar[4][i]=(V4), covar[8][i]=(V8) |
* covar[1][i]= (V1), covar[4][i]=(V4), covar[8][i]=(V8) |
* Tvar[k] # of the kth covariate: Tvar[1]=2 Tvar[2]=1 Tvar[4]=3 Tvar[8]=8 |
* Tvar[k] # of the kth covariate: Tvar[1]=2 Tvar[2]=1 Tvar[4]=3 Tvar[8]=8 |
* if multiplied by age: V3*age Tvar[3=V3*age]=3 (V3) Tvar[7]=8 and |
* if multiplied by age: V3*age Tvar[3=V3*age]=3 (V3) Tvar[7]=8 and |
* Tage[++cptcovage]=k |
* Tage[++cptcovage]=k |
* if products, new covar are created after ncovcol with k1 |
* if products, new covar are created after ncovcol + nqv (quanti fixed) with k1 |
* Tvar[k]=ncovcol+k1; # of the kth covariate product: Tvar[5]=ncovcol+1=10 Tvar[6]=ncovcol+1=11 |
* Tvar[k]=ncovcol+k1; # of the kth covariate product: Tvar[5]=ncovcol+1=10 Tvar[6]=ncovcol+1=11 |
* Tprod[k1]=k; Tprod[1]=5 Tprod[2]= 6; gives the position of the k1th product |
* Tprod[k1]=k; Tprod[1]=5 Tprod[2]= 6; gives the position of the k1th product |
* Tvard[k1][1]=m Tvard[k1][2]=m; Tvard[1][1]=5 (V5) Tvard[1][2]=6 Tvard[2][1]=7 (V7) Tvard[2][2]=8 |
* Tvard[k1][1]=m Tvard[k1][2]=m; Tvard[1][1]=5 (V5) Tvard[1][2]=6 Tvard[2][1]=7 (V7) Tvard[2][2]=8 |
* Tvar[cptcovn+k2]=Tvard[k1][1];Tvar[cptcovn+k2+1]=Tvard[k1][2]; |
* Tvar[cptcovn+k2]=Tvard[k1][1];Tvar[cptcovn+k2+1]=Tvard[k1][2]; |
* Tvar[8+1]=5;Tvar[8+2]=6;Tvar[8+3]=7;Tvar[8+4]=8 inverted |
* Tvar[8+1]=5;Tvar[8+2]=6;Tvar[8+3]=7;Tvar[8+4]=8 inverted |
* V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 |
* V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 |
* < ncovcol=8 > |
* < ncovcol=8 8 fixed covariate. Additional starts at 9 (V5*V6) and 10(V7*V8) > |
* Model V2 + V1 + V3*age + V3 + V5*V6 + V7*V8 + V8*age + V8 d1 d1 d2 d2 |
* Model V2 + V1 + V3*age + V3 + V5*V6 + V7*V8 + V8*age + V8 d1 d1 d2 d2 |
* k= 1 2 3 4 5 6 7 8 9 10 11 12 |
* k= 1 2 3 4 5 6 7 8 9 10 11 12 |
* Tvar[k]= 2 1 3 3 10 11 8 8 5 6 7 8 |
* Tvard[k]= 2 1 3 3 10 11 8 8 5 6 7 8 |
* p Tvar[1]@12={2, 1, 3, 3, 11, 10, 8, 8, 7, 8, 5, 6} |
* p Tvar[1]@12={2, 1, 3, 3, 9, 10, 8, 8} |
* p Tprod[1]@2={ 6, 5} |
* p Tprod[1]@2={ 6, 5} |
*p Tvard[1][1]@4= {7, 8, 5, 6} |
*p Tvard[1][1]@4= {7, 8, 5, 6} |
* covar[k][i]= V2 V1 ? V3 V5*V6? V7*V8? ? V8 |
* covar[k][i]= V2 V1 ? V3 V5*V6? V7*V8? ? V8 |