Skip to content

Keep brms group-level totals to varying coefficients - #739

Open
M-Colley wants to merge 1 commit into
easystats:mainfrom
M-Colley:fix/grouplevel-random-terms
Open

M-Colley wants to merge 1 commit into
easystats:mainfrom
M-Colley:fix/grouplevel-random-terms

Conversation

@M-Colley

@M-Colley M-Colley commented Dec 5, 2026

Copy link
Copy Markdown

Summary

Keep estimate_grouplevel(type = "total") rows for brms coefficients that vary in the corresponding group and model component. In the chocomini example, this removes the 20 copies of the fixed-only precision coefficient. The 60 varying coefficients retain their estimates.

Fixes #467.

Validation

  • Five regression assertions failed on main and passed with the patch. The examples cover a nonlinear model, groups with different slopes, and a zero-inflation model.
  • The targeted run passed 63 checks on Windows R 4.5.3. Source build, install, and the package check passed. The two updated Linux plot references match the regenerated Windows files. Linux execution is pending.

I used Codex to prepare and test this patch.

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 unbumped development version and an avoidable full posterior allocation that can cause substantial performance and memory problems.

2 open issues
1 file not reviewed
  • man/estimate_grouplevel.Rd: Generated file
What changed in this PR

Updates estimate_grouplevel(type = "total") for brms models to retain only coefficients with corresponding varying effects.

Changes:

  • Filters fixed-only brms coefficients by group and model component.
  • Adds regression coverage for nonlinear, varying-slope, and zero-inflation models.
  • Updates documentation, NEWS, and affected plot snapshots.
File Description
tests/​testthat/​test-estimate_grouplevel.R Adds regression tests covering brms group-level total coefficient filtering.
tests/​testthat/​_snaps/​windows/​plot-grouplevel/​plot-grouplevel-bayes-5.svg Updates the Windows expected plot snapshot for the revised group-level output.
tests/​testthat/​_snaps/​windows/​plot-grouplevel/​plot-grouplevel-bayes-4.svg Updates the Windows expected plot snapshot for the revised group-level output.
tests/​testthat/​_snaps/​linux/​plot-grouplevel/​plot-grouplevel-bayes-5.svg Updates the Linux expected plot snapshot for the revised group-level output.
tests/​testthat/​_snaps/​linux/​plot-grouplevel/​plot-grouplevel-bayes-4.svg Updates the Linux expected plot snapshot for the revised group-level output.
R/​estimate_grouplevel.R Filters brms total estimates to coefficients with corresponding varying effects.
NEWS.md Documents the brms group-level total estimate behavior change.
man/​estimate_grouplevel.Rd Updates the generated documentation for group-level estimate behavior.

Review effort: Lite

Comment thread R/estimate_grouplevel.R

if (type == "total") {
# brms::coef() repeats fixed-only coefficients for each grouping factor.
random_terms <- lapply(brms::ranef(model, summary = FALSE), function(x) dimnames(x)[[3L]])
Comment thread NEWS.md
Comment on lines +14 to +15
* `estimate_grouplevel(type = "total")` now excludes brms coefficients without
a random effect in the corresponding group and model component.
@strengejacke strengejacke added the Revisions required 💥 A review has been submitted and changes requested. label Dec 5, 2026

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

Revisions required 💥 A review has been submitted and changes requested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only include random effects in estimate_grouplevel()

3 participants