Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1c5d871
feat: add predictive performance measures as pred_measure* family
Jul 2, 2026
bad8062
feat: update print method for new pred_measure* family
Jul 2, 2026
6d404e1
feat: deprecate loo functions in favor of new pred_measure family
Jul 2, 2026
f5854c2
tests: update tests for deprecated functions
Jul 2, 2026
c42c803
docs: add migration guide to loo package
Jul 2, 2026
7750200
docs: update documentation for new pred_measure functions and depreca…
Jul 2, 2026
1926429
chore: update DESCRIPTION, NAMESPACE, NEWS and _pkgdown
Jul 2, 2026
02ecbbb
tests: add test data
Jul 3, 2026
a24fee1
tests: add unit tests for pred_measure function family
Jul 3, 2026
3a670cf
fix: update elpd and fix typo in .compute_base_measure
Jul 3, 2026
439867e
fix:update measure names in .validate_control
Jul 3, 2026
883dda0
docs: add vignettes for new predictive preformance measure
Jul 3, 2026
755984d
docs: add/update cross-references to vignettes
Jul 3, 2026
b260a32
chore: add data fitting to CI and avoid committing large data files
Jul 3, 2026
082d7be
chore: add cli to Imports and lme4 to Suggests
Jul 3, 2026
e394c30
fix: minor fixes
Jul 3, 2026
e9f1a3a
chore: add developer-notes
Jul 3, 2026
cf0c79b
add print method of test_pred_measure
Jul 3, 2026
5cb9f10
chore: update developer-notes and add old-vs.-new API comparison
Jul 3, 2026
562b141
fix: small fixes to pass test checks
Jul 3, 2026
023add0
Merge branch 'loo-v3.0.0' into pred_measure
florence-bockting Jul 3, 2026
8346344
tests: update snapshots
Jul 4, 2026
e99aeac
tests: add snapshots for pred_measure_builtin
Jul 6, 2026
884df6e
refactor: add class loo to loo_pred_measure
Jul 6, 2026
b924ac5
docs: update pkg-info
Jul 7, 2026
f64cf6c
refactor: rename revert_sign arg to higher_is_better
Jul 8, 2026
441f0ea
docs: update renaming arg to higher_is_better
Jul 8, 2026
b0015c7
tests: update renaming to higher_is_better
Jul 8, 2026
076e2c7
chore: update renaming higher_is_better argument
Jul 8, 2026
674746e
Merge branch 'loo-v3.0.0' into pred_measure
florence-bockting Jul 16, 2026
a1e66e5
Merge branch 'loo-v3.0.0' into pred_measure
florence-bockting Aug 28, 2026
0d1e072
Merge branch 'loo-v3.0.0' into pred_measure
florence-bockting Aug 28, 2026
b0f94cb
fix: computation of weights for (s)rps
Aug 30, 2026
7184cae
fix: refactor computation of ic and mlpd
Aug 30, 2026
91f251a
fix: computation of weights for (s)rps
Aug 30, 2026
757021e
tests: add tests for mlpd, ic, and updated weigts for (s)rps
Aug 30, 2026
f08afcc
fix: check equality of log_weights from loo and psis_object
Aug 30, 2026
806600b
fix: pass name of measures correctly
Aug 30, 2026
0c85ba8
review: add guards for potential silent failures
Aug 30, 2026
d0b52fa
fix: kfold diagnostics, dims on update, reuse stored log_weights
Aug 30, 2026
1b1d050
fix: bacc pointwise path, dims after 3-D conversion, duplicate filter
Aug 30, 2026
8c46b00
fix: error on group_ids until grouped summaries exist
Aug 30, 2026
e74df04
refactor: extract .lppd_from_inputs() from elpd, mlpd and ic
Aug 30, 2026
b3a7db7
refactor: extract .acc_pointwise() from acc and bacc
Aug 30, 2026
12133b8
refactor: extract .point_error_from_inputs() from mae and mse
Aug 30, 2026
bd67f6a
refactor: read the source from the attribute, reuse .measure_estimate…
Aug 30, 2026
ef914d8
refactor: print the Pareto k table with pareto_k_table()
Aug 30, 2026
f79c4f8
refactor: remove dead code and correct the .compute_measure() roxygen
Aug 30, 2026
4882727
fix: label rps as a loss and srps as a utility in .measure_spec
Aug 31, 2026
ffa1786
docs: correct the ic, mse/rmse/r2 and CRPS reference entries
Aug 31, 2026
fa95ff7
docs: correct the acc and bacc definitions in overview-measures
Aug 31, 2026
29072e6
docs: document the PWM estimator that the crps and scrps code uses
Aug 31, 2026
294f87a
docs: state that rps and srps take draws, not class probabilities
Aug 31, 2026
8a9a8e2
docs: correct the measure keywords and the weighted path in overview-…
Aug 31, 2026
6db2531
docs: fit the workflow vignette's models in the article
Aug 31, 2026
f0715be
docs: correct the pred-measure-workflow object and measure tables
Aug 31, 2026
7ffedf6
docs: state the Pareto-k threshold as sample-size dependent
Aug 31, 2026
4dd743c
docs: drop the devtools and dplyr dependencies from the articles
Aug 31, 2026
0a3ecbb
tests: shrink the pred_measure fixtures to fit the CRAN limit
Aug 31, 2026
919b29b
tests: fix the normalized-log-weights test reading a missing field
Aug 31, 2026
b5952b7
tests: drop two fixture fields that nothing reads
Aug 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vignettes/loo2-non-factorized_cache/*
.github/*
.vscode/*
^\.github$
^vignettes/online-only$
^vignettes/articles-online-only$

^CRAN-SUBMISSION$
^release-prep\.R$
Expand All @@ -27,3 +27,11 @@ vignettes/loo2-non-factorized_cache/*
^touchstone$
^.git-blame-ignore-revs
^notes-release.md
^notes$
^\.agents$
^agent$
^\.claude$
^\.refactor-review$
^internal-notes$
^scratch-files$
^skills-lock\.json$
3 changes: 2 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
local::.
any::bayesplot
any::BH
any::brms
paul-buerkner/brms
any::ggplot2
any::rmarkdown
any::Rcpp
Expand All @@ -52,6 +52,7 @@ jobs:
any::StanHeaders
any::knitr
any::withr
any::lme4
stan-dev/pkgdown-config

- name: Build site
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ vignettes/loo2-non-factorizable_cache/*
vignettes/*.html
vignettes/*.pdf
inst/doc
*.html

revdep/*
tests/testthat/Rplots.pdf

cran-comments.md
CRAN-RELEASE
release-prep.R

# personal maintainer scratch (not shared)
internal-notes/
CRAN-SUBMISSION
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Depends:
R (>= 3.5)
Imports:
checkmate,
cli (>= 3.4.0),
matrixStats (>= 0.52),
parallel,
posterior (>= 1.7.0),
Expand All @@ -46,6 +47,7 @@ Suggests:
ggplot2,
graphics,
knitr,
lme4,
rmarkdown,
rstan,
rstanarm (>= 2.19.0),
Expand All @@ -62,3 +64,4 @@ LazyData: TRUE
Roxygen: list(markdown = TRUE)
SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
23 changes: 23 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ S3method(crps,numeric)
S3method(dim,importance_sampling)
S3method(dim,kfold)
S3method(dim,loo)
S3method(dim,pred_measure)
S3method(dim,psis_loo)
S3method(dim,waic)
S3method(elpd,array)
Expand Down Expand Up @@ -58,7 +59,10 @@ S3method(print,importance_sampling)
S3method(print,importance_sampling_loo)
S3method(print,kfold)
S3method(print,loo)
S3method(print,loo_pred_measure)
S3method(print,measure)
S3method(print,pareto_k_table)
S3method(print,pred_measure)
S3method(print,pseudobma_bb_weights)
S3method(print,pseudobma_weights)
S3method(print,psis)
Expand Down Expand Up @@ -108,6 +112,7 @@ export(example_loglik_matrix)
export(extract_log_lik)
export(find_model_names)
export(gpdfit)
export(insample_pred_measure)
export(is.kfold)
export(is.loo)
export(is.psis)
Expand All @@ -116,6 +121,7 @@ export(is.sis)
export(is.tis)
export(is.waic)
export(kfold)
export(kfold_pred_measure)
export(kfold_split_grouped)
export(kfold_split_random)
export(kfold_split_stratified)
Expand All @@ -134,27 +140,44 @@ export(loo_model_weights)
export(loo_model_weights.default)
export(loo_moment_match)
export(loo_moment_match.default)
export(loo_pred_measure)
export(loo_predictive_metric)
export(loo_scrps)
export(loo_subsample)
export(loo_subsample.function)
export(mcse_loo)
export(measure_acc)
export(measure_bacc)
export(measure_brier)
export(measure_elpd)
export(measure_ic)
export(measure_mae)
export(measure_mlpd)
export(measure_mse)
export(measure_r2)
export(measure_rmse)
export(measure_rps)
export(measure_srps)
export(nlist)
export(obs_idx)
export(pareto_k_ids)
export(pareto_k_influence_values)
export(pareto_k_table)
export(pareto_k_values)
export(pointwise)
export(pred_measure)
export(print_dims)
export(pseudobma_weights)
export(psis)
export(psis_n_eff_values)
export(psislw)
export(ptw_log_pred_density)
export(relative_eff)
export(scrps)
export(sis)
export(stacking_weights)
export(supported_measures_list)
export(test_pred_measure)
export(tis)
export(waic)
export(waic.array)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# loo (development version)

* `elpd()`, `crps()`, `scrps()`, `loo_crps()`, `loo_scrps()`, and
`loo_predictive_metric()` are deprecated in favour of the `measure_*()`
functions and the `*_pred_measure()` workflow. See `vignette("migration-guide")`
for a full mapping table.
* New predictive performance API: `insample_pred_measure()`, `loo_pred_measure()`,
`kfold_pred_measure()`, `test_pred_measure()`, and `pred_measure()` with
built-in measures via `measure_*()` and [supported_measures_list()].
* Update user messages in `print()` by @ishaan-arora-1, @florence-bockting in
#328.

Expand Down
3 changes: 2 additions & 1 deletion R/compare.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' Model comparison (deprecated, old version)
#'
#' **This function is deprecated**. Please use the new [loo_compare()] function
#' instead.
#' instead. See `vignette("migration-guide", package = "loo")` for details.
#' `compare()` and `R/compare.R` are scheduled for removal in a future release.
#'
#' @export
#' @param ... At least two objects returned by [loo()] (or [waic()]).
Expand Down
24 changes: 21 additions & 3 deletions R/crps.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#' Continuously ranked probability score
#' Continuously ranked probability score (deprecated)
#'
#' As of loo 3.0.0, `crps()`, `scrps()`, `loo_crps()`, and `loo_scrps()` are
#' **deprecated**. Please use [measure_rps()] and [measure_srps()] instead,
#' or [loo_pred_measure()] for leave-one-out predictive performance.
#' See `vignette("migration-guide", package = "loo")` for a full mapping table.
#'
#' @details
#' The new functions use a single matrix of posterior predictive draws
#' (`ypred`) and a PWM estimator. The deprecated functions require two
#' independent draw matrices (`x` and `x2`) and use a permutation-based
#' estimator. See [measure_rps()] for migration details.
#'
#' The `crps()` and `scrps()` functions and their `loo_*()` counterparts can be
#' used to compute the continuously ranked probability score (CRPS) and scaled
Expand Down Expand Up @@ -34,16 +45,19 @@
#' The former reports estimator and standard error and latter the pointwise
#' values. Following Bolin & Wallin (2023), a larger value is better.
#'
#' @seealso [measure_rps()], [measure_srps()], [loo_pred_measure()]
#'
#' @examples
#' \dontrun{
#' # An example using rstanarm
#' # Deprecated:
#' library(rstanarm)
#' data("kidiq")
#' fit <- stan_glm(kid_score ~ mom_hs + mom_iq, data = kidiq)
#' ypred1 <- posterior_predict(fit)
#' ypred2 <- posterior_predict(fit)
#' crps(ypred1, ypred2, y = fit$y)
#' loo_crps(ypred1, ypred2, y = fit$y, log_lik = log_lik(fit))
#' # ->
#' measure_rps(y = fit$y, ypred = ypred1)
#' }
#'
#' @references
Expand Down Expand Up @@ -80,6 +94,7 @@ loo_scrps <- function(x, ...) {
#' @rdname crps
#' @export
crps.matrix <- function(x, x2, y, ..., permutations = 1) {
.Deprecated("measure_rps")
validate_crps_input(x, x2, y)
repeats <- replicate(permutations, EXX_compute(x, x2), simplify = F)
EXX <- Reduce(`+`, repeats) / permutations
Expand Down Expand Up @@ -114,6 +129,7 @@ loo_crps.matrix <-
permutations = 1,
r_eff = 1,
cores = getOption("mc.cores", 1)) {
.Deprecated("loo_pred_measure")
validate_crps_input(x, x2, y, log_lik)
repeats <- replicate(permutations,
EXX_loo_compute(x, x2, log_lik, r_eff = r_eff, ...),
Expand All @@ -128,6 +144,7 @@ loo_crps.matrix <-
#' @rdname crps
#' @export
scrps.matrix <- function(x, x2, y, ..., permutations = 1) {
.Deprecated("measure_srps")
validate_crps_input(x, x2, y)
repeats <- replicate(permutations, EXX_compute(x, x2), simplify = F)
EXX <- Reduce(`+`, repeats) / permutations
Expand Down Expand Up @@ -156,6 +173,7 @@ loo_scrps.matrix <-
permutations = 1,
r_eff = 1,
cores = getOption("mc.cores", 1)) {
.Deprecated("loo_pred_measure")
validate_crps_input(x, x2, y, log_lik)
repeats <- replicate(permutations,
EXX_loo_compute(x, x2, log_lik, r_eff = r_eff, ...),
Expand Down
42 changes: 30 additions & 12 deletions R/elpd.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
#' Generic (expected) log-predictive density
#' Generic (expected) log-predictive density (deprecated)
#'
#' As of loo 3.0.0, `elpd()` is **deprecated**. Please use [measure_elpd()]
#' instead. For full predictive performance workflows, see
#' [insample_pred_measure()] and [loo_pred_measure()].
#' See `vignette("migration-guide", package = "loo")` for a full mapping table.
#'
#' @details
#' The return type differs: `elpd()` returns class `"elpd_generic"` with
#' `elpd` and `ic` in `pointwise`; `measure_elpd()` returns class `"measure"`.
#'
#' The `elpd()` methods for arrays and matrices can compute the expected log
#' pointwise predictive density for a new dataset or the log pointwise
#' predictive density of the observed data (an overestimate of the elpd).
#' The `elpd()` function is an S3 generic and methods are provided for
#' 3-D pointwise log-likelihood arrays and matrices.
#'
#' @export
#' @param x A log-likelihood array or matrix. The **Methods (by class)**
#' section, below, has detailed descriptions of how to specify the inputs for
#' each method.
#' @param ... Currently ignored.
#'
#' @details The `elpd()` function is an S3 generic and methods are provided for
#' 3-D pointwise log-likelihood arrays and matrices.
#'
#' @seealso The vignette *Holdout validation and K-fold cross-validation of Stan
#' programs with the loo package* for demonstrations of using the `elpd()`
#' methods.
#' @seealso [measure_elpd()], [insample_pred_measure()], [loo_pred_measure()],
#' and the vignette *Holdout validation and K-fold cross-validation of Stan
#' programs with the loo package*.
#'
#' @examples
#' # Calculate the lpd of the observed data
#' \dontrun{
#' # Deprecated:
#' LLarr <- example_loglik_array()
#' elpd(LLarr)
#' # ->
#' measure_elpd(LLarr)
#' }
#'
elpd <- function(x, ...) {
UseMethod("elpd")
Expand All @@ -31,22 +43,28 @@ elpd <- function(x, ...) {
#' @template array
#'
elpd.array <- function(x, ...) {
.Deprecated("measure_elpd")
ll <- llarray_to_matrix(x)
elpd.matrix(ll)
.elpd_matrix_impl(ll)
}

#' @export
#' @templateVar fn elpd
#' @template matrix
#'
elpd.matrix <- function(x, ...) {
pointwise <- pointwise_elpd_calcs(x)
elpd_object(pointwise, dim(x))
.Deprecated("measure_elpd")
.elpd_matrix_impl(x)
}



# internal ----------------------------------------------------------------
# used to avoid duplicated deprecation warning messages
.elpd_matrix_impl <- function(x) {
pointwise <- pointwise_elpd_calcs(x)
elpd_object(pointwise, dim(x))
}

pointwise_elpd_calcs <- function(ll){
elpd <- colLogSumExps(ll) - log(nrow(ll))
ic <- -2 * elpd
Expand Down
15 changes: 14 additions & 1 deletion R/loo_predictive_metric.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#' Estimate leave-one-out predictive performance..
#' Estimate leave-one-out predictive performance (deprecated)
#'
#' As of loo 3.0.0, `loo_predictive_metric()` is **deprecated**. Please use
#' [loo_pred_measure()] instead, or the standalone [measure_mae()],
#' [measure_rmse()], [measure_mse()], [measure_acc()], and [measure_bacc()]
#' functions with PSIS log-weights.
#' See `vignette("migration-guide", package = "loo")` for a full mapping table.
#'
#' @details
#' The replacement API uses `mupred` (posterior expected values) rather than
#' pre-computed LOO expectations passed as `x`. Metric names also differ:
#' `"balanced_acc"` maps to `"bacc"` in [supported_measures_list].
#'
#' The `loo_predictive_metric()` function computes estimates of leave-one-out
#' predictive metrics given a set of predictions and observations. Currently
Expand Down Expand Up @@ -49,6 +60,7 @@
#' Standard error of the estimate.
#' }
#' }
#' @seealso [loo_pred_measure()], [measure_mae()], [supported_measures_list]
#' @export
#'
#' @examples
Expand Down Expand Up @@ -93,6 +105,7 @@ loo_predictive_metric.matrix <-
metric = c("mae", "rmse", "mse", "acc", "balanced_acc"),
r_eff = 1,
cores = getOption("mc.cores", 1)) {
.Deprecated("loo_pred_measure")
stopifnot(
is.numeric(x),
is.numeric(y),
Expand Down
Loading
Loading