Skip to content

Adding pred_measure feature - #363

Draft
florence-bockting wants to merge 185 commits into
loo-v3.0.0from
pred_measure
Draft

florence-bockting wants to merge 185 commits into
loo-v3.0.0from
pred_measure

Conversation

@florence-bockting

@florence-bockting florence-bockting commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #281
Fixes #223, #213, #201, #135, #220

Summary

This PR adds a predictive performance API. It computes density scores, scoring rules, and point-prediction metrics under four evaluation sources: in-sample, PSIS-LOO, k-fold, and holdout (test data).

elpd(), crps(), scrps(), loo_crps(), loo_scrps(), loo_predictive_metric(), and loo_compare() are deprecated. They still work with their current APIs.

The comment below lists all new features and functions. It marks the parts that come from #380.

How to navigate this PR

Deprecations (implementations retained)

Deprecated Replacement
elpd() measure_elpd() / *_pred_measure()
crps(), scrps() (x, x2) measure_rps(), measure_srps() (ypred)
loo_crps(), loo_scrps() loo_pred_measure(..., measure = "rps" | "srps")
loo_predictive_metric() loo_pred_measure()
loo_compare() (#380) model_compare()

Each deprecated function warns once per session.

Dependencies

Vignettes, test-data generation, and pkgdown CI install brms from GitHub master as k-fold support for categorical models (brms#1890) is not yet on CRAN. Remove the pin after the next brms CRAN release.

Known limitations

  • group_ids grouping is not implemented.
  • The formula derivations article is not finished.
  • The brms GitHub pin remains.

Acknowledgements

This work builds on a prototype by @VisruthSK (VisruthSK/loo-sandbox) under guidance from @jgabry.

@github-actions

github-actions Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

This is how benchmark results would change (along with a 95% confidence interval in relative change) if de81c46 is merged into loo-v3.0.0:

  • ✔️loo_function: 2.06s -> 2.07s [-0.35%, +1.29%]
  • ✔️loo_matrix: 1.93s -> 1.93s [-0.64%, +0.48%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

@florence-bockting

florence-bockting commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor Author

There is an open issue requesting a subset() method for psis objects #343 and an (unrelated) open PR #110. Might be worth considering whether we can address this as well in this refactoring PR. If yes, we should

Moved this to PR #379

@VisruthSK VisruthSK added this to the v3.0.0 milestone Jun 9, 2026
@florence-bockting florence-bockting mentioned this pull request Jul 1, 2026
6 tasks
@florence-bockting florence-bockting changed the title LOO refactoring and adding pred_measure feature Adding pred_measure feature Jul 1, 2026
@florence-bockting
florence-bockting changed the base branch from master to loo-v3.0.0 July 1, 2026 09:33
Florence Bockting and others added 26 commits September 30, 2026 18:28
Introduce `model_compare()` for model comparison with support of new predictive measures
@florence-bockting

Copy link
Copy Markdown
Contributor Author

Overview of changes

Items marked (#380) come from the merged integrate-loo_compare PR. #380 has the full details for those items in its overview comment.

User-facing functions

Function Status PR
insample_pred_measure(), loo_pred_measure(), kfold_pred_measure(), test_pred_measure() new #363
pred_measure() new #363
measure_elpd(), measure_mlpd(), measure_ic() new #363
measure_acc(), measure_bacc(), measure_brier() new #363
measure_mae(), measure_mse(), measure_rmse(), measure_r2() new #363
measure_rps(), measure_srps() new #363
ptw_log_pred_density() new #363
supported_measures_list() new #363
print.pred_measure(), print.loo_pred_measure(), print.measure(), dim.pred_measure() new S3 methods #363
elpd(), crps(), scrps(), loo_crps(), loo_scrps(), loo_predictive_metric() deprecated #363
model_compare() (methods default, psis_loo_ss_list) new #380
custom_measure() new #380
print.compare.loo() new arguments measures, simplify #380
loo_compare() deprecated #380
print.compare.loo_ss() removed #380

Internal functions

New in #363

  • R/pred_measure.R (new file): S3 entry points only
  • R/pred_measure-builtin.R (new file): .create_measure_structure()
  • R/pred_measure-compute.R (new file): do_pred_measure(), .get_psis_object(),
    .measure_estimate_se(), .elpd_pointwise(), .compute_measure(),
    .effective_param(), .compute_effective_param(), .measure_result_name(),
    .merge_matrix(), .build_pred_measure(), .add_attributes()
  • R/pred_measure-helpers.R (new file): .normalize_measure(), .measure_entry_custom(),
    .check_measure_entry_names(), .prepare_measures(), .any_needs_elpd(),
    .measure_n_obs(), .validate_measure_result(), .validate_numeric_matrix(),
    .validate_numeric_vector(), .normalize_and_validate_log_weights(),
    .inform_ignored_inputs(), .validate_probs(), .lppd_from_inputs(),
    .acc_pointwise(), .point_error_from_inputs(), .copy_attrs(),
    .normalize_log_weights(), .exx_pwm(), .validate_control(), subset_measures()
  • R/print.R: .fr(), .pred_measure_source_label()
  • R/helpers.R: .deprecate_once()
  • R/elpd.R: .elpd_matrix_impl()

From #380

  • R/model_compare.R, R/model_compare-pred_measure.R, R/model_compare-print.R,
    R/model_compare.psis_loo_ss_list.R: all functions (see the Introduce model_compare() for model comparison with support of new predictive measures #380 comment)
  • R/pred_measure-builtin.R: .se_diff_rmse(), .se_diff_r2(), .se_diff_bacc(),
    .se_r2_delta(), .measure_info()
  • R/pred_measure-compute.R: .detect_posthoc(), .warn_posthoc()
  • R/print.R: .measure_digits(), .se_digits(), .resolve_digits(), .format_estimates()

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants