Learn R Programming

lcmm (version 1.2)

plot.predict.hlme: Marginal class-specific predictions plot

Description

This function provides the class-specific predicted trajectories stemmed from a hlme object.

Usage

## S3 method for class 'hlme':
plot.predict(x,newdata,var.time,legend.loc="topright",\dots)

Arguments

x
an object inheriting from class hlme, representing a fitted latent class linear mixed-effects model
newdata
data frame containing the data from which predictions are computed. Data frame should include all the covariates listed in x$Xnames (in the same order). Names of data frame should be exactly x$Xnames.
var.time
A character string containing the name of the variable that corresponds to time in the data frame (x axis in the plot)
legend.loc
keyword for the position of the legend from the list "bottomright", "bottom", "bottomleft", "left", "topleft","top", "topright", "right" and
...
further arguments to be passed to or from other methods. They are ignored in this function.

Value

  • Returns a plot

See Also

hlme, postprob.hlme, plot.postprob.hlme

Examples

Run this code
data(data_hlme)

## fitted model
m<-hlme(Y~Time+X1+X1_time,mixture=~Time,random=~Time,classmb=~X2+X3,subject=ID,ng=2,data=data_hlme,B=c(0,0,0,30,25,0,-1,0,0,5,0,1,1))
## newdata for predictions plot
newdata<-data.frame(intercept=rep(1,100),Time=seq(0,5,length=100),X1=rep(0,100),X1_time=rep(0,100),X2=rep(0,100),X3=rep(0,100))
plot.predict.hlme(m,newdata,"Time","right")
## data from the first subject for predictions plot
firstdata<-cbind(intercept=rep(1,3),data_hlme[1:3,c("Time","X1","X1_time","X2","X3")])
plot.predict.hlme(m,firstdata,"Time","right")

Run the code above in your browser using DataLab