residualplot_step1 | R Documentation |
A wrapper funciton to implement step 1 of the 8 step framework. This is a wrapper fuction to the lcmm/hlme model fit to examine the class-specific residuals in order to aid choice of random effect distribution.
residualplot_step1(model, nameofoutcome, nameofage, data, ylimit = c(-50, 50))
model |
fitted hlme or lcmm model using the lcmm R package |
nameofoutcome |
Name of the longitudinal variable in the dataset |
nameofage |
Name of the age variable in the dataset |
data |
Name of the dataframe (long format) used for the regression fit |
type |
Type of residual plots: lines (spaghetti) or points |
Class-specific residual plots in ggplot style
library(ggplot2) data(bmi_long, package = "LCTMtools") require(lcmm) model2class <- lcmm::hlme( fixed = bmi ~ age, mixture = ~age, random = ~ -1, nwg = TRUE, ng = 2, subject = "id", data = data.frame(bmi_long[1:500, ]) ) residualplot_step1(model2class, nameofoutcome = "bmi", nameofage = "age", data = bmi_long, )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.