/* $Id$
$State$
$Log$
+ Revision 1.344 2022/09/14 19:33:30 brouard
+ Summary: version 0.99r40
+
+ * imach.c (Module): Fixing names of variables in T_ (thanks to Feinuo)
+
Revision 1.343 2022/09/14 14:22:16 brouard
Summary: version 0.99r39
*/
ioffset=2+nagesqr ;
/* 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 */
/* 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 */
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 */
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] */
}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 */
cotvarvold=cotvarv;
* TvarVVind 2 3 7 7 8 8 9 9
* 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 */
- 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*/
- if(TvarFind[itv]==0){ /* Not a fixed covariate */
- cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */
+ /* if(TvarFind[itv]==0){ /\* Not a fixed covariate? Could be a fixed covariate of a product with a higher than ncovcol+nqv, itv *\/ */
+ 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 */
- 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 */
cotvarvold=cotvarv;
* Model V2 + V1 + V3*age + V3 + V5*V6 + V7*V8 + V8*age + V8
* k= 1 2 3 4 5 6 7 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)
* 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
* 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
* 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
* 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
* 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
* 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
- * p Tvar[1]@12={2, 1, 3, 3, 11, 10, 8, 8, 7, 8, 5, 6}
+ * Tvard[k]= 2 1 3 3 10 11 8 8 5 6 7 8
+ * p Tvar[1]@12={2, 1, 3, 3, 9, 10, 8, 8}
* p Tprod[1]@2={ 6, 5}
*p Tvard[1][1]@4= {7, 8, 5, 6}
* covar[k][i]= V2 V1 ? V3 V5*V6? V7*V8? ? V8