Skip to content

Handle brms 0 + Intercept formulas in get_modelmatrix()#1199

Merged
strengejacke merged 2 commits into
mainfrom
copilot/fix-report-error-intercept
May 25, 2026
Merged

Handle brms 0 + Intercept formulas in get_modelmatrix()#1199
strengejacke merged 2 commits into
mainfrom
copilot/fix-report-error-intercept

Conversation

Copilot AI commented May 25, 2026

Copy link
Copy Markdown
Contributor

report() could fail on brms models fitted with formulas like 0 + Intercept + wt because insight::get_modelmatrix() reconstructed the RHS from variable names and treated Intercept as if it were a data column. This updates the brms path to preserve the intercept correctly when rebuilding the model matrix.

  • Model-matrix reconstruction

    • Update get_modelmatrix.brmsfit() to:
      • detect intercept presence separately
      • exclude symbolic Intercept from predictor extraction
      • rebuild the formula with the correct intercept setting
    • keep intercept-only cases working without requiring an Intercept column in the data
  • Regression coverage

    • Add a focused brms test for formulas of the form 0 + Intercept + wt
    • Assert the resulting model matrix has the expected columns:
      • "(Intercept)"
      • "wt"
  • Package metadata

    • Bump the development version
    • Add a NEWS entry for the user-visible bug fix

Example of the affected case:

m <- brms::brm(mpg ~ 0 + Intercept + wt, data = mtcars, refresh = 0)

insight::get_modelmatrix(m)
# now returns columns: "(Intercept)", "wt"

Agent-Logs-Url: https://github.com/easystats/insight/sessions/599f4836-a7a8-431d-9330-d2405f4aff38

Co-authored-by: DominiqueMakowski <8875533+DominiqueMakowski@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix report() failure on brms with 0 + Intercept formula Handle brms 0 + Intercept formulas in get_modelmatrix() May 25, 2026
Copilot AI requested a review from DominiqueMakowski May 25, 2026 08:36
@strengejacke strengejacke marked this pull request as ready for review May 25, 2026 09:52
@strengejacke strengejacke merged commit 2e3f033 into main May 25, 2026
17 of 20 checks passed
@strengejacke strengejacke deleted the copilot/fix-report-error-intercept branch May 25, 2026 09:54
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.

report() fail on brms with 0 + Intercept formula

3 participants