Description Usage Arguments Value Author(s) References Examples
View source: R/ctr_bayes_fit.R
This function provides a posterior distribution of some χ^2based fit indices to assess the global fit of a latent variable model.
1 2 3 4 5 6 7 8  blavFitIndices(object, thin = 1L, pD = c("loo","waic","dic"),
rescale = c("devM","ppmc","mcmc"),
fit.measures = "all", baseline.model = NULL)
## S4 method for signature 'blavFitIndices'
## S4 method for signature 'blavFitIndices'
summary(object, central.tendency = c("mean","median","mode"),
hpd = TRUE, prob = .90)

object 
An object of class 
thin 
Optional 
pD 

rescale 

fit.measures 
If 
baseline.model 
If not 
central.tendency 

hpd 

prob 
The "confidence" level of the credible interval(s). 
An S4 object of class blavFitIndices
consisting of 2 slots:

A 

A 
The summary()
method returns a data.frame
containing one row
for each requested fit.measure
, and columns containing the specified
measure(s) of central.tendency
, the posterior SD,
and (if requested) the HPD credibleinterval limits.
Mauricio GarnierVillareal (Marquette University; [email protected])
Terrence D. Jorgensen (University of Amsterdam; [email protected])
rescale = "PPMC"
based on:
Hoofs, H., van de Schoot, R., Jansen, N. W., & Kant, I. (2017). Evaluating model fit in Bayesian confirmatory factor analysis with large samples: Simulation study introducing the BRMSEA. Educational and Psychological Measurement. doi:10.1177/0013164417709314
rescale = "devM"
based on:
GarnierVillarreal, M., & Jorgensen, T. D. (in press). Adapting fit indices for Bayesian SEM: Comparison to maximum likelihood. Psychological Methods. doi:10.1037/met0000224 (See also https://osf.io/afkcw/)
Other references:
Vehtari, A., Gelman, A., & Gabry, J. (2017). Practical Bayesian model evaluation using leaveoneout crossvalidation and WAIC. Statistics and Computing, 27(5), 1413–1432. doi:10.1007/s1122201696964
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58  ## Not run:
HS.model < ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
## fit target model
fit1 < bcfa(HS.model, data = HolzingerSwineford1939, cp = "fa",
n.chains = 2, burnin = 1000, sample = 1000)
## fit null model to calculate CFI, TLI, and NFI
null.model < c(paste0("x", 1:9, " ~~ x", 1:9), paste0("x", 1:9, " ~ 1"))
fit0 < bcfa(null.model, data = HolzingerSwineford1939, cp = "fa",
n.chains = 2, burnin = 1000, sample = 1000)
## calculate posterior distributions of fit indices
## The default method mimics fit indices derived from ML estimation
ML < blavFitIndices(fit1, baseline.model = fit0)
ML
summary(ML)
## other options:
##  use Hoofs et al.'s (2017) PPMCbased method
##  use the estimated number of parameters from WAIC instead of LOOIC
PPMC < blavFitIndices(fit1, baseline.model = fit0,
pD = "waic", rescale = "PPMC")
## issues a warning about using rescale="PPMC" with N < 1000 (see Hoofs et al.)
##  specify only the desired measures of central tendency
##  specify a different "confidence" level for the credible intervals
summary(PPMC, central.tendency = c("mean","mode"), prob = .95)
## Access the posterior distributions for further investigation
head(distML < data.frame(ML@indices))
## For example, diagnostic plots using the bayesplot package:
## distinguish chains
nChains < blavInspect(fit1, "n.chains")
distML$Chain < rep(1:nChains, each = nrow(distML) / nChains)
library(bayesplot)
mcmc_pairs(distML, pars = c("BRMSEA","BMc","BGammaHat","BCFI","BTLI"),
diag_fun = "hist")
## Indices are highly correlated across iterations in both chains
## Compare to PPMC method
distPPMC < data.frame(PPMC@indices)
distPPMC$Chain < rep(1:nChains, each = nrow(distPPMC) / nChains)
mcmc_pairs(distPPMC, pars = c("BRMSEA","BMc","BGammaHat","BCFI","BTLI"),
diag_fun = "dens")
## nonlinear relation between BRMSEA, related to the floor effect of BRMSEA
## that Hoofs et al. found for larger (12indicator) models
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.