simulate {nlsem} | R Documentation |
Simulate data from a structural equation model
Description
Simulate data from a structural equation mixture model.
Usage
## S3 method for class 'singleClass'
simulate(object, nsim = 1, seed = NULL, n = 400, m = 16, parameters, ...)
## S3 method for class 'semm'
simulate(object, nsim = 1, seed = NULL, n = 400, parameters, ...)
## S3 method for class 'nsemm'
simulate(object, nsim = 1, seed = NULL, n = 400, m = 16, parameters, ...)
Arguments
object |
structural equation model of class |
parameters |
‘true’ parameters which should be used to simulate data. |
nsim |
number of response vectors to simulate. Defaults to 1. |
seed |
set seed. Default is NULL. |
n |
data for how many observations should be simulated. |
m |
number of nodes for Hermite-Gaussian quadrature. Only needed
for |
... |
additional arguments. |
Value
Returns a matrix with n rows and as many columns as indicators are entered into the model.
Examples
# specify model
model <- specify_sem(num.x = 6, num.y = 3, num.xi = 2, num.eta = 1,
xi = "x1-x3,x4-x6", eta = "y1-y3", interaction = "eta1~xi1:xi2")
# original parameters
pars.orig <- c(.6, .5, .4, .5, .4, .6, .5, .2, .6, .7, .3, .2, .5,
.7, .3, .4, .6, .2, .3, .4, .6, .2, .2, .2, .2, .3,
.3, 1, 0, 0, .8)
# simulate data from model
dat <- simulate(model, parameters = pars.orig)
[Package nlsem version 0.8-1 Index]