Skip to content

Comments

Clarify print output to specify posterior draws and log-likelihood terms#328

Open
ishaan-arora-1 wants to merge 2 commits intostan-dev:masterfrom
ishaan-arora-1:fix/clarify-print-dims-198
Open

Clarify print output to specify posterior draws and log-likelihood terms#328
ishaan-arora-1 wants to merge 2 commits intostan-dev:masterfrom
ishaan-arora-1:fix/clarify-print-dims-198

Conversation

@ishaan-arora-1
Copy link

Hey! This addresses #198, where the current print output like

Computed from 4000 by 262 log-likelihood matrix

was flagged as ambiguous — it's not immediately clear which dimension is the number of posterior draws and which is the number of observations/log-likelihood terms. As mentioned in the issue, ParetoSmooth.jl already uses a more explicit format, and this kind of ambiguity can hide bugs (e.g. a user accidentally placing all observations in one multivariate normal).

Changes

The new output format is:

Computed from 4000 posterior draws and 262 log-likelihood terms.

This is close to what @avehtari proposed in the issue comments ("Computed from 4000 posterior draws by 262 log-likelihood terms matrix"), but I dropped "matrix" since the user doesn't really need to know it's a matrix — they care about what the numbers mean.

For log-weight objects (raw psis/tis/sis):

Computed from 1000 posterior draws and 32 log-weight terms.

For subsampled loo:

Computed from 4000 posterior draws and 100 subsampled log-likelihood
terms from 3020 total observations.

Updated methods

  • print_dims.psis_loo
  • print_dims.importance_sampling
  • print_dims.importance_sampling_loo
  • print_dims.waic
  • print_dims.psis_loo_ss
  • print_dims.elpd_generic

Also updated

  • All corresponding tests in test_print_plot.R and test_loo_subsampling_cases.R
  • Snapshot files for psis.md, tisis.md, and loo_moment_matching.md
  • Vignette output in loo2-with-rstan.Rmd and loo2-large-data.Rmd
  • NEWS.md entry

Fixes #198

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 stan-dev#198
@ishaan-arora-1 ishaan-arora-1 marked this pull request as draft February 21, 2026 21:34
@ishaan-arora-1 ishaan-arora-1 marked this pull request as ready for review February 21, 2026 21:36
@avehtari
Copy link
Member

Hi @ishaan-arora-1, can you clarify why did you close this PR? Based on a quick look, it seems to be useful

@ishaan-arora-1
Copy link
Author

ishaan-arora-1 commented Feb 23, 2026

Hi @ishaan-arora-1, can you clarify why did you close this PR? Based on a quick look, it seems to be useful

Hey, i just wanted to review, why the tests weren't passing before reopening it.
I've reopened the pr now.

I am happy that this pr sounds useful. i'll try to get the tests working in a few hours.

@avehtari
Copy link
Member

In some of our repos there have been some CI tests failing due to Windows problems. It may take some days before your recent PRs are reviewed. Thanks for submitting them

@VisruthSK
Copy link
Member

Glancing at the failed logs, I think tests need to be upated to reflect the new documentation.

@ishaan-arora-1
Copy link
Author

do you maybe want a hand in that? just lemme know, ill be happy to contribute.

Glancing at the failed logs, I think tests need to be upated to reflect the new documentation.

@VisruthSK
Copy link
Member

Yes, do you want to take a stab at it?

The tests are expecting "subsampled log-likelihood values" but the new message is "subsampled log-likelihood terms", so the test case should reflect that.

@ishaan-arora-1
Copy link
Author

Yes, do you want to take a stab at it?

The tests are expecting "subsampled log-likelihood values" but the new message is "subsampled log-likelihood terms", so the test case should reflect that.

sure, would love to :)

The print_dims.psis_loo_ss method now says "log-likelihood terms"
instead of "log-likelihood values", so update the test expectations
to match.
@ishaan-arora-1
Copy link
Author

ishaan-arora-1 commented Feb 24, 2026

Fixed! The tests in test_loo_subsampling_cases.R were checking for "subsampled log-likelihood\nvalues" but the updated print_dims.psis_loo_ss now outputs "terms" instead of "values". Updated all 4 occurrences.

Ran the full test suite locally, 1160 pass, 0 fail, 0 warnings (2 skips are the usual M1 Mac platform skips).

Any feedback @avehtari @VisruthSK

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.77%. Comparing base (2883f25) to head (74dfab9).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
R/elpd.R 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #328      +/-   ##
==========================================
- Coverage   92.78%   92.77%   -0.01%     
==========================================
  Files          31       31              
  Lines        2992     2991       -1     
==========================================
- Hits         2776     2775       -1     
  Misses        216      216              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VisruthSK
Copy link
Member

Lgtm. If Aki likes the language I think this is good to merge.

The only thing I can think of is maybe the tests that you just had to fix should be snapshot tests instead, but that change needn't be made in this PR.

@ishaan-arora-1
Copy link
Author

Lgtm. If Aki likes the language I think this is good to merge.

The only thing I can think of is maybe the tests that you just had to fix should be snapshot tests instead, but that change needn't be made in this PR.

sounds good, i can do that in another pr.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify Sample Size a Bit More Clearly

4 participants