| acfa | R Documentation |
Fit an Approximate Bayesian Confirmatory Factor Analysis Model
acfa(
model,
data,
dp = priors_for(),
test = "standard",
vb_correction = TRUE,
n_qmc = 64L,
vb_method = c("sobol", "gauss_hermite"),
marginal_method = c("skewnorm", "asymgaus", "marggaus", "sampling"),
marginal_correction = c("shortcut", "shortcut_fd", "hessian", "none"),
nsamp = 1000,
samp_copula = TRUE,
samp_norta = FALSE,
cov_as_cor = FALSE,
sn_fit_ngrid = 21,
sn_fit_logthresh = -6,
sn_fit_temp = 1,
sn_fit_sample = TRUE,
control = list(),
verbose = TRUE,
debug = FALSE,
add_priors = TRUE,
optim_method = c("nlminb", "ucminf", "optim"),
numerical_grad = FALSE,
cores = NULL,
...
)
model |
A description of the user-specified model. Typically, the model
is described using the lavaan model syntax. See
|
data |
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. |
dp |
Default prior distributions for the different types of model
parameters; a named character vector as returned by |
test |
Character vector naming the post-estimation quantities to
compute and store with the fit. The atoms are |
vb_correction |
Logical indicating whether to apply a variational Bayes
correction for the posterior mean vector of estimates. Defaults to |
n_qmc |
Number of quasi-Monte Carlo nodes used by the VB mean
correction. Defaults to |
vb_method |
Integration rule for the VB mean correction. |
marginal_method |
The method for approximating the marginal posterior
distributions. Options include |
marginal_correction |
Which type of correction to use when fitting the
skew-normal or two-piece Gaussian marginals. |
nsamp |
The number of samples to draw for all sampling-based approaches (including posterior sampling for model fit indices). |
samp_copula |
Logical. When |
samp_norta |
Logical. When |
cov_as_cor |
Logical. Residual and latent-disturbance covariance
parameters ( |
sn_fit_ngrid |
Number of grid points to lay out per dimension when
fitting the skew-normal marginals. A finer grid gives a better fit at the
cost of more joint-log-posterior evaluations. Defaults to |
sn_fit_logthresh |
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 |
sn_fit_temp |
Temperature parameter for fitting the skew-normal.
Defaults to |
sn_fit_sample |
Logical. When |
control |
A list of control parameters for the optimiser. For the
default |
verbose |
Logical indicating whether to print progress messages. |
debug |
Logical indicating whether to return debug information. |
add_priors |
Logical indicating whether to include prior densities in the posterior computation. |
optim_method |
The optimisation method to use for finding the posterior
mode. Options include |
numerical_grad |
Logical indicating whether to use numerical gradients
for the optimisation. Defaults to |
cores |
Integer or |
... |
Additional arguments to be passed to the 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.
An S4 object of class INLAvaan which is a subclass of the
lavaan class.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.