Fit the same latent variable model, for a (potentially large) number of datasets.
lavaanList(model = NULL, dataList = NULL, dataFunction = NULL,
dataFunction.args = list(), ndat = length(dataList), cmd = "lavaan",
..., store.slots = c("partable"), FUN = NULL, show.progress = FALSE,
store.failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = max(1L, parallel::detectCores() - 1L), cl = NULL, iseed = NULL)semList(model = NULL, dataList = NULL, dataFunction = NULL,
dataFunction.args = list(), ndat = length(dataList),
..., store.slots = c("partable"), FUN = NULL, show.progress = FALSE,
store.failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = max(1L, parallel::detectCores() - 1L), cl = NULL, iseed = NULL)
cfaList(model = NULL, dataList = NULL, dataFunction = NULL,
dataFunction.args = list(), ndat = length(dataList),
..., store.slots = c("partable"), FUN = NULL, show.progress = FALSE,
store.failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = max(1L, parallel::detectCores() - 1L), cl = NULL, iseed = NULL)
A description of the user-specified model. Typically, the model
is described using the lavaan model syntax. See
model.syntax
for more information. Alternatively, a
parameter table (eg. the output of the lavaanify()
function) is also
accepted.
List. Each element contains a full data frame containing the observed variables used in the model.
Function. A function that generated a full data frame containing the observed variables used in the model. It can also be a matrix, if the columns are named.
List. Optional list of arguments that are passed
to the dataFunction
function.
Integer. The number of datasets that should be generated using
the dataFunction
function.
Character. Which command is used to run the sem models. The possible
choices are "sem"
, "cfa"
or "lavaan"
, determining how
we deal with default options.
Other named arguments for lavaan
function.
Character vector. Which slots (from a lavaan object)
should be stored for each dataset? The possible choices are
"timing"
, "partable"
, "data"
, "samplestats"
,
"vcov"
, "test"
, "optim"
, "h1"
, "loglik"
,
or "implied"
. Finally, "all"
selects all slots.
Logical. If TRUE
, write (to tempdir()) the dataset
and (if available) the fitted object when the estimation for a particular
dataset somehow failed. This will allow posthoc inspection of the problem.
The type of parallel operation to be used (if any). If
missing, the default is "no"
.
Integer. The number of processes to be used in parallel operation: typically one would chose this to the number of available CPUs.
An optional parallel or snow cluster for use if
parallel = "snow"
. If not supplied, a cluster on the local machine is
created for the duration of the lavaanList
call.
An integer to set the seed. Or NULL if no reproducible seeds are
needed. To make this work, make sure the first
RNGkind() element is "L'Ecuyer-CMRG"
. You can check this by
typing RNGkind()
in the console. You can set it by typing
RNGkind("L'Ecuyer-CMRG")
, before the lavaanList functions are called.
If TRUE
, show information for each dataset.
An object of class '>lavaanList
, for which several methods
are available, including a summary
method.
# NOT RUN {
# The Holzinger and Swineford (1939) example
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# a data generating function
generateData <- function() simulateData(HS.model, sample.nobs = 100)
set.seed(1234)
fit <- semList(HS.model, dataFunction = generateData, ndat = 5,
store.slots = "partable")
# show parameter estimates, per dataset
coef(fit)
# }
Run the code above in your browser using DataLab