Loo
loo R package for approximate leave-one-out cross-validation (LOO-CV) and Pareto smoothed importance sampling (PSIS)
Install / Use
/learn @stan-dev/LooREADME
loo <img src="man/figures/logo.svg" align="right" width="120" />
<!-- badges: start --> <!-- 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
-
Vehtari, A., Gelman, A., and Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing. 27(5): 1413-1432. Journal, arXiv preprint
-
Vehtari, A., Simpson, D., Gelman, A., Yao, Y., and Gabry, J. (2024). Pareto smoothed importance sampling. Journal of Machine Learning Research, 25(72): 1-58. Journal, arXiv preprint
and computes model weights as described in
- Yao, Y., Vehtari, A., Simpson, D., and Gelman, A. (2018). Using stacking to average Bayesian predictive distributions. Bayesian Analysis 13(3): 917-1007. Journal, arXiv preprint
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
- mc-stan.org/loo (online documentation, vignettes)
- Ask a question (Stan Forums on Discourse)
- Open an issue (GitHub issues for bug reports, feature requests)
Installation
- Install the latest release from CRAN:
install.packages("loo")
- Install the latest development version from GitHub:
# 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.
Contributing to loo
Contributions are welcome! loo is under active development and pull requests are always appreciated. Bugs, ideas (with or without implementations) should be noted by opening an issue. Please read CONTRIBUTING.md for further details.
License
The code is distributed under the GPL 3 license. The documentation is distributed under the CC BY 4.0 license.
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
