Learn R Programming

lcmm (version 1.5.7)

predictY: Predicted values of a hlme, lcmm or Jointlcmm object in the natural scale of the longitudinal outcome for a specified profile of covariates.

Description

For hlme and Jointlcmm objects, the function computes the predicted values of the longitudinal marker in each latent class for a specified profile of covariates. For a lcmm object, the function computes predicted values in the natural scale of the outcome for a specified profile of covariates. For linear and threshold links, the predicted values are computed analytically. For splines and Beta links, a Gauss-Hermite or Monte-Carlo integration are used to numerically compute the predictions. In addition, for any type of link function, confidence bands (and median) can be computed by a Monte Carlo approximation of the posterior distribution of the predicted values.

Usage

## S3 method for class 'lcmm':
predictY(x,newdata,methInteg=0,nsim=20,draws=FALSE,ndraws=2000,na.action=1,...)

Arguments

x
an object inheriting from class lcmm representing a general latent class mixed model.
newdata
data frame containing the data from which predictions are computed. Data frame should include all the covariates listed in x$Xnames2. Names of data frame should be exactly x$Xnames2 that is the names of covariates specified in lcmm call.
methInteg
optional integer specifying the type of numerical integration required only for predictions with splines or Beta link functions. Value 0 (by default) specifies a Gauss-Hermite integration which is very rapid but neglects the correlation between the predic
nsim
For a lcmm object only; optional number of points used in the numerical integration with splines or Beta link functions. For methInteg=1, nsim should be chosen among the following values: 5, 7, 9, 15, 20, 30, 40 or 50 (nsim=20 by default). If
draws
For a lcmm object only; optional boolean specifying whether median and confidence bands of the predicted values should be computed (TRUE) - whatever the type of link function. In this case, a Monte Carlo approximation of the posterior distrib
ndraws
For a lcmm object only; if draws=TRUE, ndraws specifies the number of draws that should be generated to approximate the posterior distribution of the predicted values. By default, ndraws=2000.
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 either a matrix with ng columns when draws=FALSE or hlme and Jointlcmm objects corresponding to the ng class-specific vectors of predicted values computed at the point estimate or a matrix with ng*3 columns representing the ng class-specific 2.5%, 50% and 97.5% (median) percentiles of the approximated posterior distribution of the class-specific predicted values when draws=TRUE and the object is of class lcmm.

See Also

lcmm, plot.lcmm, hlme, Jointlcmm

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))
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