loo R package for approximate leave-one-out cross-validation (LOO-CV) and Pareto smoothed importance sampling (PSIS)
loo is an R package that allows users to compute efficient approximate
leave-one-out cross-validation for fitted Bayesian models, as well as model
weights that can be used to average predictive distributions.
The loo package package implements the fast and stable computations for
approximate LOO-CV and WAIC from
and computes model weights as described in
From existing posterior simulation draws, we compute approximate LOO-CV using
Pareto smoothed importance sampling (PSIS), a new procedure for regularizing
importance weights. As a byproduct of our calculations, we also obtain
approximate standard errors for estimated predictive errors and for comparing
predictive errors between two models. We recommend PSIS-LOO-CV instead of WAIC,
because PSIS provides useful diagnostics and effective sample size and Monte
Carlo standard error estimates.
install.packages("loo")
# install.packages("remotes")
remotes::install_github("stan-dev/loo")
We do not recommend setting build_vignettes=TRUE
when installing from GitHub
because some of the vignettes take a long time to build and are always available
online at mc-stan.org/loo/articles/.
Corresponding Python and Matlab/Octave code can be found at the
avehtari/PSIS repository.
The code is distributed under the GPL 3 license. The documentation is distributed under the CC BY 4.0 license.