Skip to contents

Extracts predicted random effects (BLUPs - Best Linear Unbiased Predictors) from a fitted growth mixture model with random effects.

Usage

get_random_effects(object, class_assignment = c("modal", "weighted", "all"))

Arguments

object

Fitted SurveyMixrRE object

class_assignment

Character: "modal" (use most likely class, default), "weighted" (weight by posterior probabilities), or "all" (return for all classes)

Value

Data frame with columns:

id

Individual ID

class

Latent class (if class_assignment != "all")

intercept

Predicted random intercept (if in model)

slope

Predicted random slope (if in model)

posterior_prob

Posterior probability of class membership

Examples

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

# Get random effects for modal class
re <- get_random_effects(fit)
head(re)

# Get random effects for all classes (weighted)
re_all <- get_random_effects(fit, class_assignment = "all")
} # }