simulate.latents_mixture_regression: Simulate outcomes from a mixture-of-regressions fit

View source: R/mixture-regression-predict.R

simulate.latents_mixture_regressionR Documentation

Simulate outcomes from a mixture-of-regressions fit

Description

Draws class memberships from the fitted mixing model (group classes first in the two-level model, one class per group under class_level = "group"), then outcomes from each row's class regression, at the fitted rows' predictors.

Usage

## S3 method for class 'latents_mixture_regression'
simulate(object, nsim = 1, seed = NULL, ...)

Arguments

object

A fit from mixture_regression().

nsim

Number of simulated outcome vectors.

seed

NULL or an integer; the caller's random state is restored.

...

Unused.

Value

A base data.frame with one row per fitted row and one column per simulation, sim_1, sim_2, ...; for a binomial fit with more than one trial the columns hold success counts, and for an ordinal fit the fitted categories in the outcome's own type (a factor with the fitted levels, or the category numbers).

Examples

fit <- mixture_regression(score ~ hours, data = study_hours, n_classes = 2,
                          n_starts = 3, seed = 1)
head(simulate(fit, nsim = 2, seed = 1))

latents documentation built on Oct. 16, 2026, 5:09 p.m.