simulate.slca {slca} | R Documentation |
Simulate data from slca
model.
Description
This function simulates data from a constructed slca
model. If the model is not already estimated, parameters can be specified by the user or generated randomly.
Usage
## S3 method for class 'slca'
simulate(object, nsim = 500, seed = NULL, parm, nlevel, ...)
Arguments
object |
a |
nsim |
the number of response observations to simulate. Defaults to 500. |
seed |
a random seed for reproducibility of the |
parm |
a set of parameters provided by the user to guide the simulation, if the model has not been estimated. |
nlevel |
the number of levels for each manifest item declared in the model. If not provided, the default is 2. |
... |
additional arguments. |
Value
A list
of two components:
class |
A |
response |
A |
Examples
library(magrittr)
model <- slca(lc1[3] ~ x1 + x2 + x3 + x4 + x5)
sim_data <- model %>% simulate(nlevel = c(3, 3, 3, 3, 3))
y <- sim_data$response
sapply(y, table)
sim_data <- model %>%
simulate(nlevel = c(x1 = 2, x3 = 3, x4 = 4, x5 = 5))
y <- sim_data$response
sapply(y, table)
model <- slca(lc1[3] ~ x1 + x2 + x3 + x4 + x5,
lc2[4] ~ y1 + y2 + y3 + y4 + y5)
sim_data <- model %>% simulate(1000)
sapply(sim_data$class, table)