plotLCTM: plotLCTM

View source: R/plotLCTM.R

plotLCTMR Documentation

plotLCTM

Description

A wrapper funciton to plot hlme trajectories in ggplot2 style. This does the same fuction as predictY in the lcmm package.

Usage

plotLCTM(m, shape, xlimit = c(0, 4.7), ylimit = c(20, 40),
  splinesnewdata = NULL)

Arguments

m

fitted hlme or lcmm model using the lcmm R package

Value

A plot in ggplot style

Examples

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

hlennon/LCTMtools documentation built on Dec. 6, 2022, 3:04 a.m.