Fit an Approximate Bayesian Confirmatory Factor Analysis Model
acfa(
model,
data,
dp = blavaan::dpriors(),
marginal_method = c("skewnorm", "asymgaus", "marggaus", "sampling"),
nsamp = 500,
test = "standard",
marginal_correction = c("shortcut", "hessian", "none"),
sn_fit_logthresh = -6,
sn_fit_temp = NA,
control = list(),
verbose = TRUE,
debug = FALSE,
add_priors = TRUE,
optim_method = c("nlminb", "ucminf", "optim"),
numerical_grad = FALSE,
...
)An S4 object of class INLAvaan which is a subclass of the
lavaan::lavaan class.
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 lavParTable() function) is also
accepted.
An optional data frame containing the observed variables used in the model. If some variables are declared as ordered factors, lavaan will treat them as ordinal variables.
Default prior distributions on different types of
parameters, typically the result of a call to dpriors().
See the dpriors() help file for more information.
The method for approximating the marginal posterior
distributions. Options include "skewnorm" (skew normal), "asymgaus"
(two-piece asymmetric Gaussian), "marggaus" (marginalising the Laplace
approximation), and "sampling" (sampling from the joint Laplace
approximation).
The number of samples to draw for all sampling-based approaches (including posterior sampling for model fit indices).
Character indicating whether to compute posterior fit indices. Defaults to "standard". Change to "none" to skip these computations.
Which type of correction to use when fitting the
skew normal or two-piece Gaussian marginals. "hessian" computes the full
Hessian-based correction (slow), "shortcut" (default) computes only
diagonals, and "none" (or FALSE) applies no correction.
The log-threshold for fitting the skew normal. Points
with log-posterior drop below this threshold (relative to the maximum) will
be excluded from the fit. Defaults to -6.
Temperature parameter for fitting the skew normal. If
NA, the temperature will be included in the optimisation during the skew
normal fit.
A list of control parameters for the optimiser.
Logical indicating whether to print progress messages.
Logical indicating whether to return debug information.
Logical indicating whether to include prior densities in the posterior computation.
The optimisation method to use for finding the posterior
mode. Options include "nlminb" (default), "ucminf", and "optim"
(BFGS).
Logical indicating whether to use numerical gradients for the optimisation.
Additional arguments to be passed to the lavaan::lavaan model fitting function.
The acfa() function is a wrapper for the more general inlavaan()
function, using the following default arguments:
int.ov.free = TRUE
int.lv.free = FALSE
auto.fix.first = TRUE (unless std.lv = TRUE)
auto.fix.single = TRUE
auto.var = TRUE
auto.cov.lv.x = TRUE
auto.efa = TRUE
auto.th = TRUE
auto.delta = TRUE
auto.cov.y = TRUE
For further information regarding these arguments, please refer to the
lavaan::lavOptions() documentation.
Typically, users will interact with the specific latent variable
model functions instead, including acfa(), asem(), and agrowth().
# The famous Holzinger and Swineford (1939) example
HS.model <- "
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
"
utils::data("HolzingerSwineford1939", package = "lavaan")
# Fit a CFA model with standardised latent variables
fit <- acfa(HS.model, data = HolzingerSwineford1939, std.lv = TRUE, nsamp = 100)
summary(fit)
Run the code above in your browser using DataLab