View source: R/growth-mixture-simulate.R
| simulate.latents_growth_mixture | R Documentation |
Draws new outcomes on the fitted design: each person's class from their membership probabilities, their random effects from that class's covariance, and their outcomes around their own trajectory with the class's residual variance.
## S3 method for class 'latents_growth_mixture'
simulate(object, nsim = 1, seed = NULL, ...)
object |
A |
nsim |
Number of simulated outcome vectors. |
seed |
|
... |
Unused. |
A base data.frame with one row per fitted row and one column per
simulation, sim_1, sim_2, ...
few_students <- subset(growth_scores, student <= 60)
small_fit <- mixture_regression(score ~ wave, few_students, n_classes = 2,
id = "student", class_level = "group",
random = "intercept", seed = 1)
head(simulate(small_fit, nsim = 2, seed = 1))
# All 300 students, with random intercepts and slopes
fit <- mixture_regression(score ~ wave, growth_scores, n_classes = 3,
id = "student", class_level = "group",
random = "wave", random_covariance = "equal",
n_starts = 2, seed = 1)
head(simulate(fit, nsim = 2, seed = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.