Fit the same latent variable model to a (potentially large) number of datasets.
lavaanList(model = NULL, data_list = NULL, data_function = NULL,
data_function_args = list(), ndat = length(data_list), cmd = "lavaan",
..., store_slots = c("partable"), fun = NULL, show_progress = FALSE,
store_failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = min(2L, max(1L, parallel::detectCores() - 1L, na.rm = TRUE)),
cl = NULL, iseed = NULL)semList(model = NULL, data_list = NULL, data_function = NULL,
data_function_args = list(), ndat = length(data_list),
..., store_slots = c("partable"), fun = NULL, show_progress = FALSE,
store_failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = min(2L, max(1L, parallel::detectCores() - 1L, na.rm = TRUE)),
cl = NULL, iseed = NULL)
cfaList(model = NULL, data_list = NULL, data_function = NULL,
data_function_args = list(), ndat = length(data_list),
..., store_slots = c("partable"), fun = NULL, show_progress = FALSE,
store_failed = FALSE, parallel = c("no", "multicore", "snow"),
ncpus = min(2L, max(1L, parallel::detectCores() - 1L, na.rm = TRUE)),
cl = NULL, iseed = NULL)
An object of class lavaanList, for which several methods
are available, including a summary method.
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 (e.g., the output of the lavParTable() function) is also
accepted.
List. Each element contains a full data frame containing the observed variables used in the model.
Function. A function that generates 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 data_function function.
Integer. The number of datasets that should be generated using
the data_function function.
Character. The command used to run the SEM models. The possible
choices are "sem", "cfa" or "lavaan", which determine
how the default options are handled.
Other named arguments for the 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.
Function. A function which when applied to the
lavaan object returns the information of interest.
Logical. If TRUE, write (to tempdir()) the dataset
and (if available) the fitted object when the estimation for a particular
dataset failed for some reason. This allows post hoc 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: By default, this is 2 (following CRAN policy). You may set this to a higher value (for example, the number of available CPUs) if you wish to use more processes.
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.
class lavaanList
# 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() lavSimulateData(HS.model, sample_nobs = 100)
set.seed(1234)
fit <- semList(HS.model, data_function = generateData, ndat = 5,
store_slots = "partable")
# show parameter estimates, per dataset
coef(fit)
Run the code above in your browser using DataLab