SimSem
template. Some notable features include fine control of misspecification and misspecification optimization, as well as the ability to generate non-normal data. When using simsem for simulations, this function is used internally to generate data in the function sim
, and can be helpful for debugging, or in creating data for use with other analysis programs.generate(model, n, maxDraw=50, misfitBounds=NULL, misfitType="f0",
averageNumMisspec=FALSE, optMisfit=NULL, optDraws=50,
createOrder = c(1, 2, 3), indDist=NULL, sequential=FALSE,
facDist=NULL, errorDist=NULL, indLab=NULL, modelBoot=FALSE,
realData=NULL, params=FALSE)
SimSem
object.TRUE
, the provided fit will be divided by the number of misspecified parameters.SimDataDist
object or list of objects for a distribution of indicators. If one object is passed, each indicator will have the same distribution. Use when sequential
is FALSE
.TRUE
, use a sequential method to create data such that the data from factor are generated first and apply to a set of equations to obtain the data of indicators. If FALSE
, create data directly from model-implied mean and covarSimDataDist
object or list of objects for the distribution of factors. If one object is passed, all factors will have the same distribution. Use when sequential
is TRUE
.SimDataDist
indicating the distribution of errors. If a single SimDataDist
is specified, each error will be genrated with that distribution.x1, x2, ... xN
.realData
.TRUE
, return the parameters drawn along with the generated data set. Default is FALSE
.mvrnorm
function ito create data from model implied covariance matrix if the data distribution object (SimDataDist
) is not specified. It the data distribution object is specified, the Gaussian copula model is used. See SimDataDist
for further details. For the model-based bootstrap, the transformation proposed by Yung & Bentler (1996) is used. This procedure is the expansion from the Bollen and Stine (1992) bootstrap including a mean structure. The model-implied mean vector and covariance matrix with trivial misspecification will be used in the model-based bootstrap if misspec
is specified. See page 133 of Bollen and Stine (1992) for a reference.
Internally, parameters are first drawn, and data is then created from these parameters. Both of these steps are available via the draw
and createData
functions respectively.draw
To draw parameters using theSimSem
template.createData
To generate random data using a set of parameters fromdraw
loading <- matrix(0, 6, 2)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
LY <- bind(loading, 0.7)
latent.cor <- matrix(NA, 2, 2)
diag(latent.cor) <- 1
RPS <- binds(latent.cor, 0.5)
RTE <- binds(diag(6))
VY <- bind(rep(NA,6),2)
CFA.Model <- model(LY = LY, RPS = RPS, RTE = RTE, modelType = "CFA")
dat <- generate(CFA.Model,200)
Run the code above in your browser using DataLab