| simulate_lpa | R Documentation |
Draws each observation from a multivariate normal mixture: a profile is
sampled from proportions, then the indicators are drawn from that
profile's means, standard deviations and within-profile correlation matrix.
simulate_lpa(
n,
means,
sds = 1,
proportions = NULL,
correlations = NULL,
labels = NULL,
seed = NULL,
batch = NULL
)
n |
Number of observations. A single whole number of at least 2. |
means |
Profile-by-variable mean matrix (one row per profile, one
column per indicator, at least 2 rows), or a tidy data frame with columns
|
sds |
Scalar (the default, |
proportions |
Profile proportions, one positive value per profile;
they are rescaled to sum to one. |
correlations |
Optional list of within-profile correlation matrices,
one per profile, or a tidy data frame with columns |
labels |
Optional profile labels, one unique value per profile.
Defaults to the profile names given with |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A simulab_sim base data.frame with one row per observation and
columns id, profile (the true profile label) and one numeric column
per indicator. A parameters component holds one row per
profile-by-variable combination with columns profile, variable,
mean, sd and proportion.
# `means` is one row per profile and one column per indicator.
result <- simulate_lpa(
n = 200,
means = matrix(c(0, 0, 3, 3), nrow = 2, byrow = TRUE),
proportions = c(0.6, 0.4),
seed = 1
)
head(result)
as.data.frame(result, what = "parameters")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.