Learn R Programming

nlsem (version 0.8-1)

simulate: Simulate data from a structural equation model

Description

Simulate data from a structural equation mixture model.

Usage

# S3 method for singleClass
simulate(object, nsim = 1, seed = NULL, n = 400, m = 16, parameters, ...)
# S3 method for semm
simulate(object, nsim = 1, seed = NULL, n = 400, parameters, ...)
# S3 method for nsemm
simulate(object, nsim = 1, seed = NULL, n = 400, m = 16, parameters, ...)

Value

Returns a matrix with n rows and as many columns as indicators are entered into the model.

Arguments

object

structural equation model of class singleClass, semm, or nsemm.

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 singleClass and nsemm.

...

additional arguments.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab