Home

Awesome

loo <img src="man/figures/stanlogo.png" align="right" width="120" />

<!-- badges: start -->

CRAN_Status_Badge RStudio_CRAN_mirror_downloads_badge codecov R-CMD-check

<!-- badges: end -->

Efficient approximate leave-one-out cross-validation for fitted Bayesian models

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.

Resources

Installation

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/.

Python and Matlab/Octave Code

Corresponding Python and Matlab/Octave code can be found at the avehtari/PSIS repository.

License

The code is distributed under the GPL 3 license. The documentation is distributed under the CC BY 4.0 license.