bfit_indices: Bayesian Fit Indices

View source: R/method-fitmeasures.R

bfit_indicesR Documentation

Bayesian Fit Indices

Description

Compute posterior distributions of Bayesian fit indices for an INLAvaan model, analogous to blavaan::blavFitIndices().

Usage

bfit_indices(
  object,
  baseline.model = NULL,
  rescale = c("devM", "MCMC"),
  nsamp = NULL,
  samp_copula = TRUE
)

## S3 method for class 'bfit_indices'
summary(object, ...)

## S3 method for class 'bfit_indices'
print(x, ...)

Arguments

object

An object of class INLAvaan.

baseline.model

The baseline (null) model that the incremental fit indices (BCFI, BTLI, BNFI) are scaled against. NULL (default) fits the independence model on the same data and options automatically, as lavaan does: every observed variable keeps its variance (and intercept) and nothing correlates. That fit uses Gaussian marginals and no VB shift, since only its posterior draws and pD are needed, and takes a fraction of a second. Supply an INLAvaan object to use another baseline, or FALSE to skip the incremental indices.

rescale

Character string controlling how the Bayesian chi-square is rescaled. "devM" (default) subtracts pD from the deviance at each sample. "MCMC" uses the classical chi-square and classical df at each sample.

nsamp

Number of posterior samples to draw. Defaults to the value used when fitting the model.

samp_copula

Logical. When TRUE (default), posterior samples are drawn using the copula method with the fitted marginals. When FALSE, samples are drawn from the Gaussian (Laplace) approximation.

...

Additional arguments passed to methods.

x

An object of class bfit_indices (for print).

Value

An S3 object of class "bfit_indices" containing:

indices

Named list of numeric vectors (one per posterior sample) for each computed fit index.

details

List with chisq (per-sample deviance), df, pD, rescale, and nsamp.

Use summary() to obtain a table of posterior summaries (Mean, SD, quantiles, Mode) for each index.

See Also

lavaan::fitMeasures(), blavaan::blavFitIndices(), fitmeasures(), compare()

Examples


HS.model <- "
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
utils::data("HolzingerSwineford1939", package = "lavaan")
fit <- acfa(HS.model, HolzingerSwineford1939, std.lv = TRUE, nsamp = 100,
            verbose = FALSE)

# Absolute fit indices
bf <- bfit_indices(fit)
bf
summary(bf)



INLAvaan documentation built on Oct. 2, 2026, 1:07 a.m.