| deviance | R Documentation |
Extract the (Bayesian) deviance of a fitted INLAvaan model. Unlike
lavaan, which has no deviance() method, this follows the
BUGS/JAGS/Stan convention: "deviance" is -2 times the log-likelihood,
summarised over the posterior.
## S3 method for class 'INLAvaan'
deviance(object, type = c("mean", "plugin"), ...)
object |
An object of class INLAvaan. |
type |
Character. |
... |
Currently unused. |
\bar{D} and \hat{D} are the two ingredients of the Deviance
Information Criterion, DIC = \bar{D} + p_D where
p_D = \bar{D} - \hat{D} is the effective number of parameters. Use
compare() to compare models by DIC (or Bayes factors, or LOO/WAIC)
rather than comparing raw deviances directly.
This p_D is estimated from the posterior draws. loo() reaches the
same quantity in closed form as pd_trace, the trace
\mathrm{tr}(\Sigma \mathcal{I}); the two routes estimate one target
but do not agree exactly in a finite sample. Neither is p_loo, which
estimates something else entirely (see loo()).
A length-one numeric of class inlavaan_deviance, with the
effective number of parameters (pD) and DIC attached as
attributes.
logLik(), compare()
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,
test = "standard", verbose = FALSE)
deviance(fit)
attr(deviance(fit), "DIC")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.