int *Dummy; /** Dummy[k] 0=dummy (0 1), 1 quantitative (single or product without age), 2 dummy with age product, 3 quant with age product */
int *Tage;
int anyvaryingduminmodel=0; /**< Any varying dummy in Model=1 yes, 0 no, to avoid a loop on waves in freq */
-int *Tmodelind; /** Tmodelind[Tvaraff[3]]=9,Tvaraff[1]@9={4, 3, 1, 0, 0, 0, 0, 0, 0}, model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
+int *Tmodelind; /** Tmodelind[Tvaraff[3]]=9 for V1 position,Tvaraff[1]@9={4, 3, 1, 0, 0, 0, 0, 0, 0}, model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
+int *TmodelInvind; /** Tmodelind[Tvaraff[3]]=9 for V1 position,Tvaraff[1]@9={4, 3, 1, 0, 0, 0, 0, 0, 0}, model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
+int *TmodelInvQind; /** Tmodelqind[1]=1 for V5(quantitative varying) position,Tvaraff[1]@9={4, 3, 1, 0, 0, 0, 0, 0, 0}, model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
int *Ndum; /** Freq of modality (tricode */
/* int **codtab;*/ /**< codtab=imatrix(1,100,1,10); */
int **Tvard;
int ioffset=0;
double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1];
double **out;
- double sw; /* Sum of weights */
double lli; /* Individual log likelihood */
int s1, s2;
- int iv=0, iqv=0, itv=0, iqtv=0 ; /* Index of varying covariate, fixed quantitative cov, time varying covariate, quatitative time varying covariate */
+ int iv=0, iqv=0, itv=0, iqtv=0 ; /* Index of varying covariate, fixed quantitative cov, time varying covariate, quantitative time varying covariate */
double bbh, survp;
long ipmx;
double agexact;
cov[++ioffset]=covar[Tvar[k]][i];
}
for(iqv=1; iqv <= nqfveff; iqv++){ /* Quantitatives and Fixed covariates */
- cov[++ioffset]=coqvar[iqv][i];
+ cov[++ioffset]=coqvar[Tvar[iqv]][i];
}
/* In model V2+V1*V4+age*V3+V3*V2 Tvar[1] is V2, Tvar[2=V1*V4]
*/
for(mi=1; mi<= wav[i]-1; mi++){
for(itv=1; itv <= ntveff; itv++){ /* Varying dummy covariates */
- cov[ioffset+itv]=cotvar[mw[mi][i]][itv][i];
+ cov[ioffset+itv]=cotvar[mw[mi][i]][Tvar[itv]][i]; /* Not sure, Tvar V4+V3+V5 Tvaraff ? */
}
for(iqtv=1; iqtv <= nqtveff; iqtv++){ /* Varying quantitatives covariates */
if(cotqvar[mw[mi][i]][iqtv][i] == -1){
/*************** log-likelihood *************/
double funcone( double *x)
{
- /* Same as likeli but slower because of a lot of printf and if */
+ /* Same as func but slower because of a lot of printf and if */
int i, ii, j, k, mi, d, kk;
- int ioffset=0;
+ int ioffset=0;
double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1];
double **out;
double lli; /* Individual log likelihood */
double llt;
int s1, s2;
- int iv=0, iqv=0, itv=0, iqtv=0 ; /* Index of varying covariate, fixed quantitative cov, time varying covariate */
+ int iv=0, iqv=0, itv=0, iqtv=0 ; /* Index of varying covariate, fixed quantitative cov, time varying covariate, quantitative time varying covariate */
+
double bbh, survp;
double agexact;
double agebegin, ageend;
for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */
for(itv=1; itv <= ntveff; itv++){ /* Varying dummy covariates */
- cov[ioffset+itv]=cotvar[mw[mi][i]][itv][i];
+ /* iv= Tvar[Tmodelind[ioffset-2-nagesqr-cptcovage+itv]]-ncovcol-nqv; /\* Counting the # varying covariate from 1 to ntveff *\/ */
+ /* cov[ioffset+iv]=cotvar[mw[mi][i]][iv][i]; */
+ k=ioffset-2-nagesqr-cptcovage+itv; /* position in simple model */
+ cov[ioffset+itv]=cotvar[mw[mi][i]][TmodelInvind[itv]][i];
+ printf(" i=%d,mi=%d,itv=%d,TmodelInvind[itv]=%d,cotvar[mw[mi][i]][TmodelInvind[itv]][i]=%f\n", i, mi, itv, TmodelInvind[itv],cotvar[mw[mi][i]][TmodelInvind[itv]][i]);
}
for(iqtv=1; iqtv <= nqtveff; iqtv++){ /* Varying quantitatives covariates */
- cov[ioffset+ntveff+iqtv]=cotqvar[mw[mi][i]][iqtv][i];
+ iv=TmodelInvQind[iqtv]; /* Counting the # varying covariate from 1 to ntveff */
+ printf(" i=%d,mi=%d,iqtv=%d,TmodelInvQind[iqtv]=%d,cotqvar[mw[mi][i]][TmodelInvQind[iqtv]][i]=%f\n", i, mi, iqtv, TmodelInvQind[iqtv],cotqvar[mw[mi][i]][TmodelInvQind[iqtv]][i]);
+ cov[ioffset+ntveff+iqtv]=cotqvar[mw[mi][i]][TmodelInvQind[iqtv]][i];
}
for (ii=1;ii<=nlstate+ndeath;ii++)
for (j=1;j<=nlstate+ndeath;j++){
++ij;
Tvaraff[ij]=Tvar[k]; /*For printing */
Tmodelind[ij]=k;
+ TmodelInvind[k]=Tvar[k]- ncovcol-nqv;
if(Fixed[k]!=0)
anyvaryingduminmodel=1;
/* }else if((Ndum[i]!=0) && (i<=ncovcol+nqv)){ */
Tvaraff[j]=0;
Tmodelind[j]=0;
}
+ for(j=ntveff+1; j<= cptcovt; j++){
+ TmodelInvind[j]=0;
+ }
/* To be sorted */
;
}
Fixed[k]= 1;
Dummy[k]= 0;
ntveff++; /* Only simple time varying dummy variable */
+ printf("Quasi Tmodelind[%d]=%d,Tvar[Tmodelind[%d]]=V%d, ncovcol=%d, nqv=%d,Tvar[k]- ncovcol-nqv=%d\n",ntveff,k,ntveff,Tvar[k], ncovcol, nqv,Tvar[k]- ncovcol-nqv);
+ printf("Quasi TmodelInvind[%d]=%d\n",k,Tvar[k]- ncovcol-nqv);
}else if( Tvar[k] <=ncovcol+nqv+ntv+nqtv && Typevar[k]==0){
Fixed[k]= 1;
Dummy[k]= 1;
- nqtveff++;/* Only simple time varying quantitative variable */
+ TmodelInvQind[++nqtveff]=Tvar[k]- ncovcol-nqv-ntv;/* Only simple time varying quantitative variable */
+ /* Tmodeliqind[k]=nqtveff;/\* Only simple time varying quantitative variable *\/ */
+ printf("Quasi TmodelQind[%d]=%d,Tvar[TmodelQind[%d]]=V%d, ncovcol=%d, nqv=%d, ntv=%d,Tvar[k]- ncovcol-nqv-ntv=%d\n",nqtveff,k,nqtveff,Tvar[k], ncovcol, nqv, ntv, Tvar[k]- ncovcol-nqv-ntv);
+ printf("Quasi TmodelInvQind[%d]=%d\n",k,Tvar[k]- ncovcol-nqv-ntv);
}else if (Typevar[k] == 1) { /* product with age */
if (Tvar[k] <=ncovcol ){ /* Simple or product fixed dummy covariatee */
Fixed[k]= 2;
* Tmodelind[Tvaraff[3]]=9,Tvaraff[1]@9={4,
* 3, 1, 0, 0, 0, 0, 0, 0},
* model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
+ TmodelInvind=ivector(1,NCOVMAX);
+ TmodelInvQind=ivector(1,NCOVMAX);/** five the k model position of an
+ * individual quantitative, fixed or varying:
+ * Tmodelqind[1]=1,Tvaraff[1]@9={4,
+ * 3, 1, 0, 0, 0, 0, 0, 0},
+ * model=V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1*/
/* Main decodemodel */
free_ivector(invalidvarcomb,1,ncovcombmax);
free_ivector(Tage,1,NCOVMAX);
free_ivector(Tmodelind,1,NCOVMAX);
+ free_ivector(TmodelInvind,1,NCOVMAX);
+ free_ivector(TmodelInvQind,1,NCOVMAX);
free_imatrix(nbcode,0,NCOVMAX,0,NCOVMAX);
/* free_imatrix(codtab,1,100,1,10); */