|
|
| version 1.338, 2022/09/04 17:40:33 | version 1.341, 2022/09/11 07:58:42 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ | /* $Id$ |
| $State$ | $State$ |
| $Log$ | $Log$ |
| Revision 1.341 2022/09/11 07:58:42 brouard | |
| Summary: Version 0.99r38 | |
| After adding change in cotvar. | |
| Revision 1.340 2022/09/11 07:53:11 brouard | |
| Summary: Version imach 0.99r37 | |
| * imach.c (Module): Adding timevarying products of any kinds, | |
| should work before shifting cotvar from ncovcol+nqv columns in | |
| order to have a correspondance between the column of cotvar and | |
| the id of column. | |
| Revision 1.339 2022/09/09 17:55:22 brouard | |
| Summary: version 0.99r37 | |
| * imach.c (Module): Many improvements for fixing products of fixed | |
| timevarying as well as fixed * fixed, and test with quantitative | |
| covariate. | |
| Revision 1.338 2022/09/04 17:40:33 brouard | Revision 1.338 2022/09/04 17:40:33 brouard |
| Summary: 0.99r36 | Summary: 0.99r36 |
| Line 1322 int cptcovprodnoage=0; /**< Number of co | Line 1342 int cptcovprodnoage=0; /**< Number of co |
| int cptcoveff=0; /* Total number of single dummy covariates (fixed or time varying) to vary for printing results (2**cptcoveff combinations of dummies)(computed in tricode as cptcov) */ | int cptcoveff=0; /* Total number of single dummy covariates (fixed or time varying) to vary for printing results (2**cptcoveff combinations of dummies)(computed in tricode as cptcov) */ |
| int ncovf=0; /* Total number of effective fixed covariates (dummy or 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 ncovv=0; /* Total number of effective (wave) varying covariates (dummy or quantitative) in the model */ |
| int ncovvt=0; /* Total number of effective (wave) varying covariates (dummy or quantitative or products [without age]) in the model */ | |
| int ncova=0; /* Total number of effective (wave and stepm) varying with age covariates (dummy of 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 nsd=0; /**< Total number of single dummy variables (output) */ | int nsd=0; /**< Total number of single dummy variables (output) */ |
| int nsq=0; /**< Total number of single quantitative variables (output) */ | int nsq=0; /**< Total number of single quantitative variables (output) */ |
| Line 1337 int npar=NPARMAX; /* Number of parameter | Line 1358 int npar=NPARMAX; /* Number of parameter |
| int nlstate=2; /* Number of live states */ | int nlstate=2; /* Number of live states */ |
| int ndeath=1; /* Number of dead states */ | int ndeath=1; /* Number of dead states */ |
| int ncovmodel=0, ncovcol=0; /* Total number of covariables including constant a12*1 +b12*x ncovmodel=2 */ | int ncovmodel=0, ncovcol=0; /* Total number of covariables including constant a12*1 +b12*x ncovmodel=2 */ |
| int nqv=0, ntv=0, nqtv=0; /* Total number of quantitative variables, time variable (dummy), quantitative and time variable */ | int nqv=0, ntv=0, nqtv=0; /* Total number of quantitative variables, time variable (dummy), quantitative and time variable*/ |
| int ncovcolt=0; /* ncovcolt=ncovcol+nqv+ntv+nqtv; total of covariates in the data, not in the model equation*/ | |
| int popbased=0; | int popbased=0; |
| int *wav; /* Number of waves for this individuual 0 is possible */ | int *wav; /* Number of waves for this individuual 0 is possible */ |
| Line 1486 double **covar; /**< covar[j,i], value | Line 1508 double **covar; /**< covar[j,i], value |
| * covar=matrix(0,NCOVMAX,1,n); | * covar=matrix(0,NCOVMAX,1,n); |
| * cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ | * cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ |
| double **coqvar; /* Fixed quantitative covariate nqv */ | double **coqvar; /* Fixed quantitative covariate nqv */ |
| double ***cotvar; /* Time varying covariate ntv */ | double ***cotvar; /* Time varying covariate start at ncovcol + nqv + (1 to ntv) */ |
| double ***cotqvar; /* Time varying quantitative covariate itqv */ | double ***cotqvar; /* Time varying quantitative covariate itqv */ |
| double idx; | double idx; |
| int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ | int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ |
| Line 1498 int **nbcode, *Tvar; /**< model=V2 => Tv | Line 1520 int **nbcode, *Tvar; /**< model=V2 => Tv |
| * cptcovn number of covariates (not including constant and age or age*age) = number of plus sign + 1 = 10+1=11 | * cptcovn number of covariates (not including constant and age or age*age) = number of plus sign + 1 = 10+1=11 |
| * For time varying covariate, quanti or dummies | * For time varying covariate, quanti or dummies |
| * cotqvar[wav][iv(1 to nqtv)][i]= [1][12][i]=(V12) quanti | * cotqvar[wav][iv(1 to nqtv)][i]= [1][12][i]=(V12) quanti |
| * cotvar[wav][ntv+iv][i]= [3+(1 to nqtv)][i]=(V12) quanti | * cotvar[wav][ncovcol+nqv+ iv(1 to nqtv)][i]= [(1 to nqtv)][i]=(V12) quanti |
| * cotvar[wav][iv(1 to ntv)][i]= [1][1][i]=(V9) dummies at wav 1 | * cotvar[wav][iv(1 to ntv)][i]= [1][1][i]=(V9) dummies at wav 1 |
| * cotvar[wav][iv(1 to ntv)][i]= [1][2][i]=(V10) dummies at wav 1 | * cotvar[wav][iv(1 to ntv)][i]= [1][2][i]=(V10) dummies at wav 1 |
| * covar[Vk,i], value of the Vkth fixed covariate dummy or quanti for individual i: | * covar[Vk,i], value of the Vkth fixed covariate dummy or quanti for individual i: |
| Line 1579 int *TvarVD; /* TvarVD[1]=V5 in V5+V4+V3 | Line 1601 int *TvarVD; /* TvarVD[1]=V5 in V5+V4+V3 |
| int *TvarVDind; /* TvarVDind[1]=1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ | int *TvarVDind; /* TvarVDind[1]=1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ |
| int *TvarVQ; /* TvarVQ[1]=V5 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple time varying quantitative variable */ | int *TvarVQ; /* TvarVQ[1]=V5 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple time varying quantitative variable */ |
| int *TvarVQind; /* TvarVQind[1]=1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple time varying quantitative variable */ | int *TvarVQind; /* TvarVQind[1]=1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple time varying quantitative variable */ |
| int *TvarVV; /* We count ncovvt time varying covariates (single or products without age) and put their name into TvarVV */ | |
| int *TvarVVind; /* We count ncovvt time varying covariates (single or products without age) and put their name into TvarVV */ | |
| /*# ID V1 V2 weight birth death 1st s1 V3 V4 V5 2nd s2 */ | |
| /* model V1+V3+age*V1+age*V3+V1*V3 */ | |
| /* Tvar={1, 3, 1, 3, 6}, the 6 comes from the fact that there are already V1, V2, V3, V4, V5 native covariates */ | |
| /* TvarVV={3,1,3}, for V3 and then the product V1*V3 is decomposed into V1 and V3 */ | |
| /* TvarVVind={2,5,5}, for V3 and then the product V1*V3 is decomposed into V1 and V3 */ | |
| int *Tvarsel; /**< Selected covariates for output */ | int *Tvarsel; /**< Selected covariates for output */ |
| double *Tvalsel; /**< Selected modality value of covariate for output */ | double *Tvalsel; /**< Selected modality value of covariate for output */ |
| int *Typevar; /**< 0 for simple covariate (dummy, quantitative, fixed or varying), 1 for age product, 2 for product */ | int *Typevar; /**< 0 for simple covariate (dummy, quantitative, fixed or varying), 1 for age product, 2 for product */ |
| Line 3280 double **pmij(double **ps, double *cov, | Line 3308 double **pmij(double **ps, double *cov, |
| for(i=1; i<= nlstate; i++){ | for(i=1; i<= nlstate; i++){ |
| s1=0; | s1=0; |
| for(j=1; j<i; j++){ | for(j=1; j<i; j++){ |
| /* printf("debug1 %d %d ps=%lf exp(ps)=%lf \n",i,j,ps[i][j],exp(ps[i][j])); */ | |
| s1+=exp(ps[i][j]); /* In fact sums pij/pii */ | s1+=exp(ps[i][j]); /* In fact sums pij/pii */ |
| /* printf("debug1 %d %d ps=%lf exp(ps)=%lf s1+=%lf\n",i,j,ps[i][j],exp(ps[i][j]),s1); */ | |
| } | } |
| for(j=i+1; j<=nlstate+ndeath; j++){ | for(j=i+1; j<=nlstate+ndeath; j++){ |
| /* printf("debug2 %d %d ps=%lf exp(ps)=%lf \n",i,j,ps[i][j],exp(ps[i][j])); */ | |
| s1+=exp(ps[i][j]); /* In fact sums pij/pii */ | s1+=exp(ps[i][j]); /* In fact sums pij/pii */ |
| /* printf("debug2 %d %d ps=%lf exp(ps)=%lf s1+=%lf\n",i,j,ps[i][j],exp(ps[i][j]),s1); */ | |
| } | } |
| /* s1= sum_{j<>i} pij/pii=(1-pii)/pii and thus pii is known from s1 */ | /* s1= sum_{j<>i} pij/pii=(1-pii)/pii and thus pii is known from s1 */ |
| ps[i][i]=1./(s1+1.); | ps[i][i]=1./(s1+1.); |
| Line 3863 double func( double *x) | Line 3891 double func( double *x) |
| { | { |
| int i, ii, j, k, mi, d, kk, kf=0; | int i, ii, j, k, mi, d, kk, kf=0; |
| int ioffset=0; | int ioffset=0; |
| int ipos=0,iposold=0,ncovv=0; | |
| double cotvarv, cotvarvold; | |
| double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1]; | double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1]; |
| double **out; | double **out; |
| double lli; /* Individual log likelihood */ | double lli; /* Individual log likelihood */ |
| Line 3910 double func( double *x) | Line 3941 double func( double *x) |
| mw[mi][i] is real wave of the mi th effectve wave */ | mw[mi][i] is real wave of the mi th effectve wave */ |
| /* Then statuses are computed at each begin and end of an effective wave s1=s[ mw[mi][i] ][i]; | /* Then statuses are computed at each begin and end of an effective wave s1=s[ mw[mi][i] ][i]; |
| s2=s[mw[mi+1][i]][i]; | s2=s[mw[mi+1][i]][i]; |
| And the iv th varying covariate is the cotvar[mw[mi+1][i]][iv][i] | And the iv th varying covariate is the cotvar[mw[mi+1][i]][iv][i] because now is moved after nvocol+nqv |
| But if the variable is not in the model TTvar[iv] is the real variable effective in the model: | But if the variable is not in the model TTvar[iv] is the real variable effective in the model: |
| meaning that decodemodel should be used cotvar[mw[mi+1][i]][TTvar[iv]][i] | meaning that decodemodel should be used cotvar[mw[mi+1][i]][TTvar[iv]][i] |
| */ | */ |
| for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */ | for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */ |
| /* Wave varying (but not age varying) */ | /* Wave varying (but not age varying) */ |
| for(k=1; k <= ncovv ; k++){ /* Varying covariates in the model (single and product but no age )"V5+V4+V3+V4*V3+V5*age+V1*age+V1" +TvarVind 1,2,3,4(V4*V3) Tvar[1]@7{5, 4, 3, 6, 5, 1, 1 ; 6 because the created covar is after V5 and is 6, minus 1+1, 3,2,1,4 positions in cotvar*/ | /* for(k=1; k <= ncovv ; k++){ /\* Varying covariates in the model (single and product but no age )"V5+V4+V3+V4*V3+V5*age+V1*age+V1" +TvarVind 1,2,3,4(V4*V3) Tvar[1]@7{5, 4, 3, 6, 5, 1, 1 ; 6 because the created covar is after V5 and is 6, minus 1+1, 3,2,1,4 positions in cotvar*\/ */ |
| /* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; but where is the crossproduct? */ | /* /\* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; but where is the crossproduct? *\/ */ |
| cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]-ncovcol-nqv][i]; | /* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]-ncovcol-nqv][i]; */ |
| } | /* } */ |
| 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 */ | |
| cotvarv=cotvar[mw[mi][i]][TvarVV[ncovv]][i]; /* cotvar[wav][ncovcol+nqv+iv][i] */ | |
| }else{ /* fixed covariate */ | |
| cotvarv=covar[Tvar[TvarFind[itv]]][i]; | |
| } | |
| if(ipos!=iposold){ /* Not a product or first of a product */ | |
| cotvarvold=cotvarv; | |
| }else{ /* A second product */ | |
| cotvarv=cotvarv*cotvarvold; | |
| } | |
| iposold=ipos; | |
| cov[ioffset+ipos]=cotvarv; | |
| } | |
| /* 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 *\/ */ | |
| /* 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 *\/ */ | |
| /* 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 products of time varying to be done */ | |
| for (ii=1;ii<=nlstate+ndeath;ii++) | for (ii=1;ii<=nlstate+ndeath;ii++) |
| for (j=1;j<=nlstate+ndeath;j++){ | for (j=1;j<=nlstate+ndeath;j++){ |
| oldm[ii][j]=(ii==j ? 1.0 : 0.0); | oldm[ii][j]=(ii==j ? 1.0 : 0.0); |
| Line 3938 double func( double *x) | Line 3998 double func( double *x) |
| if(!FixedV[Tvar[Tage[kk]]]) | if(!FixedV[Tvar[Tage[kk]]]) |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; /* Tage[kk] gives the data-covariate associated with age */ | cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; /* Tage[kk] gives the data-covariate associated with age */ |
| else | else |
| cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]-ncovcol-nqv][i]*agexact; | cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]][i]*agexact; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ |
| } | } |
| out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, | out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, |
| 1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate)); | 1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate)); |
| Line 4034 double func( double *x) | Line 4094 double func( double *x) |
| } | } |
| /*lli=(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]);*/ | /*lli=(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]);*/ |
| /*if(lli ==000.0)*/ | /*if(lli ==000.0)*/ |
| /*printf("bbh= %f lli=%f savm=%f out=%f %d\n",bbh,lli,savm[s1][s2], out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]],i); */ | /* printf("num[i], i=%d, bbh= %f lli=%f savm=%f out=%f %d\n",bbh,lli,savm[s1][s2], out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]],i); */ |
| ipmx +=1; | ipmx +=1; |
| sw += weight[i]; | sw += weight[i]; |
| ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; | ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
| Line 4051 double func( double *x) | Line 4111 double func( double *x) |
| cov[ioffset+TvarFind[k]]=covar[Tvar[TvarFind[k]]][i]; | cov[ioffset+TvarFind[k]]=covar[Tvar[TvarFind[k]]][i]; |
| for(mi=1; mi<= wav[i]-1; mi++){ | for(mi=1; mi<= wav[i]-1; mi++){ |
| for(k=1; k <= ncovv ; k++){ | for(k=1; k <= ncovv ; k++){ |
| cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]-ncovcol-nqv][i]; | cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ |
| } | } |
| for (ii=1;ii<=nlstate+ndeath;ii++) | for (ii=1;ii<=nlstate+ndeath;ii++) |
| for (j=1;j<=nlstate+ndeath;j++){ | for (j=1;j<=nlstate+ndeath;j++){ |
| Line 4098 double func( double *x) | Line 4158 double func( double *x) |
| if(nagesqr==1) | if(nagesqr==1) |
| cov[3]= agexact*agexact; | cov[3]= agexact*agexact; |
| for (kk=1; kk<=cptcovage;kk++) { | for (kk=1; kk<=cptcovage;kk++) { |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; | if(!FixedV[Tvar[Tage[kk]]]) |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; /* Tage[kk] gives the data-covariate associated with age */ | |
| else | |
| cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]][i]*agexact; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ | |
| } | } |
| out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, | out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, |
| 1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate)); | 1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate)); |
| Line 4154 double func( double *x) | Line 4217 double func( double *x) |
| ipmx +=1; | ipmx +=1; |
| sw += weight[i]; | sw += weight[i]; |
| ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; | ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
| /* printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ | /* printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
| } /* end of wave */ | } /* end of wave */ |
| } /* end of individual */ | } /* end of individual */ |
| }else{ /* ml=5 no inter-extrapolation no jackson =0.8a */ | }else{ /* ml=5 no inter-extrapolation no jackson =0.8a */ |
| Line 4173 double func( double *x) | Line 4236 double func( double *x) |
| if(nagesqr==1) | if(nagesqr==1) |
| cov[3]= agexact*agexact; | cov[3]= agexact*agexact; |
| for (kk=1; kk<=cptcovage;kk++) { | for (kk=1; kk<=cptcovage;kk++) { |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; | if(!FixedV[Tvar[Tage[kk]]]) |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; /* Tage[kk] gives the data-covariate associated with age */ | |
| else | |
| cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]][i]*agexact; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ | |
| } | } |
| out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, | out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, |
| Line 4204 double funcone( double *x) | Line 4270 double funcone( double *x) |
| /* Same as func 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, kf=0; | int i, ii, j, k, mi, d, kk, kf=0; |
| int ioffset=0; | int ioffset=0; |
| int ipos=0,iposold=0,ncovv=0; | |
| double cotvarv, cotvarvold; | |
| double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1]; | double l, ll[NLSTATEMAX+1], cov[NCOVMAX+1]; |
| double **out; | double **out; |
| double lli; /* Individual log likelihood */ | double lli; /* Individual log likelihood */ |
| Line 4236 double funcone( double *x) | Line 4305 double funcone( double *x) |
| /* for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i]; */ | /* for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i]; */ |
| /* for (k=1; k<=ncoveff;k++){ /\* Simple and product fixed Dummy covariates without age* products *\/ */ | /* for (k=1; k<=ncoveff;k++){ /\* Simple and product fixed Dummy covariates without age* products *\/ */ |
| for (kf=1; kf<=ncovf;kf++){ /* Simple and product fixed covariates without age* products *//* Missing values are set to -1 but should be dropped */ | for (kf=1; kf<=ncovf;kf++){ /* Simple and product fixed covariates without age* products *//* Missing values are set to -1 but should be dropped */ |
| /* printf("Debug3 TvarFind[%d]=%d",kf, TvarFind[kf]); */ | |
| /* printf(" Tvar[TvarFind[kf]]=%d", Tvar[TvarFind[kf]]); */ | |
| /* printf(" i=%d covar[Tvar[TvarFind[kf]]][i]=%f\n",i,covar[Tvar[TvarFind[kf]]][i]); */ | |
| cov[ioffset+TvarFind[kf]]=covar[Tvar[TvarFind[kf]]][i];/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, only V1 is fixed (k=6)*/ | cov[ioffset+TvarFind[kf]]=covar[Tvar[TvarFind[kf]]][i];/* V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1, only V1 is fixed (k=6)*/ |
| /* cov[ioffset+TvarFind[1]]=covar[Tvar[TvarFind[1]]][i]; */ | /* cov[ioffset+TvarFind[1]]=covar[Tvar[TvarFind[1]]][i]; */ |
| /* cov[2+6]=covar[Tvar[6]][i]; */ | /* cov[2+6]=covar[Tvar[6]][i]; */ |
| Line 4255 double funcone( double *x) | Line 4327 double funcone( double *x) |
| mw[mi][i] is real wave of the mi th effectve wave */ | mw[mi][i] is real wave of the mi th effectve wave */ |
| /* Then statuses are computed at each begin and end of an effective wave s1=s[ mw[mi][i] ][i]; | /* Then statuses are computed at each begin and end of an effective wave s1=s[ mw[mi][i] ][i]; |
| s2=s[mw[mi+1][i]][i]; | s2=s[mw[mi+1][i]][i]; |
| And the iv th varying covariate is the cotvar[mw[mi+1][i]][iv][i] | And the iv th varying covariate in the DATA is the cotvar[mw[mi+1][i]][ncovcol+nqv+iv][i] |
| But if the variable is not in the model TTvar[iv] is the real variable effective in the model: | |
| meaning that decodemodel should be used cotvar[mw[mi+1][i]][TTvar[iv]][i] | |
| */ | */ |
| /* This part may be useless now because everythin should be in covar */ | /* This part may be useless now because everythin should be in covar */ |
| /* for (k=1; k<=nqfveff;k++){ /\* Simple and product fixed Quantitative covariates without age* products *\/ */ | /* for (k=1; k<=nqfveff;k++){ /\* Simple and product fixed Quantitative covariates without age* products *\/ */ |
| Line 4269 double funcone( double *x) | Line 4339 double funcone( double *x) |
| for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */ | for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */ |
| /* Wave varying (but not age varying) */ | /* Wave varying (but not age varying) *//* V1+V3+age*V1+age*V3+V1*V3 with V4 tv and V5 tvq k= 1 to 5 and extra at V(5+1)=6 for V1*V3 */ |
| for(k=1; k <= ncovv ; k++){ /* Varying covariates (single and product but no age )*/ | /* 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]; */ | /* /\* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; *\/ */ |
| cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]-ncovcol-nqv][i]; | /* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]-ncovcol-nqv][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 *\/ */ | /*# ID V1 V2 weight birth death 1st s1 V3 V4 V5 2nd s2 */ |
| /* cov[ioffset+iv]=cotvar[mw[mi][i]][iv][i]; */ | /* model V1+V3+age*V1+age*V3+V1*V3 */ |
| /* k=ioffset-2-nagesqr-cptcovage+itv; /\* position in simple model *\/ */ | /* Tvar={1, 3, 1, 3, 6}, the 6 comes from the fact that there are already V1, V2, V3, V4, V5 native covariates */ |
| /* cov[ioffset+itv]=cotvar[mw[mi][i]][TmodelInvind[itv]][i]; */ | /* TvarVV[1]=V3 (first time varying in the model equation, TvarVV[2]=V1 (in V1*V3) TvarVV[3]=3(V3) */ |
| /* 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]); */ | /* We need the position of the time varying or product in the model */ |
| /* TvarVVind={2,5,5}, for V3 at position 2 and then the product V1*V3 is decomposed into V1 and V3 but at same position 5 */ | |
| /* TvarVV gives the variable name */ | |
| /* Other example V1 + V3 + V5 + age*V1 + age*V3 + age*V5 + V1*V3 + V3*V5 + V1*V5 | |
| * k= 1 2 3 4 5 6 7 8 9 | |
| * varying 1 2 3 4 5 | |
| * ncovv 1 2 3 4 5 6 7 8 | |
| * TvarVV V3 5 1 3 3 5 1 5 | |
| * TvarVVind 2 3 7 7 8 8 9 9 | |
| * TvarFind[k] 1 0 0 0 0 0 0 0 0 | |
| * cotvar starts at ntv=2 (because of V3 V4) | |
| */ | |
| 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 */ | |
| 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) */ | |
| }else{ /* fixed covariate */ | |
| cotvarv=covar[Tvar[TvarFind[itv]]][i]; | |
| } | |
| if(ipos!=iposold){ /* Not a product or first of a product */ | |
| cotvarvold=cotvarv; | |
| }else{ /* A second product */ | |
| cotvarv=cotvarv*cotvarvold; | |
| } | |
| iposold=ipos; | |
| cov[ioffset+ipos]=cotvarv; | |
| /* For products */ | |
| } | |
| /* for(itv=1; itv <= ntveff; itv++){ /\* Varying dummy covariates single *\/ */ | |
| /* iv=TvarVDind[itv]; /\* iv, position in the model equation of time varying covariate itv *\/ */ | |
| /* /\* "V1+V3+age*V1+age*V3+V1*V3" with V3 time varying *\/ */ | |
| /* /\* 1 2 3 4 5 *\/ */ | |
| /* /\*itv 1 *\/ */ | |
| /* /\* TvarVInd[1]= 2 *\/ */ | |
| /* /\* iv= Tvar[Tmodelind[itv]]-ncovcol-nqv; /\\* Counting the # varying covariate from 1 to ntveff *\\/ *\/ */ | |
| /* /\* iv= Tvar[Tmodelind[ioffset-2-nagesqr-cptcovage+itv]]-ncovcol-nqv; *\/ */ | |
| /* /\* cov[ioffset+iv]=cotvar[mw[mi][i]][iv][i]; *\/ */ | |
| /* /\* k=ioffset-2-nagesqr-cptcovage+itv; /\\* position in simple model *\\/ *\/ */ | |
| /* /\* cov[ioffset+iv]=cotvar[mw[mi][i]][TmodelInvind[itv]][i]; *\/ */ | |
| /* cov[ioffset+iv]=cotvar[mw[mi][i]][itv][i]; */ | |
| /* /\* printf(" i=%d,mi=%d,itv=%d,TmodelInvind[itv]=%d,cotvar[mw[mi][i]][itv][i]=%f\n", i, mi, itv, TvarVDind[itv],cotvar[mw[mi][i]][itv][i]); *\/ */ | |
| /* } */ | |
| /* for(iqtv=1; iqtv <= nqtveff; iqtv++){ /\* Varying quantitatives covariates *\/ */ | /* for(iqtv=1; iqtv <= nqtveff; iqtv++){ /\* Varying quantitatives covariates *\/ */ |
| /* iv=TmodelInvQind[iqtv]; /\* Counting the # varying covariate from 1 to ntveff *\/ */ | /* 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]); *\/ */ | /* /\* 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]); *\/ */ |
| Line 4306 double funcone( double *x) | Line 4418 double funcone( double *x) |
| if(!FixedV[Tvar[Tage[kk]]]) | if(!FixedV[Tvar[Tage[kk]]]) |
| cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; | cov[Tage[kk]+2+nagesqr]=covar[Tvar[Tage[kk]]][i]*agexact; |
| else | else |
| cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]-ncovcol-nqv][i]*agexact; | cov[Tage[kk]+2+nagesqr]=cotvar[mw[mi][i]][Tvar[Tage[kk]]][i]*agexact; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ |
| } | } |
| /* printf("i=%d,mi=%d,d=%d,mw[mi][i]=%d\n",i, mi,d,mw[mi][i]); */ | /* printf("i=%d,mi=%d,d=%d,mw[mi][i]=%d\n",i, mi,d,mw[mi][i]); */ |
| /* savm=pmij(pmmij,cov,ncovmodel,x,nlstate); */ | /* savm=pmij(pmmij,cov,ncovmodel,x,nlstate); */ |
| Line 4361 double funcone( double *x) | Line 4473 double funcone( double *x) |
| ipmx +=1; | ipmx +=1; |
| sw += weight[i]; | sw += weight[i]; |
| ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; | ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
| /* printf("Funcone i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],(s2==-1? -1: out[s1][s2]),(s2==-1? -1: savm[s1][s2])); */ | printf("Funcone num[i]=%ld i=%6d V= ", num[i], i); |
| for (kf=1; kf<=ncovf;kf++){ /* Simple and product fixed covariates without age* products *//* Missing values are set to -1 but should be dropped */ | |
| printf("%g",covar[Tvar[TvarFind[kf]]][i]); | |
| } | |
| for(ncovv=1, iposold=0; ncovv <= ncovvt ; ncovv++){ /* Varying covariates (single and product but no age) including individual from products */ | |
| ipos=TvarVVind[ncovv]; /* TvarVVind={2, 5, 5] gives the position in the model of the ncovv th varying covariate*/ | |
| if(ipos!=iposold){ /* Not a product or first of a product */ | |
| printf(" %g",cov[ioffset+ipos]); | |
| }else{ | |
| printf("*"); | |
| } | |
| iposold=ipos; | |
| } | |
| for (kk=1; kk<=cptcovage;kk++) { | |
| if(!FixedV[Tvar[Tage[kk]]]) | |
| printf(" %g*age",covar[Tvar[Tage[kk]]][i]); | |
| else | |
| printf(" %g*age",cotvar[mw[mi][i]][Tvar[Tage[kk]]][i]);/* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ | |
| } | |
| printf(" s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],(s2==-1? -1: out[s1][s2]),(s2==-1? -1: savm[s1][s2])); | |
| if(globpr){ | if(globpr){ |
| fprintf(ficresilk,"%09ld %6.1f %6.1f %6d %2d %2d %2d %2d %3d %15.6f %8.4f %8.3f\ | fprintf(ficresilk,"%09ld %6.1f %6.1f %6d %2d %2d %2d %2d %3d %15.6f %8.4f %8.3f\ |
| %11.6f %11.6f %11.6f ", \ | %11.6f %11.6f %11.6f ", \ |
| Line 5158 Title=%s <br>Datafile=%s Firstpass=%d La | Line 5289 Title=%s <br>Datafile=%s Firstpass=%d La |
| if(anyvaryingduminmodel==1){ /* Some are varying covariates */ | if(anyvaryingduminmodel==1){ /* Some are varying covariates */ |
| for (z1=1; z1<=cptcoveff; z1++) { | for (z1=1; z1<=cptcoveff; z1++) { |
| if( Fixed[Tmodelind[z1]]==1){ | if( Fixed[Tmodelind[z1]]==1){ |
| iv= Tvar[Tmodelind[z1]]-ncovcol-nqv; | /* iv= Tvar[Tmodelind[z1]]-ncovcol-nqv; /\* Good *\/ */ |
| iv= Tvar[Tmodelind[z1]]; /* Good *//* because cotvar starts now at first at ncovcol+nqv+ntv */ | |
| if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]) /* iv=1 to ntv, right modality. If covariate's | if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]) /* iv=1 to ntv, right modality. If covariate's |
| value is -1, we don't select. It differs from the | value is -1, we don't select. It differs from the |
| constant and age model which counts them. */ | constant and age model which counts them. */ |
| Line 5239 Title=%s <br>Datafile=%s Firstpass=%d La | Line 5371 Title=%s <br>Datafile=%s Firstpass=%d La |
| fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable "); | fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable "); |
| fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable "); | fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable "); |
| fprintf(ficlog, "\n#********** Variable "); | fprintf(ficlog, "\n#********** Variable "); |
| for (z1=1; z1<=cptcovs; z1++){ | for (z1=1; z1<=cptcoveff; z1++){ |
| if(!FixedV[Tvaraff[z1]]){ | if(!FixedV[Tvaraff[z1]]){ |
| printf( "V%d(fixed)=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]); | printf( "V%d(fixed)=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]); |
| fprintf(ficresp, "V%d(fixed)=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]); | fprintf(ficresp, "V%d(fixed)=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]); |
| Line 5695 void prevalence(double ***probs, double | Line 5827 void prevalence(double ***probs, double |
| /* Tvar[Tmodelind[z1]] is the n of Vn; n-ncovcol-nqv is the first time varying covariate or iv */ | /* Tvar[Tmodelind[z1]] is the n of Vn; n-ncovcol-nqv is the first time varying covariate or iv */ |
| for (z1=1; z1<=cptcoveff; z1++){ | for (z1=1; z1<=cptcoveff; z1++){ |
| if( Fixed[Tmodelind[z1]]==1){ | if( Fixed[Tmodelind[z1]]==1){ |
| iv= Tvar[Tmodelind[z1]]-ncovcol-nqv; | iv= Tvar[Tmodelind[z1]];/* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */ |
| if (cotvar[m][iv][i]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]) /* iv=1 to ntv, right modality */ | if (cotvar[m][iv][i]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]) /* iv=1 to ntv, right modality */ |
| bool=0; | bool=0; |
| }else if( Fixed[Tmodelind[z1]]== 0) /* fixed */ | }else if( Fixed[Tmodelind[z1]]== 0) /* fixed */ |
| Line 6004 void concatwav(int wav[], int **dh, int | Line 6136 void concatwav(int wav[], int **dh, int |
| /* Loop on covariates without age and products and no quantitative variable */ | /* Loop on covariates without age and products and no quantitative variable */ |
| for (k=1; k<=cptcovt; k++) { /* cptcovt: total number of covariates of the model (2) nbocc(+)+1 = 8 excepting constant and age and age*age */ | for (k=1; k<=cptcovt; k++) { /* cptcovt: total number of covariates of the model (2) nbocc(+)+1 = 8 excepting constant and age and age*age */ |
| for (j=-1; (j < maxncov); j++) Ndum[j]=0; | for (j=-1; (j < maxncov); j++) Ndum[j]=0; |
| if(Dummy[k]==0 && Typevar[k] !=1){ /* Dummy covariate and not age product */ | printf("Testing k=%d, cptcovt=%d\n",k, cptcovt); |
| if(Dummy[k]==0 && Typevar[k] !=1 && Typevar[k] != 2){ /* Dummy covariate and not age product nor fixed product */ | |
| switch(Fixed[k]) { | switch(Fixed[k]) { |
| case 0: /* Testing on fixed dummy covariate, simple or product of fixed */ | case 0: /* Testing on fixed dummy covariate, simple or product of fixed */ |
| modmaxcovj=0; | modmaxcovj=0; |
| modmincovj=0; | modmincovj=0; |
| for (i=1; i<=imx; i++) { /* Loop on individuals: reads the data file to get the maximum value of the modality of this covariate Vj*/ | for (i=1; i<=imx; i++) { /* Loop on individuals: reads the data file to get the maximum value of the modality of this covariate Vj*/ |
| /* printf("Waiting for error tricode Tvar[%d]=%d i=%d (int)(covar[Tvar[k]][i]=%d\n",k,Tvar[k], i, (int)(covar[Tvar[k]][i])); */ | |
| ij=(int)(covar[Tvar[k]][i]); | ij=(int)(covar[Tvar[k]][i]); |
| /* ij=0 or 1 or -1. Value of the covariate Tvar[j] for individual i | /* ij=0 or 1 or -1. Value of the covariate Tvar[j] for individual i |
| * If product of Vn*Vm, still boolean *: | * If product of Vn*Vm, still boolean *: |
| Line 10144 int readdata(char datafile[], int firsto | Line 10278 int readdata(char datafile[], int firsto |
| printf("Covariate type in the data: V%d, DummyV(V%d)=%d, FixedV(V%d)=%d\n",v,v,DummyV[v],v,FixedV[v]); | printf("Covariate type in the data: V%d, DummyV(V%d)=%d, FixedV(V%d)=%d\n",v,v,DummyV[v],v,FixedV[v]); |
| fprintf(ficlog,"Covariate type in the data: V%d, DummyV(V%d)=%d, FixedV(V%d)=%d\n",v,v,DummyV[v],v,FixedV[v]); | fprintf(ficlog,"Covariate type in the data: V%d, DummyV(V%d)=%d, FixedV(V%d)=%d\n",v,v,DummyV[v],v,FixedV[v]); |
| } | } |
| ncovcolt=ncovcol+nqv+ntv+nqtv; /* total of covariates in the data, not in the model equation */ | |
| if((fic=fopen(datafile,"r"))==NULL) { | if((fic=fopen(datafile,"r"))==NULL) { |
| printf("Problem while opening datafile: %s with errno='%s'\n", datafile,strerror(errno));fflush(stdout); | printf("Problem while opening datafile: %s with errno='%s'\n", datafile,strerror(errno));fflush(stdout); |
| fprintf(ficlog,"Problem while opening datafile: %s with errno='%s'\n", datafile,strerror(errno));fflush(ficlog);return 1; | fprintf(ficlog,"Problem while opening datafile: %s with errno='%s'\n", datafile,strerror(errno));fflush(ficlog);return 1; |
| Line 10222 int readdata(char datafile[], int firsto | Line 10358 int readdata(char datafile[], int firsto |
| if(strb[0]=='.') { /* Missing value */ | if(strb[0]=='.') { /* Missing value */ |
| lval=-1; | lval=-1; |
| cotqvar[j][iv][i]=-1; /* 0.0/0.0 */ | cotqvar[j][iv][i]=-1; /* 0.0/0.0 */ |
| cotvar[j][ntv+iv][i]=-1; /* For performance reasons */ | cotvar[j][ncovcol+nqv+ntv+iv][i]=-1; /* For performance reasons */ |
| if(isalpha(strb[1])) { /* .m or .d Really Missing value */ | if(isalpha(strb[1])) { /* .m or .d Really Missing value */ |
| printf("Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be the %d th quantitative value out of %d measured at wave %d. If missing, you should remove this individual or impute a value. Exiting.\n", strb, linei,i,line,iv, nqtv, j); | printf("Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be the %d th quantitative value out of %d measured at wave %d. If missing, you should remove this individual or impute a value. Exiting.\n", strb, linei,i,line,iv, nqtv, j); |
| fprintf(ficlog,"Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be the %d th quantitative value out of %d measured at wave %d. If missing, you should remove this individual or impute a value. Exiting.\n", strb, linei,i,line,iv, nqtv, j);fflush(ficlog); | fprintf(ficlog,"Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be the %d th quantitative value out of %d measured at wave %d. If missing, you should remove this individual or impute a value. Exiting.\n", strb, linei,i,line,iv, nqtv, j);fflush(ficlog); |
| Line 10242 int readdata(char datafile[], int firsto | Line 10378 int readdata(char datafile[], int firsto |
| return 1; | return 1; |
| } | } |
| cotqvar[j][iv][i]=dval; | cotqvar[j][iv][i]=dval; |
| cotvar[j][ntv+iv][i]=dval; | cotvar[j][ncovcol+nqv+ntv+iv][i]=dval; /* because cotvar starts now at first ntv */ |
| } | } |
| strcpy(line,stra); | strcpy(line,stra); |
| }/* end loop ntqv */ | }/* end loop ntqv */ |
| Line 10282 int readdata(char datafile[], int firsto | Line 10418 int readdata(char datafile[], int firsto |
| Exiting.\n",lval,linei, i,line,iv,j);fflush(ficlog); | Exiting.\n",lval,linei, i,line,iv,j);fflush(ficlog); |
| return 1; | return 1; |
| } | } |
| cotvar[j][iv][i]=(double)(lval); | cotvar[j][ncovcol+nqv+iv][i]=(double)(lval); |
| strcpy(line,stra); | strcpy(line,stra); |
| }/* end loop ntv */ | }/* end loop ntv */ |
| Line 10725 int decodemodel( char model[], int lasto | Line 10861 int decodemodel( char model[], int lasto |
| * - cptcovn or number of covariates k of the models excluding age*products =6 and age*age | * - cptcovn or number of covariates k of the models excluding age*products =6 and age*age |
| * - cptcovage number of covariates with age*products =2 | * - cptcovage number of covariates with age*products =2 |
| * - cptcovs number of simple covariates | * - cptcovs number of simple covariates |
| * ncovcolt=ncovcol+nqv+ntv+nqtv total of covariates in the data, not in the model equation | |
| * - Tvar[k] is the id of the kth covariate Tvar[1]@12 {1, 2, 3, 8, 10, 11, 8, 3, 7, 8, 5, 6}, thus Tvar[5=V7*V8]=10 | * - Tvar[k] is the id of the kth covariate Tvar[1]@12 {1, 2, 3, 8, 10, 11, 8, 3, 7, 8, 5, 6}, thus Tvar[5=V7*V8]=10 |
| * which is a new column after the 9 (ncovcol) variables. | * which is a new column after the 9 (ncovcol+nqv+ntv+nqtv) variables. |
| * - if k is a product Vn*Vm, covar[k][i] is filled with correct values for each individual | * - if k is a product Vn*Vm, covar[k][i] is filled with correct values for each individual |
| * - Tprod[l] gives the kth covariates of the product Vn*Vm l=1 to cptcovprod-cptcovage | * - Tprod[l] gives the kth covariates of the product Vn*Vm l=1 to cptcovprod-cptcovage |
| * Tprod[1]@2 {5, 6}: position of first product V7*V8 is 5, and second V5*V6 is 6. | * Tprod[1]@2 {5, 6}: position of first product V7*V8 is 5, and second V5*V6 is 6. |
| Line 10870 int decodemodel( char model[], int lasto | Line 11007 int decodemodel( char model[], int lasto |
| cptcovn++; | cptcovn++; |
| cptcovprodnoage++;k1++; | cptcovprodnoage++;k1++; |
| cutl(stre,strb,strc,'V'); /* strc= Vn, stre is n; strb=V3*V2 stre=3 strc=*/ | cutl(stre,strb,strc,'V'); /* strc= Vn, stre is n; strb=V3*V2 stre=3 strc=*/ |
| Tvar[k]=ncovcol+nqv+ntv+nqtv+k1; /* For model-covariate k tells which data-covariate to use but | Tvar[k]=ncovcol+nqv+ntv+nqtv+k1; /* ncovcolt+k1; For model-covariate k tells which data-covariate to use but |
| because this model-covariate is a construction we invent a new column | because this model-covariate is a construction we invent a new column |
| which is after existing variables ncovcol+nqv+ntv+nqtv + k1 | which is after existing variables ncovcol+nqv+ntv+nqtv + k1 |
| If already ncovcol=4 and model= V2 + V1 + V1*V4 + age*V3 + V3*V2 | If already ncovcol=4 and model= V2 + V1 + V1*V4 + age*V3 + V3*V2 |
| thus after V4 we invent V5 and V6 because age*V3 will be computed in 4 | thus after V4 we invent V5 and V6 because age*V3 will be computed in 4 |
| Tvar[3=V1*V4]=4+1=5 Tvar[5=V3*V2]=4 + 2= 6, Tvar[4=age*V3]=4 etc */ | Tvar[3=V1*V4]=4+1=5 Tvar[5=V3*V2]=4 + 2= 6, Tvar[4=age*V3]=3 etc */ |
| /* Please remark that the new variables are model dependent */ | /* Please remark that the new variables are model dependent */ |
| /* If we have 4 variable but the model uses only 3, like in | /* If we have 4 variable but the model uses only 3, like in |
| * model= V1 + age*V1 + V2 + V3 + age*V2 + age*V3 + V1*V2 + V1*V3 | * model= V1 + age*V1 + V2 + V3 + age*V2 + age*V3 + V1*V2 + V1*V3 |
| Line 10884 int decodemodel( char model[], int lasto | Line 11021 int decodemodel( char model[], int lasto |
| * Tage[kk] [1]= 2 [2]=5 [3]=6 kk=1 to cptcovage=3 | * Tage[kk] [1]= 2 [2]=5 [3]=6 kk=1 to cptcovage=3 |
| * Tvar[Tage[kk]][1]=2 [2]=2 [3]=3 | * Tvar[Tage[kk]][1]=2 [2]=2 [3]=3 |
| */ | */ |
| Typevar[k]=2; /* 2 for double fixed dummy covariates */ | Typevar[k]=2; /* 2 for product */ |
| cutl(strc,strb,strd,'V'); /* strd was Vm, strc is m */ | cutl(strc,strb,strd,'V'); /* strd was Vm, strc is m */ |
| Tprod[k1]=k; /* Tprod[1]=3(=V1*V4) for V2+V1+V1*V4+age*V3+V3*V2 */ | Tprod[k1]=k; /* Tprod[1]=3(=V1*V4) for V2+V1+V1*V4+age*V3+V3*V2 */ |
| Tposprod[k]=k1; /* Tposprod[3]=1, Tposprod[2]=5 */ | Tposprod[k]=k1; /* Tposprod[3]=1, Tposprod[2]=5 */ |
| Line 10897 int decodemodel( char model[], int lasto | Line 11034 int decodemodel( char model[], int lasto |
| /* Tvar[cptcovt+k2+1]=Tvard[k1][2]; /\* Tvar[(cptcovt=4+(k2=1)+1)=6]= 4 (V4) *\/ */ | /* Tvar[cptcovt+k2+1]=Tvard[k1][2]; /\* Tvar[(cptcovt=4+(k2=1)+1)=6]= 4 (V4) *\/ */ |
| /*ncovcol=4 and model=V2+V1+V1*V4+age*V3+V3*V2, Tvar[3]=5, Tvar[4]=6, cptcovt=5 */ | /*ncovcol=4 and model=V2+V1+V1*V4+age*V3+V3*V2, Tvar[3]=5, Tvar[4]=6, cptcovt=5 */ |
| /* 1 2 3 4 5 | Tvar[5+1)=1, Tvar[7]=2 */ | /* 1 2 3 4 5 | Tvar[5+1)=1, Tvar[7]=2 */ |
| for (i=1; i<=lastobs;i++){ | 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 */ | |
| /* Computes the new covariate which is a product of | /* Computes the new covariate which is a product of |
| covar[n][i]* covar[m][i] and stores it at ncovol+k1 May not be defined */ | covar[n][i]* covar[m][i] and stores it at ncovol+k1 May not be defined */ |
| covar[ncovcol+k1][i]=covar[atoi(stre)][i]*covar[atoi(strc)][i]; | covar[ncovcolt+k1][i]=covar[atoi(stre)][i]*covar[atoi(strc)][i]; |
| } | } |
| } /*End of FixedV */ | |
| } /* End age is not in the model */ | } /* End age is not in the model */ |
| } /* End if model includes a product */ | } /* End if model includes a product */ |
| else { /* not a product */ | else { /* not a product */ |
| Line 10953 Typevar: 0 for simple covariate (dummy, | Line 11092 Typevar: 0 for simple covariate (dummy, |
| Fixed[k] 0=fixed (product or simple), 1 varying, 2 fixed with age product, 3 varying with age product \n\ | Fixed[k] 0=fixed (product or simple), 1 varying, 2 fixed with age product, 3 varying with age product \n\ |
| 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<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;} | for(k=-1;k<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;} |
| for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0;k<=cptcovt; k++){ /* or cptocvt */ | for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0, ncovvt=0;k<=cptcovt; k++){ /* or cptocvt */ |
| 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; |
| Dummy[k]= 0; | Dummy[k]= 0; |
| Line 10968 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11107 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| TvarFind[ncovf]=k; | TvarFind[ncovf]=k; |
| TvarFD[ncoveff]=Tvar[k]; /* TvarFD[1]=V1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ | TvarFD[ncoveff]=Tvar[k]; /* TvarFD[1]=V1 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ |
| TvarFDind[ncoveff]=k; /* TvarFDind[1]=9 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ | TvarFDind[ncoveff]=k; /* TvarFDind[1]=9 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ |
| }else if( Tvar[k] <=ncovcol && Typevar[k]==2){ /* Product of fixed dummy (<=ncovcol) covariates */ | /* }else if( Tvar[k] <=ncovcol && Typevar[k]==2){ /\* Product of fixed dummy (<=ncovcol) covariates For a fixed product k is higher than ncovcol *\/ */ |
| }else if( Tposprod[k]>0 && Typevar[k]==2 && FixedV[Tvardk[k][1]] == 0 && FixedV[Tvardk[k][2]] == 0){ /* Needs a fixed product Product of fixed dummy (<=ncovcol) covariates For a fixed product k is higher than ncovcol */ | |
| Fixed[k]= 0; | Fixed[k]= 0; |
| Dummy[k]= 0; | Dummy[k]= 0; |
| ncoveff++; | ncoveff++; |
| Line 10994 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11134 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| TvarFQ[nqfveff]=Tvar[k]-ncovcol; /* TvarFQ[1]=V2-1=1st in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ | TvarFQ[nqfveff]=Tvar[k]-ncovcol; /* TvarFQ[1]=V2-1=1st in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ |
| TvarFQind[nqfveff]=k; /* TvarFQind[1]=6 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ | TvarFQind[nqfveff]=k; /* TvarFQind[1]=6 in V5+V4+V3+V4*V3+V5*age+V2+V1*V2+V1*age+V1 */ /* Only simple fixed quantitative variable */ |
| }else if( Tvar[k] <=ncovcol+nqv+ntv && Typevar[k]==0){/* Only simple time varying dummy variables */ | }else if( Tvar[k] <=ncovcol+nqv+ntv && Typevar[k]==0){/* Only simple time varying dummy variables */ |
| /*# ID V1 V2 weight birth death 1st s1 V3 V4 V5 2nd s2 */ | |
| /* model V1+V3+age*V1+age*V3+V1*V3 */ | |
| /* Tvar={1, 3, 1, 3, 6}, the 6 comes from the fact that there are already V1, V2, V3, V4, V5 native covariates */ | |
| ncovvt++; | |
| TvarVV[ncovvt]=Tvar[k]; /* TvarVV[1]=V3 (first time varying in the model equation */ | |
| TvarVVind[ncovvt]=k; /* TvarVVind[1]=2 (second position in the model equation */ | |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 0; | Dummy[k]= 0; |
| ntveff++; /* Only simple time varying dummy variable */ | ntveff++; /* Only simple time varying dummy variable */ |
| Line 11011 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11158 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| 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 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); | printf("Quasi TmodelInvind[%d]=%d\n",k,Tvar[k]- ncovcol-nqv); |
| }else if( Tvar[k] <=ncovcol+nqv+ntv+nqtv && Typevar[k]==0){ /* Only simple time varying quantitative variable V5*/ | }else if( Tvar[k] <=ncovcol+nqv+ntv+nqtv && Typevar[k]==0){ /* Only simple time varying quantitative variable V5*/ |
| /*# ID V1 V2 weight birth death 1st s1 V3 V4 V5 2nd s2 */ | |
| /* model V1+V3+age*V1+age*V3+V1*V3 */ | |
| /* Tvar={1, 3, 1, 3, 6}, the 6 comes from the fact that there are already V1, V2, V3, V4, V5 native covariates */ | |
| ncovvt++; | |
| TvarVV[ncovvt]=Tvar[k]; /* TvarVV[1]=V3 (first time varying in the model equation */ | |
| TvarVVind[ncovvt]=k; /* TvarVV[1]=V3 (first time varying in the model equation */ | |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| nqtveff++; | nqtveff++; |
| Line 11057 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11211 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| modell[k].subtype= APVQ; /* Product age * varying quantitative */ | modell[k].subtype= APVQ; /* Product age * varying quantitative */ |
| /* nqtveff++;/\* Only simple time varying quantitative variable *\/ */ | /* nqtveff++;/\* Only simple time varying quantitative variable *\/ */ |
| } | } |
| }else if (Typevar[k] == 2) { /* product without age */ | }else if (Typevar[k] == 2) { /* product Vn * Vm without age, V1+V3+age*V1+age*V3+V1*V3 looking at V1*V3, Typevar={0, 0, 1, 1, 2}, k=5, V1 is fixed, V3 is timevary, V5 is a product */ |
| k1=Tposprod[k]; | /*# ID V1 V2 weight birth death 1st s1 V3 V4 V5 2nd s2 */ |
| if(Tvard[k1][1] <=ncovcol){ | /* model V1+V3+age*V1+age*V3+V1*V3 */ |
| if(Tvard[k1][2] <=ncovcol){ | /* Tvar={1, 3, 1, 3, 6}, the 6 comes from the fact that there are already V1, V2, V3, V4, V5 native covariates */ |
| k1=Tposprod[k]; /* Position in the products of product k, Tposprod={0, 0, 0, 0, 1} k1=1 first product but second time varying because of V3 */ | |
| ncovvt++; | |
| TvarVV[ncovvt]=Tvard[k1][1]; /* TvarVV[2]=V1 (because TvarVV[1] was V3, first time varying covariates */ | |
| TvarVVind[ncovvt]=k; /* TvarVVind[2]=5 (because TvarVVind[2] was V1*V3 at position 5 */ | |
| ncovvt++; | |
| TvarVV[ncovvt]=Tvard[k1][2]; /* TvarVV[3]=V3 */ | |
| TvarVVind[ncovvt]=k; /* TvarVVind[2]=5 (because TvarVVind[2] was V1*V3 at position 5 */ | |
| if(Tvard[k1][1] <=ncovcol){ /* Vn is dummy fixed, (Tvard[1][1]=V1), (Tvard[1][1]=V3 time varying) */ | |
| if(Tvard[k1][2] <=ncovcol){ /* Vm is dummy fixed */ | |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 0; | Dummy[k]= 0; |
| modell[k].maintype= FTYPE; | modell[k].maintype= FTYPE; |
| Line 11068 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11233 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| ncovf++; /* Fixed variables without age */ | ncovf++; /* Fixed variables without age */ |
| TvarF[ncovf]=Tvar[k]; | TvarF[ncovf]=Tvar[k]; |
| TvarFind[ncovf]=k; | TvarFind[ncovf]=k; |
| }else if(Tvard[k1][2] <=ncovcol+nqv){ | }else if(Tvard[k1][2] <=ncovcol+nqv){ /* Vm is quanti fixed */ |
| Fixed[k]= 0; /* or 2 ?*/ | Fixed[k]= 0; /* Fixed product */ |
| Dummy[k]= 1; | Dummy[k]= 1; |
| modell[k].maintype= FTYPE; | modell[k].maintype= FTYPE; |
| modell[k].subtype= FPDQ; /* Product fixed dummy * fixed quantitative */ | modell[k].subtype= FPDQ; /* Product fixed dummy * fixed quantitative */ |
| ncovf++; /* Varying variables without age */ | ncovf++; /* Varying variables without age */ |
| TvarF[ncovf]=Tvar[k]; | TvarF[ncovf]=Tvar[k]; |
| TvarFind[ncovf]=k; | TvarFind[ncovf]=k; |
| }else if(Tvard[k1][2] <=ncovcol+nqv+ntv){ | }else if(Tvard[k1][2] <=ncovcol+nqv+ntv){ /* Vm is a time varying dummy covariate */ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 0; | Dummy[k]= 0; |
| modell[k].maintype= VTYPE; | modell[k].maintype= VTYPE; |
| modell[k].subtype= VPDD; /* Product fixed dummy * varying dummy */ | modell[k].subtype= VPDD; /* Product fixed dummy * varying dummy */ |
| ncovv++; /* Varying variables without age */ | ncovv++; /* Varying variables without age */ |
| TvarV[ncovv]=Tvar[k]; | TvarV[ncovv]=Tvar[k]; /* TvarV[1]=Tvar[5]=5 because there is a V4 */ |
| TvarVind[ncovv]=k; | TvarVind[ncovv]=k;/* TvarVind[1]=5 */ |
| }else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){ | }else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){ /* Vm is a time varying quantitative covariate */ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| modell[k].maintype= VTYPE; | modell[k].maintype= VTYPE; |
| Line 11093 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11258 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| TvarV[ncovv]=Tvar[k]; | TvarV[ncovv]=Tvar[k]; |
| TvarVind[ncovv]=k; | TvarVind[ncovv]=k; |
| } | } |
| }else if(Tvard[k1][1] <=ncovcol+nqv){ | }else if(Tvard[k1][1] <=ncovcol+nqv){ /* Vn is fixed quanti */ |
| if(Tvard[k1][2] <=ncovcol){ | if(Tvard[k1][2] <=ncovcol){ /* Vm is fixed dummy */ |
| Fixed[k]= 0; /* or 2 ?*/ | Fixed[k]= 0; /* Fixed product */ |
| Dummy[k]= 1; | Dummy[k]= 1; |
| modell[k].maintype= FTYPE; | modell[k].maintype= FTYPE; |
| modell[k].subtype= FPDQ; /* Product fixed quantitative * fixed dummy */ | modell[k].subtype= FPDQ; /* Product fixed quantitative * fixed dummy */ |
| ncovf++; /* Fixed variables without age */ | ncovf++; /* Fixed variables without age */ |
| TvarF[ncovf]=Tvar[k]; | TvarF[ncovf]=Tvar[k]; |
| TvarFind[ncovf]=k; | TvarFind[ncovf]=k; |
| }else if(Tvard[k1][2] <=ncovcol+nqv+ntv){ | }else if(Tvard[k1][2] <=ncovcol+nqv+ntv){ /* Vm is time varying */ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| modell[k].maintype= VTYPE; | modell[k].maintype= VTYPE; |
| Line 11110 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11275 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| ncovv++; /* Varying variables without age */ | ncovv++; /* Varying variables without age */ |
| TvarV[ncovv]=Tvar[k]; | TvarV[ncovv]=Tvar[k]; |
| TvarVind[ncovv]=k; | TvarVind[ncovv]=k; |
| }else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){ | }else if(Tvard[k1][2] <=ncovcol+nqv+ntv+nqtv){ /* Vm is time varying quanti */ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| modell[k].maintype= VTYPE; | modell[k].maintype= VTYPE; |
| Line 11122 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11287 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| TvarV[ncovv]=Tvar[k]; | TvarV[ncovv]=Tvar[k]; |
| TvarVind[ncovv]=k; | TvarVind[ncovv]=k; |
| } | } |
| }else if(Tvard[k1][1] <=ncovcol+nqv+ntv){ | }else if(Tvard[k1][1] <=ncovcol+nqv+ntv){ /* Vn is time varying dummy */ |
| if(Tvard[k1][2] <=ncovcol){ | if(Tvard[k1][2] <=ncovcol){ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| Line 11156 Dummy[k] 0=dummy (0 1), 1 quantitative ( | Line 11321 Dummy[k] 0=dummy (0 1), 1 quantitative ( |
| TvarV[ncovv]=Tvar[k]; | TvarV[ncovv]=Tvar[k]; |
| TvarVind[ncovv]=k; | TvarVind[ncovv]=k; |
| } | } |
| }else if(Tvard[k1][1] <=ncovcol+nqv+ntv+nqtv){ | }else if(Tvard[k1][1] <=ncovcol+nqv+ntv+nqtv){ /* Vn is time varying quanti */ |
| if(Tvard[k1][2] <=ncovcol){ | if(Tvard[k1][2] <=ncovcol){ |
| Fixed[k]= 1; | Fixed[k]= 1; |
| Dummy[k]= 1; | Dummy[k]= 1; |
| Line 12366 int main(int argc, char *argv[]) | Line 12531 int main(int argc, char *argv[]) |
| covar=matrix(0,NCOVMAX,firstobs,lastobs); /**< used in readdata */ | covar=matrix(0,NCOVMAX,firstobs,lastobs); /**< used in readdata */ |
| if(nqv>=1)coqvar=matrix(1,nqv,firstobs,lastobs); /**< Fixed quantitative covariate */ | if(nqv>=1)coqvar=matrix(1,nqv,firstobs,lastobs); /**< Fixed quantitative covariate */ |
| if(nqtv>=1)cotqvar=ma3x(1,maxwav,1,nqtv,firstobs,lastobs); /**< Time varying quantitative covariate */ | if(nqtv>=1)cotqvar=ma3x(1,maxwav,1,nqtv,firstobs,lastobs); /**< Time varying quantitative covariate */ |
| if(ntv+nqtv>=1)cotvar=ma3x(1,maxwav,1,ntv+nqtv,firstobs,lastobs); /**< Time varying covariate (dummy and quantitative)*/ | /* if(ntv+nqtv>=1)cotvar=ma3x(1,maxwav,1,ntv+nqtv,firstobs,lastobs); /\**< Time varying covariate (dummy and quantitative)*\/ */ |
| if(ntv+nqtv>=1)cotvar=ma3x(1,maxwav,ncovcol+nqv+1,ncovcol+nqv+ntv+nqtv,firstobs,lastobs); /**< Might be better */ | |
| cptcovn=0; /*Number of covariates, i.e. number of '+' in model statement plus one, indepently of n in Vn*/ | 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 | /* v1+v2+v3+v2*v4+v5*age makes cptcovn = 5 |
| v1+v2*age+v2*v3 makes cptcovn = 3 | v1+v2*age+v2*v3 makes cptcovn = 3 |
| Line 12647 Please run with mle=-1 to get a correct | Line 12813 Please run with mle=-1 to get a correct |
| TvarVDind=ivector(1,NCOVMAX); /* */ | TvarVDind=ivector(1,NCOVMAX); /* */ |
| TvarVQ=ivector(1,NCOVMAX); /* */ | TvarVQ=ivector(1,NCOVMAX); /* */ |
| TvarVQind=ivector(1,NCOVMAX); /* */ | TvarVQind=ivector(1,NCOVMAX); /* */ |
| TvarVV=ivector(1,NCOVMAX); /* */ | |
| TvarVVind=ivector(1,NCOVMAX); /* */ | |
| Tvalsel=vector(1,NCOVMAX); /* */ | Tvalsel=vector(1,NCOVMAX); /* */ |
| Tvarsel=ivector(1,NCOVMAX); /* */ | Tvarsel=ivector(1,NCOVMAX); /* */ |
| Line 14168 Please run with mle=-1 to get a correct | Line 14336 Please run with mle=-1 to get a correct |
| free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath); | free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath); |
| free_matrix(newms, 1,nlstate+ndeath,1,nlstate+ndeath); | free_matrix(newms, 1,nlstate+ndeath,1,nlstate+ndeath); |
| free_matrix(savms, 1,nlstate+ndeath,1,nlstate+ndeath); | free_matrix(savms, 1,nlstate+ndeath,1,nlstate+ndeath); |
| if(ntv+nqtv>=1)free_ma3x(cotvar,1,maxwav,1,ntv+nqtv,firstobs,lastobs); | /* if(ntv+nqtv>=1)free_ma3x(cotvar,1,maxwav,1,ntv+nqtv,firstobs,lastobs); */ |
| if(ntv+nqtv>=1)free_ma3x(cotvar,1,maxwav,ncovcol+nqv+1,ncovcol+nqv+ntv+nqtv,firstobs,lastobs); | |
| if(nqtv>=1)free_ma3x(cotqvar,1,maxwav,1,nqtv,firstobs,lastobs); | if(nqtv>=1)free_ma3x(cotqvar,1,maxwav,1,nqtv,firstobs,lastobs); |
| if(nqv>=1)free_matrix(coqvar,1,nqv,firstobs,lastobs); | if(nqv>=1)free_matrix(coqvar,1,nqv,firstobs,lastobs); |
| free_matrix(covar,0,NCOVMAX,firstobs,lastobs); | free_matrix(covar,0,NCOVMAX,firstobs,lastobs); |
| Line 14207 Please run with mle=-1 to get a correct | Line 14376 Please run with mle=-1 to get a correct |
| free_ivector(TvarVDind,1,NCOVMAX); | free_ivector(TvarVDind,1,NCOVMAX); |
| free_ivector(TvarVQ,1,NCOVMAX); | free_ivector(TvarVQ,1,NCOVMAX); |
| free_ivector(TvarVQind,1,NCOVMAX); | free_ivector(TvarVQind,1,NCOVMAX); |
| free_ivector(TvarVV,1,NCOVMAX); | |
| free_ivector(TvarVVind,1,NCOVMAX); | |
| free_ivector(Tvarsel,1,NCOVMAX); | free_ivector(Tvarsel,1,NCOVMAX); |
| free_vector(Tvalsel,1,NCOVMAX); | free_vector(Tvalsel,1,NCOVMAX); |
| free_ivector(Tposprod,1,NCOVMAX); | free_ivector(Tposprod,1,NCOVMAX); |