Learn R Programming

lcmm (version 1.6.6)

predictL: Class-specific marginal predictions in the latent process scale for lcmm and multlcmm objects

Description

This function provides a matrix containing the class-specific predicted trajectories computed in the latent process scale, that is the latent process underlying the curvilinear outcome(s), for a profile of covariates specified by the user. This function applies only to lcmm and multlcmm objects. The function plot.predict provides directly the plot of these class-specific predicted trajectories. The function predictY provides the class-specific predicted trajectories computed in the natural scale of the outcome(s).

Usage

## S3 method for class 'lcmm':
predictL(x,newdata,na.action=1,...)
## S3 method for class 'multlcmm':
predictL(x,newdata,na.action=1,...)

Arguments

x
an object inheriting from class lcmm or multlcmm representing a (latent class) mixed model involving a latent process and estimated link function(s).
newdata
data frame containing the data from which predictions are computed. The data frame should include at least all the covariates listed in x$Xnames2. Names in the data frame should be exactly x$Xnames2 that are the names of covariates specified in lcmm
na.action
Integer indicating how NAs are managed. The default is 1 for 'na.omit'. The alternative is 2 for 'na.fail'. Other options such as 'na.pass' or 'na.exclude' are not implemented in the current version.
...
further arguments to be passed to or from other methods. They are ignored in this function.

Value

  • Returns a matrix

See Also

plot.predict, predictY, lcmm

Examples

Run this code
#### 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))
summary(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))
predictL(m,newdata)
## predictions for times from 0 to 5 for X1=1
newdata$X1 <- 1
predictY(m,newdata)

Run the code above in your browser using DataLab