From c975745b9cd0cdf61684b400291c8dc119628e7d Mon Sep 17 00:00:00 2001 From: ishaan-arora-1 Date: Sun, 22 Feb 2026 03:01:37 +0530 Subject: [PATCH 1/7] Clarify print output: specify posterior draws and log-likelihood terms The previous print output "Computed from 4000 by 262 log-likelihood matrix" was ambiguous about which dimension was draws and which was observations. This made it easy for users to miss cases where they accidentally misspecified the log-likelihood (e.g. placing all observations in one multivariate normal). The new output explicitly labels both dimensions: "Computed from 4000 posterior draws and 262 log-likelihood terms." Updated all print_dims methods (psis_loo, importance_sampling, importance_sampling_loo, waic, psis_loo_ss, elpd_generic), along with corresponding tests, snapshots, and vignette output. Fixes #198 --- NEWS.md | 2 ++ R/elpd.R | 6 ++-- R/print.R | 29 ++++++++++---------- tests/testthat/_snaps/loo_moment_matching.md | 2 +- tests/testthat/_snaps/psis.md | 4 +-- tests/testthat/_snaps/tisis.md | 2 +- tests/testthat/test_loo_subsampling_cases.R | 22 +++++++-------- tests/testthat/test_print_plot.R | 8 +++--- vignettes/loo2-large-data.Rmd | 22 +++++++-------- vignettes/loo2-with-rstan.Rmd | 4 +-- 10 files changed, 51 insertions(+), 50 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6f182376..abb6e481 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # loo (development version) +* Clarify print output to say "posterior draws" and "log-likelihood terms" instead of the ambiguous "X by Y matrix" format (#198) + # loo 2.9.0 * Avoid under and overflows in stacking by @avehtari in #273 diff --git a/R/elpd.R b/R/elpd.R index 20724e71..b6736fb4 100644 --- a/R/elpd.R +++ b/R/elpd.R @@ -67,9 +67,9 @@ elpd_object <- function(pointwise, dims) { } #' @export print_dims.elpd_generic <- function(x, ...) { + dims <- dim(x) cat( - "Computed from", - paste(dim(x), collapse = " by "), - "log-likelihood matrix using the generic elpd function\n" + "Computed from", dims[1], "posterior draws and", + dims[2], "log-likelihood terms using the generic elpd function.\n" ) } diff --git a/R/print.R b/R/print.R index f05834d6..096bb4a5 100644 --- a/R/print.R +++ b/R/print.R @@ -119,40 +119,40 @@ print_dims <- function(x, ...) UseMethod("print_dims") #' @rdname print_dims #' @export print_dims.importance_sampling <- function(x, ...) { + dims <- dim(x) cat( - "Computed from", - paste(dim(x), collapse = " by "), - "log-weights matrix.\n" + "Computed from", dims[1], "posterior draws and", + dims[2], "log-weight terms.\n" ) } #' @rdname print_dims #' @export print_dims.psis_loo <- function(x, ...) { + dims <- dim(x) cat( - "Computed from", - paste(dim(x), collapse = " by "), - "log-likelihood matrix.\n" + "Computed from", dims[1], "posterior draws and", + dims[2], "log-likelihood terms.\n" ) } #' @rdname print_dims #' @export print_dims.importance_sampling_loo <- function(x, ...) { + dims <- dim(x) cat( - "Computed from", - paste(dim(x), collapse = " by "), - "log-likelihood matrix using", class(x)[1], ".\n" + "Computed from", dims[1], "posterior draws and", + dims[2], "log-likelihood terms using", class(x)[1], ".\n" ) } #' @rdname print_dims #' @export print_dims.waic <- function(x, ...) { + dims <- dim(x) cat( - "Computed from", - paste(dim(x), collapse = " by "), - "log-likelihood matrix.\n" + "Computed from", dims[1], "posterior draws and", + dims[2], "log-likelihood terms.\n" ) } @@ -169,9 +169,8 @@ print_dims.kfold <- function(x, ...) { #' @export print_dims.psis_loo_ss <- function(x, ...) { cat( - "Computed from", - paste(c(dim(x)[1], nobs(x)) , collapse = " by "), - "subsampled log-likelihood\nvalues from", + "Computed from", dim(x)[1], "posterior draws and", + nobs(x), "subsampled log-likelihood\nterms from", length(x$loo_subsampling$elpd_loo_approx), "total observations.\n" ) diff --git a/tests/testthat/_snaps/loo_moment_matching.md b/tests/testthat/_snaps/loo_moment_matching.md index e34c5d48..a227a3aa 100644 --- a/tests/testthat/_snaps/loo_moment_matching.md +++ b/tests/testthat/_snaps/loo_moment_matching.md @@ -13,7 +13,7 @@ Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details. Output - Computed from 4000 by 30 log-likelihood matrix. + Computed from 4000 posterior draws and 30 log-likelihood terms. Estimate SE elpd_loo -74.0 18.8 diff --git a/tests/testthat/_snaps/psis.md b/tests/testthat/_snaps/psis.md index 9f2deaf3..d902046d 100644 --- a/tests/testthat/_snaps/psis.md +++ b/tests/testthat/_snaps/psis.md @@ -4787,7 +4787,7 @@ Message Replacing NAs in `r_eff` with 1s Output - Computed from 1000 by 32 log-weights matrix. + Computed from 1000 posterior draws and 32 log-weight terms. MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.0]). All Pareto k estimates are good (k < 0.67). @@ -4803,7 +4803,7 @@ Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details. Output - Computed from 10 by 32 log-weights matrix. + Computed from 10 posterior draws and 32 log-weight terms. MCSE and ESS estimates assume independent draws (r_eff=1). Pareto k diagnostic values: Count Pct. Min. ESS diff --git a/tests/testthat/_snaps/tisis.md b/tests/testthat/_snaps/tisis.md index 57cf7e30..1f20897f 100644 --- a/tests/testthat/_snaps/tisis.md +++ b/tests/testthat/_snaps/tisis.md @@ -5,7 +5,7 @@ Message Replacing NAs in `r_eff` with 1s Output - Computed from 1000 by 32 log-weights matrix. + Computed from 1000 posterior draws and 32 log-weight terms. MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.0]). All Pareto k estimates are good (k < 0.67). diff --git a/tests/testthat/test_loo_subsampling_cases.R b/tests/testthat/test_loo_subsampling_cases.R index 1f53192b..03558949 100644 --- a/tests/testthat/test_loo_subsampling_cases.R +++ b/tests/testthat/test_loo_subsampling_cases.R @@ -344,9 +344,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_1), - "Computed from 4000 by 100 subsampled log-likelihood" + "Computed from 4000 posterior draws and 100 subsampled log-likelihood" ) - expect_output(print(looss_1), "values from 3020 total observations.") + expect_output(print(looss_1), "terms from 3020 total observations.") expect_output( print(looss_1), "MCSE and ESS estimates assume independent draws" @@ -366,9 +366,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_1b), - "Computed from 4000 by 200 subsampled log-likelihood" + "Computed from 4000 posterior draws and 200 subsampled log-likelihood" ) - expect_output(print(looss_1b), "values from 3020 total observations.") + expect_output(print(looss_1b), "terms from 3020 total observations.") expect_output( print(looss_1b), "MCSE and ESS estimates assume independent draws" @@ -391,9 +391,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_2), - "Computed from 4000 by 100 subsampled log-likelihood" + "Computed from 4000 posterior draws and 100 subsampled log-likelihood" ) - expect_output(print(looss_2), "values from 3020 total observations.") + expect_output(print(looss_2), "terms from 3020 total observations.") expect_output( print(looss_2), "MCSE and ESS estimates assume independent draws" @@ -415,7 +415,7 @@ test_that("Test the vignette", { ) expect_output( print(aploo_1), - "Computed from 2000 by 3020 log-likelihood matrix" + "Computed from 2000 posterior draws and 3020 log-likelihood terms" ) expect_output( print(aploo_1), @@ -441,13 +441,13 @@ test_that("Test the vignette", { ) expect_output( print(looapss_1), - "Computed from 2000 by 100 subsampled log-likelihood" + "Computed from 2000 posterior draws and 100 subsampled log-likelihood" ) expect_output( print(looapss_1), "MCSE and ESS estimates assume independent draws" ) - expect_output(print(looapss_1), "values from 3020 total observations.") + expect_output(print(looapss_1), "terms from 3020 total observations.") expect_output(print(looapss_1), "elpd_loo -1968.2 15.6 0.4") expect_output(print(looapss_1), "p_loo 2.9 0.1 0.5") expect_output(print(looapss_1), "All Pareto k estimates are good") @@ -474,13 +474,13 @@ test_that("Test the vignette", { ) expect_output( print(looss_2), - "Computed from 4000 by 100 subsampled log-likelihood" + "Computed from 4000 posterior draws and 100 subsampled log-likelihood" ) expect_output( print(looss_2), "MCSE and ESS estimates assume independent draws" ) - expect_output(print(looss_2), "values from 3020 total observations.") + expect_output(print(looss_2), "terms from 3020 total observations.") expect_output(print(looss_2), "elpd_loo -1952.0 16.2 0.2") expect_output(print(looss_2), "p_loo 2.6 0.1 0.3") diff --git a/tests/testthat/test_print_plot.R b/tests/testthat/test_print_plot.R index f69ed6f0..ea0ec03b 100644 --- a/tests/testthat/test_print_plot.R +++ b/tests/testthat/test_print_plot.R @@ -41,16 +41,16 @@ test_that("plot methods throw appropriate errors/warnings", { lldim_msg <- paste0( "Computed from ", prod(dim(LLarr)[1:2]), - " by ", + " posterior draws and ", dim(LLarr)[3], - " log-likelihood matrix" + " log-likelihood terms" ) lwdim_msg <- paste0( "Computed from ", prod(dim(LLarr)[1:2]), - " by ", + " posterior draws and ", dim(LLarr)[3], - " log-weights matrix" + " log-weight terms" ) test_that("print.waic output is ok", { diff --git a/vignettes/loo2-large-data.Rmd b/vignettes/loo2-large-data.Rmd index 0dadaf7e..ff801817 100644 --- a/vignettes/loo2-large-data.Rmd +++ b/vignettes/loo2-large-data.Rmd @@ -188,8 +188,8 @@ print(loo_ss_1) ``` ``` -Computed from 4000 by 100 subsampled log-likelihood -values from 3020 total observations. +Computed from 4000 posterior draws and 100 subsampled log-likelihood +terms from 3020 total observations. Estimate SE subsampling SE elpd_loo -1968.5 15.6 0.3 @@ -240,8 +240,8 @@ print(loo_ss_1b) ``` ``` -Computed from 4000 by 200 subsampled log-likelihood -values from 3020 total observations. +Computed from 4000 posterior draws and 200 subsampled log-likelihood +terms from 3020 total observations. Estimate SE subsampling SE elpd_loo -1968.3 15.6 0.2 @@ -285,8 +285,8 @@ print(loo_ss_1c) ``` -Computed from 4000 by 100 subsampled log-likelihood -values from 3020 total observations. +Computed from 4000 posterior draws and 100 subsampled log-likelihood +terms from 3020 total observations. Estimate SE subsampling SE elpd_loo -1968.9 15.4 0.5 @@ -339,7 +339,7 @@ print(loo_ap_1) The function creates a class, `psis_loo_ap` that inherits from `psis_loo, loo`. ``` -Computed from 2000 by 3020 log-likelihood matrix +Computed from 2000 posterior draws and 3020 log-likelihood terms Estimate SE elpd_loo -1968.4 15.6 @@ -375,8 +375,8 @@ print(loo_ap_ss_1) ``` ``` -Computed from 2000 by 100 subsampled log-likelihood -values from 3020 total observations. +Computed from 2000 posterior draws and 100 subsampled log-likelihood +terms from 3020 total observations. Estimate SE subsampling SE elpd_loo -1968.2 15.6 0.4 @@ -455,8 +455,8 @@ print(loo_ss_2) ``` ``` -Computed from 4000 by 100 subsampled log-likelihood -values from 3020 total observations. +Computed from 4000 posterior draws and 100 subsampled log-likelihood +terms from 3020 total observations. Estimate SE subsampling SE elpd_loo -1952.0 16.2 0.2 diff --git a/vignettes/loo2-with-rstan.Rmd b/vignettes/loo2-with-rstan.Rmd index 23ddf364..9c1fcd05 100644 --- a/vignettes/loo2-with-rstan.Rmd +++ b/vignettes/loo2-with-rstan.Rmd @@ -140,7 +140,7 @@ print(loo_1) ``` ``` -Computed from 4000 by 3020 log-likelihood matrix +Computed from 4000 posterior draws and 3020 log-likelihood terms Estimate SE elpd_loo -1968.5 15.6 @@ -182,7 +182,7 @@ print(loo_2) ``` ``` -Computed from 4000 by 3020 log-likelihood matrix +Computed from 4000 posterior draws and 3020 log-likelihood terms Estimate SE elpd_loo -1952.3 16.2 From 74dfab9334ebe2ffd3ca0d8ad563ee6673e30a12 Mon Sep 17 00:00:00 2001 From: ishaan-arora-1 Date: Tue, 24 Feb 2026 20:38:05 +0530 Subject: [PATCH 2/7] Update tests to match new print output wording The print_dims.psis_loo_ss method now says "log-likelihood terms" instead of "log-likelihood values", so update the test expectations to match. --- tests/testthat/test_loo_subsampling_cases.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test_loo_subsampling_cases.R b/tests/testthat/test_loo_subsampling_cases.R index 03558949..61fb5691 100644 --- a/tests/testthat/test_loo_subsampling_cases.R +++ b/tests/testthat/test_loo_subsampling_cases.R @@ -171,17 +171,17 @@ test_that("Test loo_subsampling and loo_approx with radon data", { )) expect_failure(expect_output( print(full_loo), - "subsampled log-likelihood\nvalues" + "subsampled log-likelihood\nterms" )) expect_failure(expect_output( print(loo_ss), "Posterior approximation correction used\\." )) - expect_output(print(loo_ss), "subsampled log-likelihood\nvalues") + expect_output(print(loo_ss), "subsampled log-likelihood\nterms") expect_output(print(loo_ap_ss), "Posterior approximation correction used\\.") - expect_output(print(loo_ap_ss), "subsampled log-likelihood\nvalues") + expect_output(print(loo_ap_ss), "subsampled log-likelihood\nterms") expect_output( print(loo_ap_ss_full), @@ -189,7 +189,7 @@ test_that("Test loo_subsampling and loo_approx with radon data", { ) expect_failure(expect_output( print(loo_ap_ss_full), - "subsampled log-likelihood\nvalues" + "subsampled log-likelihood\nterms" )) # Test conversion of objects From 09d56b2564593bee414cd8db80b5860c5a2f6277 Mon Sep 17 00:00:00 2001 From: ishaan-arora-1 Date: Mon, 9 Mar 2026 02:56:08 +0530 Subject: [PATCH 3/7] Update print message for subsampling loo per feedback --- R/print.R | 10 +++++--- tests/testthat/test_loo_subsampling_cases.R | 28 ++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/R/print.R b/R/print.R index 096bb4a5..94276f0f 100644 --- a/R/print.R +++ b/R/print.R @@ -169,10 +169,12 @@ print_dims.kfold <- function(x, ...) { #' @export print_dims.psis_loo_ss <- function(x, ...) { cat( - "Computed from", dim(x)[1], "posterior draws and", - nobs(x), "subsampled log-likelihood\nterms from", - length(x$loo_subsampling$elpd_loo_approx), - "total observations.\n" + "Subsampling loo uses 1) faster but more biased computation with", + dim(x)[1], "posterior draws and", + length(x$loo_subsampling$elpd_loo_approx), "log-likelihood terms,", + "and 2) slower but more accurate computation with", + dim(x)[1], "posterior draws and", + nobs(x), "subsampled log-likelihood terms.\n" ) } diff --git a/tests/testthat/test_loo_subsampling_cases.R b/tests/testthat/test_loo_subsampling_cases.R index 61fb5691..53da6679 100644 --- a/tests/testthat/test_loo_subsampling_cases.R +++ b/tests/testthat/test_loo_subsampling_cases.R @@ -171,17 +171,17 @@ test_that("Test loo_subsampling and loo_approx with radon data", { )) expect_failure(expect_output( print(full_loo), - "subsampled log-likelihood\nterms" + "subsampled log-likelihood terms" )) expect_failure(expect_output( print(loo_ss), "Posterior approximation correction used\\." )) - expect_output(print(loo_ss), "subsampled log-likelihood\nterms") + expect_output(print(loo_ss), "subsampled log-likelihood terms") expect_output(print(loo_ap_ss), "Posterior approximation correction used\\.") - expect_output(print(loo_ap_ss), "subsampled log-likelihood\nterms") + expect_output(print(loo_ap_ss), "subsampled log-likelihood terms") expect_output( print(loo_ap_ss_full), @@ -189,7 +189,7 @@ test_that("Test loo_subsampling and loo_approx with radon data", { ) expect_failure(expect_output( print(loo_ap_ss_full), - "subsampled log-likelihood\nterms" + "subsampled log-likelihood terms" )) # Test conversion of objects @@ -344,9 +344,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_1), - "Computed from 4000 posterior draws and 100 subsampled log-likelihood" + "faster but more biased computation with 4000 posterior draws and 3020 log-likelihood terms" ) - expect_output(print(looss_1), "terms from 3020 total observations.") + expect_output(print(looss_1), "slower but more accurate computation with 4000 posterior draws and 100 subsampled log-likelihood terms") expect_output( print(looss_1), "MCSE and ESS estimates assume independent draws" @@ -366,9 +366,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_1b), - "Computed from 4000 posterior draws and 200 subsampled log-likelihood" + "faster but more biased computation with 4000 posterior draws and 3020 log-likelihood terms" ) - expect_output(print(looss_1b), "terms from 3020 total observations.") + expect_output(print(looss_1b), "slower but more accurate computation with 4000 posterior draws and 200 subsampled log-likelihood terms") expect_output( print(looss_1b), "MCSE and ESS estimates assume independent draws" @@ -391,9 +391,9 @@ test_that("Test the vignette", { ) expect_output( print(looss_2), - "Computed from 4000 posterior draws and 100 subsampled log-likelihood" + "faster but more biased computation with 4000 posterior draws and 3020 log-likelihood terms" ) - expect_output(print(looss_2), "terms from 3020 total observations.") + expect_output(print(looss_2), "slower but more accurate computation with 4000 posterior draws and 100 subsampled log-likelihood terms") expect_output( print(looss_2), "MCSE and ESS estimates assume independent draws" @@ -441,13 +441,13 @@ test_that("Test the vignette", { ) expect_output( print(looapss_1), - "Computed from 2000 posterior draws and 100 subsampled log-likelihood" + "faster but more biased computation with 2000 posterior draws and 3020 log-likelihood terms" ) expect_output( print(looapss_1), "MCSE and ESS estimates assume independent draws" ) - expect_output(print(looapss_1), "terms from 3020 total observations.") + expect_output(print(looapss_1), "slower but more accurate computation with 2000 posterior draws and 100 subsampled log-likelihood terms") expect_output(print(looapss_1), "elpd_loo -1968.2 15.6 0.4") expect_output(print(looapss_1), "p_loo 2.9 0.1 0.5") expect_output(print(looapss_1), "All Pareto k estimates are good") @@ -474,13 +474,13 @@ test_that("Test the vignette", { ) expect_output( print(looss_2), - "Computed from 4000 posterior draws and 100 subsampled log-likelihood" + "faster but more biased computation with 4000 posterior draws and 3020 log-likelihood terms" ) expect_output( print(looss_2), "MCSE and ESS estimates assume independent draws" ) - expect_output(print(looss_2), "terms from 3020 total observations.") + expect_output(print(looss_2), "slower but more accurate computation with 4000 posterior draws and 100 subsampled log-likelihood terms") expect_output(print(looss_2), "elpd_loo -1952.0 16.2 0.2") expect_output(print(looss_2), "p_loo 2.6 0.1 0.3") From 0b6eb243b8fbc4bab58fff61d05e79f44ae8fca0 Mon Sep 17 00:00:00 2001 From: Florence Bockting Date: Mon, 10 Aug 2026 10:56:57 +0300 Subject: [PATCH 4/7] fix: update user info for loo_subsampling --- R/print.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/print.R b/R/print.R index 91628bfa..1f4030b8 100644 --- a/R/print.R +++ b/R/print.R @@ -191,12 +191,13 @@ print_dims.kfold <- function(x, ...) { #' @export print_dims.psis_loo_ss <- function(x, ...) { cat( - "Subsampling loo uses 1) faster but more biased computation with", - dim(x)[1], "posterior draws and", - length(x$loo_subsampling$elpd_loo_approx), "log-likelihood terms,", - "and 2) slower but more accurate computation with", - dim(x)[1], "posterior draws and", - nobs(x), "subsampled log-likelihood terms.\n" + "Subsampling loo uses 1) faster, more biased computation with ", + length(x$loo_subsampling$elpd_loo_approx), + " log-lik.\n", + "terms, and 2) slower, more accurate computation with ", + nobs(x), + " subsampled terms.\n", + sep = "" ) } From 2014866d99891a02fabb5a77a50367dbef6a8666 Mon Sep 17 00:00:00 2001 From: Florence Bockting Date: Mon, 10 Aug 2026 10:57:33 +0300 Subject: [PATCH 5/7] tests/docs: update tests and vignette wrt updated user message --- .../testthat/_snaps/loo_subsampling_cases.md | 18 +++++++-------- tests/testthat/test_loo_subsampling_cases.R | 11 ++++------ vignettes/loo2-large-data.Rmd | 22 +++++++++---------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/tests/testthat/_snaps/loo_subsampling_cases.md b/tests/testthat/_snaps/loo_subsampling_cases.md index 2dcdf0fb..677e4fa1 100644 --- a/tests/testthat/_snaps/loo_subsampling_cases.md +++ b/tests/testthat/_snaps/loo_subsampling_cases.md @@ -4,8 +4,8 @@ print(looss_1) Output - Computed from 4000 by 100 subsampled log-likelihood - values from 3020 total observations. + Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. + terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.5 15.6 0.3 @@ -24,8 +24,8 @@ print(looss_1b) Output - Computed from 4000 by 200 subsampled log-likelihood - values from 3020 total observations. + Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. + terms, and 2) slower, more accurate computation with 200 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.3 15.6 0.2 @@ -44,7 +44,7 @@ print(aploo_1) Output - Computed from 2000 by 3020 log-likelihood matrix. + Computed from 2000 posterior draws and 3020 log-likelihood terms. Estimate SE elpd_loo -1968.4 15.6 @@ -64,8 +64,8 @@ print(looapss_1) Output - Computed from 2000 by 100 subsampled log-likelihood - values from 3020 total observations. + Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. + terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.2 15.6 0.4 @@ -85,8 +85,8 @@ print(looss_2) Output - Computed from 4000 by 100 subsampled log-likelihood - values from 3020 total observations. + Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. + terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1952.0 16.2 0.2 diff --git a/tests/testthat/test_loo_subsampling_cases.R b/tests/testthat/test_loo_subsampling_cases.R index 36613c24..532d5830 100644 --- a/tests/testthat/test_loo_subsampling_cases.R +++ b/tests/testthat/test_loo_subsampling_cases.R @@ -178,10 +178,10 @@ test_that("Test loo_subsampling and loo_approx with radon data", { print(loo_ss), "Posterior approximation correction used\\." )) - expect_output(print(loo_ss), "subsampled log-likelihood terms") + expect_output(print(loo_ss), "Subsampling loo uses 1) faster,") expect_output(print(loo_ap_ss), "Posterior approximation correction used\\.") - expect_output(print(loo_ap_ss), "subsampled log-likelihood terms") + expect_output(print(loo_ap_ss), "Subsampling loo uses 1) faster,") expect_output( print(loo_ap_ss_full), @@ -369,11 +369,8 @@ test_that("Test the vignette", { loo_approximation_draws = 100 ) ) - expect_output( - print(looss_2), - "faster but more biased computation with 4000 posterior draws and 3020 log-likelihood terms" - ) - expect_output(print(looss_2), "slower but more accurate computation with 4000 posterior draws and 100 subsampled log-likelihood terms") + expect_output(print(looss_2), "Subsampling loo uses 1) faster,") + expect_output(print(looss_2), "Subsampling loo uses 1) faster,") expect_output( print(looss_2), "MCSE and ESS estimates assume independent draws" diff --git a/vignettes/loo2-large-data.Rmd b/vignettes/loo2-large-data.Rmd index ff801817..fbaa5827 100644 --- a/vignettes/loo2-large-data.Rmd +++ b/vignettes/loo2-large-data.Rmd @@ -188,8 +188,8 @@ print(loo_ss_1) ``` ``` -Computed from 4000 posterior draws and 100 subsampled log-likelihood -terms from 3020 total observations. +Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. +terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.5 15.6 0.3 @@ -235,13 +235,13 @@ loo_ss_1b <- r_eff = r_eff, draws = parameter_draws_1, data = stan_df_1 - ) + ) print(loo_ss_1b) ``` ``` -Computed from 4000 posterior draws and 200 subsampled log-likelihood -terms from 3020 total observations. +Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. +terms, and 2) slower, more accurate computation with 200 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.3 15.6 0.2 @@ -285,8 +285,8 @@ print(loo_ss_1c) ``` -Computed from 4000 posterior draws and 100 subsampled log-likelihood -terms from 3020 total observations. +Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. +terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.9 15.4 0.5 @@ -375,8 +375,8 @@ print(loo_ap_ss_1) ``` ``` -Computed from 2000 posterior draws and 100 subsampled log-likelihood -terms from 3020 total observations. +Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. +terms, and 2) slower, more accurate computation with 100 subsampled terms. Estimate SE subsampling SE elpd_loo -1968.2 15.6 0.4 @@ -455,8 +455,8 @@ print(loo_ss_2) ``` ``` -Computed from 4000 posterior draws and 100 subsampled log-likelihood -terms from 3020 total observations. +Subsampling loo uses 1) faster, more biased computation with 3020 log-lik. +terms, and 2) slower, more accurate computation with 200 subsampled terms. Estimate SE subsampling SE elpd_loo -1952.0 16.2 0.2 From ec9ff72a4640ea2f9c1c9dee861b4f70d30b7e64 Mon Sep 17 00:00:00 2001 From: Florence Bockting Date: Mon, 10 Aug 2026 11:27:26 +0300 Subject: [PATCH 6/7] tests: update snapshots for new user messages --- tests/testthat/_snaps/print_plot.md | 8 ++++---- tests/testthat/_snaps/tisis.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/_snaps/print_plot.md b/tests/testthat/_snaps/print_plot.md index e4df71da..5a7a6c34 100644 --- a/tests/testthat/_snaps/print_plot.md +++ b/tests/testthat/_snaps/print_plot.md @@ -4,7 +4,7 @@ print(waic1) Output - Computed from 1000 by 32 log-likelihood matrix. + Computed from 1000 posterior draws and 32 log-likelihood terms. Estimate SE elpd_waic -83.5 4.3 @@ -18,7 +18,7 @@ Code print(psis1) Output - Computed from 1000 by 32 log-weights matrix. + Computed from 1000 posterior draws and 32 log-weight terms. MCSE and ESS estimates assume independent draws (r_eff=1). All Pareto k estimates are good (k < 0.67). @@ -30,7 +30,7 @@ print(loo1) Output - Computed from 1000 by 32 log-likelihood matrix. + Computed from 1000 posterior draws and 32 log-likelihood terms. Estimate SE elpd_loo -83.6 4.3 @@ -49,7 +49,7 @@ print(loo1_r_eff) Output - Computed from 1000 by 32 log-likelihood matrix. + Computed from 1000 posterior draws and 32 log-likelihood terms. Estimate SE elpd_loo -83.6 4.3 diff --git a/tests/testthat/_snaps/tisis.md b/tests/testthat/_snaps/tisis.md index 84a73ec3..c39c5e81 100644 --- a/tests/testthat/_snaps/tisis.md +++ b/tests/testthat/_snaps/tisis.md @@ -17,7 +17,7 @@ print(loo_tis) Output - Computed from 1000 by 32 log-likelihood matrix using tis_loo . + Computed from 1000 posterior draws and 32 log-likelihood terms using tis_loo . Estimate SE elpd_loo -83.6 4.3 @@ -31,7 +31,7 @@ print(loo_sis) Output - Computed from 1000 by 32 log-likelihood matrix using sis_loo . + Computed from 1000 posterior draws and 32 log-likelihood terms using sis_loo . Estimate SE elpd_loo -83.6 4.3 From 05c80c11266059362569e06de4a80655509d068e Mon Sep 17 00:00:00 2001 From: Florence Bockting Date: Mon, 10 Aug 2026 12:40:50 +0300 Subject: [PATCH 7/7] chore: update NEWS.md --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index f0026850..291db72b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # loo (development version) +* Update user messages in `print()` by @ishaan-arora-1, @florence-bockting in +#328. + # loo 2.10.1 * Revert behavior of internal `psis_smooth_tail()` function that led to several