Skip to contents

Visualizes the distribution of predicted random effects for each latent class.

Usage

plot_random_effects(
  object,
  type = c("density", "qq", "caterpillar", "scatter"),
  which = c("intercept", "slope", "both")
)

Arguments

object

Fitted SurveyMixrRE object

type

Character: "density", "qq", "caterpillar", or "scatter"

which

Character: "intercept", "slope", or "both"

Value

ggplot2 object

Examples

if (FALSE) { # \dontrun{
# Note: Random effects functionality is under development
fit <- gmm_survey_re(
  data = mcs_simulated,
  id = "id", time = "age", outcome = "selfcontrol",
  n_classes = 3, random = ~ 1 + age, starts = 100
)

# Density plots of random intercepts
plot_random_effects(fit, type = "density", which = "intercept")

# QQ plots to check normality
plot_random_effects(fit, type = "qq", which = "both")

# Caterpillar plot with confidence intervals
plot_random_effects(fit, type = "caterpillar", which = "slope")

# Scatter plot of intercepts vs slopes
plot_random_effects(fit, type = "scatter")
} # }