residualplot_step1: residualplot_step1

residualplot_step1R Documentation

residualplot_step1

Description

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.

Usage

residualplot_step1(model, nameofoutcome, nameofage, data, ylimit = c(-50,
  50))

Arguments

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

Value

Class-specific residual plots in ggplot style

Examples

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

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