Stan Logo


Efficient approximate leave-one-out cross-validation

loo is an R package that allows users to perform efficient leave-one-out cross-validation for fitted Bayesian models. Leave-one-out cross-validation (LOO) and the widely applicable information criterion (WAIC) are methods for estimating pointwise out-of-sample prediction accuracy from a fitted Bayesian model using the log-likelihood evaluated at the posterior simulations of the parameter values. LOO and WAIC have various advantages over simpler estimates of predictive error such as AIC and DIC but are less used in practice because they involve additional computational steps.


The package implements the fast and stable computations for LOO from

From existing posterior simulation draws, we compute LOO 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.

As of version 2.0.0, the package also provides methods for using stacking and other model weighting techiques to average Bayesian predictive distributions. For details on stacking and model weighting see:


Install the latest release from CRAN


Install the latest development version from GitHub

if (!require(devtools)) {
devtools::install_github("stan-dev/loo", build_vignettes = FALSE)

You can also set build_vignettes=TRUE, but the vignettes take some time to buid and they can always be accessed online at

Python and Matlab/Octave Code

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