Skip to content

Fix report text duplication for brms models#509

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-418
Draft

Fix report text duplication for brms models#509
Copilot wants to merge 4 commits intomainfrom
copilot/fix-418

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 31, 2025

This PR fixes an issue where report() output was duplicated multiple times for brms models, particularly when used in tidymodels workflows.

Problem

When calling report() on brmsfit objects, the same text would appear multiple times in the output, making the reports difficult to read and use.

Root Cause

The issue occurred because brmsfit objects use mixed inheritance:

  • Text generation: inherits from report_text.lm
  • Parameter processing: uses report_parameters.stanreg

This mismatch caused conflicts in the text assembly pipeline where stanreg-formatted parameters didn't integrate properly with the lm text framework, leading to duplication.

Solution

Registered report_text.brmsfit as a simple alias for report_text.lm, consistent with how the upstream main branch resolved the same class of issue. This ensures proper method dispatch without the complexity of a custom implementation, and aligns report.brmsfit() to use the standard as.report(txt, table = tbl, ...) call.

Example

library(brms)
library(report)

# Previously would show duplicated text
model <- brm(mpg ~ wt, data = mtcars, refresh = 0)
report(model)  # Now shows clean, non-duplicated output

Changes

  • R/report.brmsfit.R: registered report_text.brmsfit <- report_text.lm and used the clean as.report(txt, table = tbl, ...) pattern in report.brmsfit()
  • Added test coverage in tests/testthat/test-brmsfit-duplication-fix.R
  • Merged with origin/main (version 0.6.3.1), incorporating upstream fixes for related duplication issues

Validation

  • ✅ Method properly registered and available
  • ✅ Backward compatibility maintained (lm models unchanged)
  • ✅ No text duplication in output
  • ✅ All existing tests continue to pass

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 31, 2025 05:42
Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com>
Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Report text duplicated many times for brms model using in a tidymodels workflow Fix report text duplication for brms models Aug 31, 2025
Copilot AI requested a review from rempsyc August 31, 2025 05:45
@strengejacke
Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/report.brmsfit.R

Co-authored-by: strengejacke <26301769+strengejacke@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 29, 2026

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 7a05a876. The three conflicting files were:

  • DESCRIPTION: Used main's version 0.6.3.1 (upstream is ahead)
  • NEWS.md: Merged entries, keeping main's 0.6.2/0.6.3 changelog (which already includes the brmsfit duplication fix from [Bug]: Report for BRMS model leads to printing 4 times #543)
  • R/report.brmsfit.R: Used main's cleaner as.report(txt, table = tbl, ...) in report.brmsfit(), and aligned report_text.brmsfit to use the simple alias approach (report_text.brmsfit <- report_text.lm) consistent with how main fixed the issue.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants