Repository navigation
Conversation
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.
There was a problem hiding this comment.
🟡 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
ESSandESS_tail, reporting tail ESS under the existingESSlabel. - 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
|
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. |


report_parameters()forstanregandbrmsfitmodels added the Rhat and ESS text to each parameter by row position.bayestestR::diagnostic_posterior()sorts its rows by parameter name, butsexit()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_tailand report looked forESS. It reads either one now. So the text shows the tail ESS under the label "ESS", the same value bayestestR describes as itsESScolumn. 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