Skip to content

Conversation

Copy link
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

Added a dedicated report_text.brmsfit() method that:

  • Properly handles stanreg parameter output within the lm text framework
  • Prevents duplication by controlling parameter text assembly and conversion
  • Maintains full backward compatibility with existing functionality

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

  • Added report_text.brmsfit() method in R/report.brmsfit.R
  • Added comprehensive test coverage in tests/testthat/test-brmsfit-duplication-fix.R
  • Updated version to 0.6.1.3 and changelog

Validation

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

Fixes #418.


✨ 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 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
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.

Report text duplicated many times for brms model using in a tidymodels workflow

2 participants