Compute posterior distributions of Bayesian fit indices for an INLAvaan
model, analogous to blavaan::blavFitIndices().
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, orFALSEto 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. WhenFALSE, samples are drawn from the Gaussian (Laplace) approximation.- ...
Additional arguments passed to methods.
- x
An object of class
bfit_indices(forprint).
Value
An S3 object of class "bfit_indices" containing:
indicesNamed list of numeric vectors (one per posterior sample) for each computed fit index.
detailsList with
chisq(per-sample deviance),df,pD,rescale, andnsamp.
Use summary() to obtain a table of posterior summaries (Mean, SD,
quantiles, Mode) for each index.
Examples
# \donttest{
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
#> Posterior summary of devM-based Bayesian fit indices (nsamp = 100):
#>
#> BRMSEA BGammaHat adjBGammaHat BMc BCFI BTLI
#> 0.091 0.957 0.920 0.903 0.930 0.899
#> BNFI
#> 0.906
summary(bf)
#>
#> Posterior summary of devM-based Bayesian fit indices (nsamp = 100):
#>
#> Mean SD X2.5. X25. X50. X75. X97.5. Mode
#> BRMSEA 0.091 0.005 0.084 0.088 0.091 0.094 0.101 0.089
#> BGammaHat 0.957 0.004 0.947 0.954 0.957 0.959 0.963 0.958
#> adjBGammaHat 0.920 0.008 0.904 0.915 0.921 0.925 0.933 0.923
#> BMc 0.903 0.010 0.883 0.896 0.904 0.909 0.918 0.907
#> BCFI 0.930 0.007 0.915 0.925 0.931 0.935 0.942 0.933
#> BTLI 0.899 0.011 0.876 0.891 0.900 0.905 0.915 0.903
#> BNFI 0.906 0.007 0.891 0.901 0.907 0.911 0.917 0.909
# }
