plotLCTM | R Documentation |
A wrapper funciton to plot hlme trajectories in ggplot2 style. This does the same fuction as predictY in the lcmm package.
plotLCTM(m, shape, xlimit = c(0, 4.7), ylimit = c(20, 40), splinesnewdata = NULL)
m |
fitted hlme or lcmm model using the lcmm R package |
A plot in ggplot style
library(ggplot2) data(bmi_long, package='LCTMtools') require(lcmm) model2class <- lcmm::hlme(fixed = bmi ~ age, mixture= ~ age, random= ~ age, nwg=TRUE, ng=2, subject="id", data=data.frame(bmi_long[1:500, ])) plotLCTM(model2class, shape="linear") library(splines) # For use of natural splines model2class_splines <- lcmm::hlme(fixed = bmi ~ ns(age, knots=2), mixture= ~ ns(age, knots=2), random= ~ age, nwg=TRUE, ng=2, subject="id", data=data.frame(bmi_long[1:500, ])) newdat <- data.frame(age=seq(0, 4.7, length=100)) #plotLCTM(model2class_splines, shape="splines", splinesnewdata = newdat, #xlimit=c(0, 4.7), ylimit=c(20, 40))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.