loo.brmsfit | R Documentation |
Perform approximate leave-one-out cross-validation based
on the posterior likelihood using the loo package.
For more details see loo
.
## S3 method for class 'brmsfit'
loo(
x,
...,
compare = TRUE,
resp = NULL,
pointwise = FALSE,
moment_match = FALSE,
reloo = FALSE,
k_threshold = 0.7,
save_psis = FALSE,
moment_match_args = list(),
reloo_args = list(),
model_names = NULL
)
x |
A |
... |
More |
compare |
A flag indicating if the information criteria
of the models should be compared to each other
via |
resp |
Optional names of response variables. If specified, predictions are performed only for the specified response variables. |
pointwise |
A flag indicating whether to compute the full
log-likelihood matrix at once or separately for each observation.
The latter approach is usually considerably slower but
requires much less working memory. Accordingly, if one runs
into memory issues, |
moment_match |
Logical; Indicate whether |
reloo |
Logical; Indicate whether |
k_threshold |
The Pareto |
save_psis |
Should the |
moment_match_args |
Optional named |
reloo_args |
Optional named |
model_names |
If |
See loo_compare
for details on model comparisons.
For brmsfit
objects, LOO
is an alias of loo
.
Use method add_criterion
to store
information criteria in the fitted model object for later usage.
If just one object is provided, an object of class loo
.
If multiple objects are provided, an object of class loolist
.
Vehtari, A., Gelman, A., & Gabry J. (2016). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. In Statistics and Computing, doi:10.1007/s11222-016-9696-4. arXiv preprint arXiv:1507.04544.
Gelman, A., Hwang, J., & Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24, 997-1016.
Watanabe, S. (2010). Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. The Journal of Machine Learning Research, 11, 3571-3594.
## Not run:
# model with population-level effects only
fit1 <- brm(rating ~ treat + period + carry,
data = inhaler)
(loo1 <- loo(fit1))
# model with an additional varying intercept for subjects
fit2 <- brm(rating ~ treat + period + carry + (1|subject),
data = inhaler)
(loo2 <- loo(fit2))
# compare both models
loo_compare(loo1, loo2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.