| logLik | R Documentation |
Extract a log-likelihood-flavoured summary from a fitted INLAvaan
model. Two distinct quantities are available, deliberately not conflated:
the Bayesian marginal log-likelihood (the default) and the classical
log-likelihood evaluated at the posterior mean.
## S4 method for signature 'INLAvaan'
logLik(object, type = c("marginal", "plugin"), ...)
## S4 method for signature 'INLAvaan'
AIC(object, ..., k = 2)
## S4 method for signature 'INLAvaan'
BIC(object, ...)
object |
An object of class INLAvaan. |
type |
Character. |
... |
Currently unused. |
k |
Numeric penalty per parameter passed to the (disabled) |
The marginal log-likelihood already integrates over the (Laplace-
approximated) posterior, so it is not on the same scale as a classical
log-likelihood and should not be passed to AIC()/BIC() –
doing so would double-penalise model complexity that the evidence has
already accounted for. Use compare() to compare models via Bayes
factors, DIC, or LOO/WAIC. The plug-in variant exists for users who
specifically want a point-estimate-based classical comparison.
AIC()/BIC() on an INLAvaan fit are themselves
disabled (mirroring anova()): both are large-sample asymptotic
approximations to quantities INLAvaan already computes directly –
AIC approximates predictive accuracy, which loo()/waic()
already estimate more rigorously; BIC approximates -2 times
the log marginal likelihood, which logLik() already returns
directly (up to the Laplace approximation). Point-estimate AIC/BIC remain
available for reporting-convention purposes via
AIC(logLik(object, type = "plugin")) /
BIC(logLik(object, type = "plugin")).
For type = "marginal", a length-one numeric of class
inlavaan_logLik that prints with a note on its interpretation.
For type = "plugin", a standard "logLik" object.
deviance(), compare(), loo(), waic()
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)
# Marginal log-likelihood (log evidence)
logLik(fit)
# Classical log-likelihood at the posterior mean, AIC/BIC-compatible
ll <- logLik(fit, type = "plugin")
AIC(ll)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.