Skip to content

Fix Rhat and ESS text for Bayesian models in report() - #629

Open
jmgirard wants to merge 2 commits into
mainfrom
hotfix-bayesian-diagnostics-text
Open

jmgirard wants to merge 2 commits into
mainfrom
hotfix-bayesian-diagnostics-text

Conversation

@jmgirard

@jmgirard jmgirard commented Nov 5, 2026

Copy link
Copy Markdown

report_parameters() for stanreg and brmsfit models added the Rhat and ESS text to each parameter by row position. bayestestR::diagnostic_posterior() sorts its rows by parameter name, but sexit() keeps the model's order. So when predictors aren't in alphabetical order, a parameter gets another parameter's values. This matches them by name now.

The ESS text had also disappeared, because recent versions of bayestestR and parameters name the column ESS_tail and report looked for ESS. It reads either one now. So the text shows the tail ESS under the label "ESS", the same value bayestestR describes as its ESS column. Is that label OK, or would you rather have it say tail ESS?

tests/testthat/_snaps/windows/report.stanreg.md: the two ESS values change from 451 and 478 to 379 and 355. The snapshot is from 2023, and these are now tail ESS.

Fixes #343

report_parameters() for stanreg and brmsfit models matched diagnostics to parameters by row position, but diagnostic_posterior() sorts its rows by name. Match them by name instead. Also read the ESS_tail column, so that the ESS text shows again with recent versions of bayestestR.
Copilot AI lite review requested due to automatic review settings November 5, 2026 05:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The change still has an unresolved package-version mismatch and insufficient test coverage for ESS alignment with unsorted predictors.

2 open issues
What changed in this PR

This pull request fixes Bayesian parameter reporting so Rhat and ESS diagnostics are matched by parameter name rather than row position, while supporting newer ESS column names.

Changes:

  • Aligns posterior diagnostics with sexit() parameter order.
  • Supports both ESS and ESS_tail, reporting tail ESS under the existing ESS label.
  • Adds regression coverage and updates the Stanreg snapshot and changelog.

The ESS regression test should use an unsorted-parameter model to verify alignment. The development version in DESCRIPTION should also be synchronized with the NEWS entries.

This pull request requires changes.

File Summary
tests/​testthat/​test-report.stanreg.R Adds Rhat and ESS regression tests for Bayesian models.
tests/​testthat/​_snaps/​windows/​report.stanreg.md Updates expected tail ESS values.
R/​report.stanreg.R Matches posterior diagnostic rows to parameters by name.
R/​report.lm.R Adds ESS text handling for supported ESS column names.
R/​report_parameters.R Adds shared ESS-column compatibility and diagnostic normalization.
NEWS.md Documents the Bayesian reporting fixes.

Review effort: Lite

Comment thread tests/testthat/test-report.stanreg.R Resolved
Comment thread NEWS.md Resolved
@jmgirard

jmgirard commented Nov 5, 2026 •

Copy link
Copy Markdown
Author

Copilot pointed out that the ESS test couldn’t catch the bug, because the shared model’s predictors are already in order, so it now uses the model with predictors out of order.

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

Development

Successfully merging this pull request may close these issues.

ESS is reported inconsistently for brmsfit objects

2 participants