## estimation of a 2 classes mixed model
m2 <- hlme(Y~Time*X1,mixture=~Time,random=~Time,classmb=~X2+X3,subject='ID',
ng=2,data=data_hlme,B=c(0.11,-0.74,-0.07,20.71,
29.39,-1,0.13,2.45,-0.29,4.5,0.36,0.79,0.97))
## simulate according to model m2 with same number of subjects and
## same measurement times as in data_lcmm. Binary covariates X1 and X2 are simulated
## according to a Bernoulli distribution with probability p=0.5, continuous covariate
## X3 is simulated according to a Gaussian distribution with mean=1 and sd=1 :
dsim1 <- simulate(m2, times=data_hlme[,c("ID","Time")],
Xbin=list(X1=0.5, X2=0.5), Xcont=list(X3=c(1,1)))
## simulate a dataset of 300 subjects according to the same model
## with new observation times, equally spaced and ranging from 0 to 3 :
dsim2 <- simulate(m2, times=c(0,3,0.5,0), n=300, tname="Time",
Xbin=list(X1=0.5, X2=0.5), Xcont=list(X3=c(1,1)))
Run the code above in your browser using DataLab