| SIMULATE | R Documentation |
Creates a simulation specification that can be passed to rblimp() as the data argument.
Instead of reading existing data, rblimp() will use Blimp's SIMULATE command to generate
data and then fit the specified model to it.
SIMULATE(model, n, define = NULL, variables = NULL)
model |
Character string or vector specifying data generation equations.
Same format as |
n |
Sample size. For single-level: integer. For multilevel: named list. |
define |
Character vector or string of parameter definitions (optional). |
variables |
Formula or character string specifying which variables to save (optional). |
A blimp_simulate object (subclass of blimp_syntax) that can be passed to
rblimp() as the data argument.
rblimp_sim() for directly generating simulated data without fitting a model
# Create simulation specification
sim_spec <- SIMULATE(
model = c(
"x = normal(0, 1)",
"y = normal(10 + x*0.5, 1)"
),
n = 1000
)
# View the specification
print(sim_spec)
# Use in rblimp to fit a model to simulated data
mdl <- rblimp(
model = "y ~ x",
data = sim_spec,
seed = 123,
burn = 5000,
iter = 5000
)
summary(mdl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.