/* $Id$
$State$
$Log$
+ Revision 1.232 2016/08/22 14:20:21 brouard
+ Summary: not working
+
Revision 1.231 2016/08/22 07:17:15 brouard
Summary: not working
int cptcovage=0; /**< Number of covariates with age: V3*age only =1 */
int cptcovprodnoage=0; /**< Number of covariate products without age */
int cptcoveff=0; /* Total number of covariates to vary for printing results */
-int ncovf=0; /* Total number of effective fixed covariates (dummy of quantitative) in the model */
-int ncovv=0; /* Total number of effective (wave) varying covariates (dummy of quantitative) in the model */
+int ncovf=0; /* Total number of effective fixed covariates (dummy or quantitative) in the model */
+int ncovv=0; /* Total number of effective (wave) varying covariates (dummy or quantitative) in the model */
int ncova=0; /* Total number of effective (wave and stepm) varying with age covariates (dummy of quantitative) in the model */
int ncoveff=0; /* Total number of effective fixed dummy covariates in the model */
to be observed in j being in i according to the model.
*/
ioffset=2+nagesqr+cptcovage;
- /* for (k=1; k<=cptcovn;k++){ /\* Simple and product covariates without age* products *\/ */
- for (k=1; k<=ncoveff;k++){ /* Simple and product covariates without age* products */
- cov[++ioffset]=covar[Tvar[k]][i];
- }
- for(iqv=1; iqv <= nqfveff; iqv++){ /* Quantitatives and Fixed covariates */
- cov[++ioffset]=coqvar[Tvar[iqv]][i];
- }
-
+ /* Fixed */
+ for (k=1; k<=ncovf;k++){ /* Simple and product fixed covariates without age* products */
+ cov[ioffset+TvarFind[k]]=covar[Tvar[TvarFind[k]]][i];/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, only V1 is fixed (k=6)*/
+ }
/* In model V2+V1*V4+age*V3+V3*V2 Tvar[1] is V2, Tvar[2=V1*V4]
is 6, Tvar[3=age*V3] should not be computed because of age Tvar[4=V3*V2]
has been calculated etc */
meaning that decodemodel should be used cotvar[mw[mi+1][i]][TTvar[iv]][i]
*/
for(mi=1; mi<= wav[i]-1; mi++){
- for(itv=1; itv <= ntveff; itv++){ /* Varying dummy covariates */
- /* cov[ioffset+itv]=cotvar[mw[mi][i]][Tvar[itv]][i]; /\* Not sure, Tvar V4+V3+V5 Tvaraff ? *\/ */
- cov[ioffset+itv]=cotvar[mw[mi][i]][TmodelInvind[itv]][i];
+ for(k=1; k <= ncovv ; k++){ /* Varying covariates (single and product but no age )*/
+ cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i];
}
- for(iqtv=1; iqtv <= nqtveff; iqtv++){ /* Varying quantitatives covariates */
- if(cotqvar[mw[mi][i]][iqtv][i] == -1){
- printf("i=%d, mi=%d, iqtv=%d, cotqvar[mw[mi][i]][iqtv][i]=%f",i,mi,iqtv,cotqvar[mw[mi][i]][iqtv][i]);
- }
- cov[ioffset+ntveff+iqtv]=cotqvar[mw[mi][i]][TmodelInvQind[iqtv]][i];
- /* cov[ioffset+ntveff+iqtv]=cotqvar[mw[mi][i]][iqtv][i]; */
- }
- /* ioffset=2+nagesqr+cptcovn+nqv+ntv+nqtv; */
for (ii=1;ii<=nlstate+ndeath;ii++)
for (j=1;j<=nlstate+ndeath;j++){
oldm[ii][j]=(ii==j ? 1.0 : 0.0);
/* cov[++ioffset]=coqvar[Tvar[iqv]][i]; /\* Only V2 k=6 and V1*V2 7 *\/ */
/* } */
- /* Wave varying (but not age varying) */
+
for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */
+ /* Wave varying (but not age varying) */
for(k=1; k <= ncovv ; k++){ /* Varying covariates (single and product but no age )*/
- cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarFind[k]]][i];
+ cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i];
}
/* for(itv=1; itv <= ntveff; itv++){ /\* Varying dummy covariates (single??)*\/ */
/* iv= Tvar[Tmodelind[ioffset-2-nagesqr-cptcovage+itv]]-ncovcol-nqv; /\* Counting the # varying covariate from 1 to ntveff *\/ */
char stra[80], strb[80], strc[80], strd[80],stre[80];
removespace(&resultline);
- printf("decoderesult=%s\n",resultline);
+ printf("decoderesult:%s\n",resultline);
if (strstr(resultline,"v") !=0){
printf("Error. 'v' must be in upper case 'V' result: %s ",resultline);
}
}else if (Typevar[k] == 2) { /* product without age */
k1=Tposprod[k];
- ncovv++; /* Only time varying variables */
- TvarV[ncovv]=Tvar[k];
- TvarVind[ncovv]=k;
if(Tvard[k1][1] <=ncovcol){
if(Tvard[k1][2] <=ncovcol){
Fixed[k]= 1;
Dummy[k]= 0;
modell[k].maintype= FTYPE;
modell[k].subtype= FPDD; /* Product fixed dummy * fixed dummy */
+ ncovf++; /* Fixed variables without age */
+ TvarF[ncovf]=Tvar[k];
+ TvarFind[ncovf]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv){
Fixed[k]= 0; /* or 2 ?*/
Dummy[k]= 1;
modell[k].maintype= FTYPE;
modell[k].subtype= FPDQ; /* Product fixed dummy * fixed quantitative */
+ ncovf++; /* Varying variables without age */
+ TvarF[ncovf]=Tvar[k];
+ TvarFind[ncovf]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv){
Fixed[k]= 1;
Dummy[k]= 0;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDD; /* Product fixed dummy * varying dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product fixed dummy * varying quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}
}else if(Tvard[k1][1] <=ncovcol+nqv){
if(Tvard[k1][2] <=ncovcol){
Dummy[k]= 1;
modell[k].maintype= FTYPE;
modell[k].subtype= FPDQ; /* Product fixed quantitative * fixed dummy */
+ ncovf++; /* Fixed variables without age */
+ TvarF[ncovf]=Tvar[k];
+ TvarFind[ncovf]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product fixed quantitative * varying dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPQQ; /* Product fixed quantitative * varying quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}
}else if(Tvard[k1][1] <=ncovcol+nqv+ntv){
if(Tvard[k1][2] <=ncovcol){
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDD; /* Product time varying dummy * fixed dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product time varying dummy * fixed quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv){
Fixed[k]= 1;
Dummy[k]= 0;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDD; /* Product time varying dummy * time varying dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product time varying dummy * time varying quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}
}else if(Tvard[k1][1] <=ncovcol+nqv+ntv+nqtv){
if(Tvard[k1][2] <=ncovcol){
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product time varying quantitative * fixed dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPQQ; /* Product time varying quantitative * fixed quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPDQ; /* Product time varying quantitative * time varying dummy */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){
Fixed[k]= 1;
Dummy[k]= 1;
modell[k].maintype= VTYPE;
modell[k].subtype= VPQQ; /* Product time varying quantitative * time varying quantitative */
+ ncovv++; /* Varying variables without age */
+ TvarV[ncovv]=Tvar[k];
+ TvarVind[ncovv]=k;
}
}else{
printf("Error unknown type of covariate: Tvard[%d][1]=%d,Tvard[%d][2]=%d\n",k1,Tvard[k1][1],k1,Tvard[k1][2]);
covar=matrix(0,NCOVMAX,1,n); /**< used in readdata */
coqvar=matrix(1,nqv,1,n); /**< Fixed quantitative covariate */
- cotvar=ma3x(1,maxwav,1,ntv,1,n); /**< Time varying covariate */
+ cotvar=ma3x(1,maxwav,1,ntv+nqtv,1,n); /**< Time varying covariate (dummy and quantitative)*/
cotqvar=ma3x(1,maxwav,1,nqtv,1,n); /**< Time varying quantitative covariate */
cptcovn=0; /*Number of covariates, i.e. number of '+' in model statement plus one, indepently of n in Vn*/
/* v1+v2+v3+v2*v4+v5*age makes cptcovn = 5
TvarVQind=ivector(1,NCOVMAX); /* */
Tvalsel=vector(1,NCOVMAX); /* */
+ Tvarsel=ivector(1,NCOVMAX); /* */
Typevar=ivector(-1,NCOVMAX); /* -1 to 2 */
Fixed=ivector(-1,NCOVMAX); /* -1 to 3 */
Dummy=ivector(-1,NCOVMAX); /* -1 to 3 */
free_matrix(newms, 1,nlstate+ndeath,1,nlstate+ndeath);
free_matrix(savms, 1,nlstate+ndeath,1,nlstate+ndeath);
free_ma3x(cotqvar,1,maxwav,1,nqtv,1,n);
- free_ma3x(cotvar,1,maxwav,1,ntv,1,n);
+ free_ma3x(cotvar,1,maxwav,1,ntv+nqtv,1,n);
free_matrix(coqvar,1,maxwav,1,n);
free_matrix(covar,0,NCOVMAX,1,n);
free_matrix(matcov,1,npar,1,npar);