################# Prediction from a 2-class model with a Splines link function
data(data_Jointlcmm)
## fitted model
m<-lcmm(Ydep2~Time*X1,mixture=~Time,random=~Time,classmb=~X2+X3,
subject='ID',ng=2,data=data_Jointlcmm,link="splines",B=c(
-0.175, -0.191, 0.654, -0.443,
-0.345, -1.780, 0.913, 0.016,
0.389, 0.028, 0.083, -7.349,
0.722, 0.770, 1.376, 1.653,
1.640, 1.285))
m
## predictions for times from 0 to 5 for X1=0
newdata<-data.frame(Time=seq(0,5,length=100),
X1=rep(0,100),X2=rep(0,100),X3=rep(0,100))
predictY(m,newdata)
## Option draws=TRUE to compute a MonteCarlo
# approximation of the predicted value distribution
# (quite long with ndraws=2000 by default)
predictY(m,newdata,draws=TRUE)
## predictions for times from 0 to 5 for X1=1
newdata$X1 <- 1
predictY(m,newdata)
## Option draws=TRUE to compute a MonteCarlo
# approximation of the predicted value distribution
# (quite long with ndraws=2000 by default)
predictY(m,newdata,draws=TRUE)
Run the code above in your browser using DataLab