Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 31, 2025

This PR addresses issue #391 where report() was failing when models were built using stats::reformulate.

Analysis: The issue appears to have been resolved in recent versions (current: 0.6.1.3 vs reported: 0.5.7), but there were no regression tests to prevent this issue from reoccurring.

Changes made:

  • Added comprehensive regression tests for reformulate scenarios in tests/testthat/test-report.lm.R
  • Updated version number (0.6.1.2 → 0.6.1.3) and NEWS.md
  • Validated that all reformulate edge cases work correctly

Reformulate scenarios now tested:

  1. Simple reformulate: reformulate(c("wt", "hp"), "mpg")
  2. Reformulate with interactions: reformulate(c("wt", "hp", "wt:hp"), "mpg")
  3. Formula wrapper: formula(reformulate(...))
  4. No intercept: reformulate(..., intercept = FALSE)
  5. Compatibility verification for format_formula() and report_model()

Demonstration that the fix works:

library(report)

# Example 1: Normal formula (for comparison)
model_normal <- lm(mpg ~ wt + hp, data = mtcars)
print(summary(report(model_normal)))
#> We fitted a linear model to predict mpg with wt and hp. The model explains a
#> statistically significant and substantial proportion of variance (R2 = 0.83,
#> F(2, 29) = 69.21, p < .001, adj. R2 = 0.81).

# Example 2: Reformulate formula (issue #391 case)
model_reform <- lm(reformulate(c("wt", "hp"), "mpg"), data = mtcars)
print(summary(report(model_reform)))
#> We fitted a linear model to predict mpg with wt and hp. The model explains a
#> statistically significant and substantial proportion of variance (R2 = 0.83,
#> F(2, 29) = 69.21, p < .001, adj. R2 = 0.81).

# Example 3: Formula wrapper of reformulate  
model_formula <- lm(formula(reformulate(c("wt", "hp"), "mpg")), data = mtcars)
print(summary(report(model_formula)))
#> We fitted a linear model to predict mpg with wt and hp. The model explains a
#> statistically significant and substantial proportion of variance (R2 = 0.83,
#> F(2, 29) = 69.21, p < .001, adj. R2 = 0.81).

# Verify all produce identical results
identical(as.character(summary(report(model_normal))),
          as.character(summary(report(model_reform)))) &&
identical(as.character(summary(report(model_normal))),
          as.character(summary(report(model_formula))))
#> [1] TRUE

All 14 new regression tests pass successfully, ensuring that models built with reformulate() work identically to models built with standard formula syntax.

Fixes #391.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/easystats/insight/commits/HEAD
    • Triggering command: /usr/lib/R/bin/exec/R --no-restore --no-save -e devtools::install_github(c(&#34;easystats/insight&#34;,~&#43;~&#34;easystats/bayestestR&#34;,~&#43;~&#34;easystats/parameters&#34;,~&#43;~&#34;easystats/performance&#34;,~&#43;~&#34;easystats/effectsize&#34;,~&#43;~&#34;easystats/datawizard&#34;)) (http block)
  • https://r-universe.dev/src/contrib/PACKAGES
    • Triggering command: /usr/lib/R/bin/exec/R --no-restore --no-save -e install.packages(c(&#34;insight&#34;,~&#43;~&#34;bayestestR&#34;,~&#43;~&#34;effectsize&#34;,~&#43;~&#34;performance&#34;,~&#43;~&#34;parameters&#34;,~&#43;~&#34;datawizard&#34;,~&#43;~&#34;styler&#34;),~&#43;~repos=c(&#34;REDACTED&#34;,~&#43;~&#34;REDACTED&#34;)) (http block)
  • https://r-universe.dev/src/contrib/PACKAGES.gz
    • Triggering command: /usr/lib/R/bin/exec/R --no-restore --no-save -e install.packages(c(&#34;insight&#34;,~&#43;~&#34;bayestestR&#34;,~&#43;~&#34;effectsize&#34;,~&#43;~&#34;performance&#34;,~&#43;~&#34;parameters&#34;,~&#43;~&#34;datawizard&#34;,~&#43;~&#34;styler&#34;),~&#43;~repos=c(&#34;REDACTED&#34;,~&#43;~&#34;REDACTED&#34;)) (http block)
  • https://r-universe.dev/src/contrib/PACKAGES.rds
    • Triggering command: /usr/lib/R/bin/exec/R --no-restore --no-save -e install.packages(c(&#34;insight&#34;,~&#43;~&#34;bayestestR&#34;,~&#43;~&#34;effectsize&#34;,~&#43;~&#34;performance&#34;,~&#43;~&#34;parameters&#34;,~&#43;~&#34;datawizard&#34;,~&#43;~&#34;styler&#34;),~&#43;~repos=c(&#34;REDACTED&#34;,~&#43;~&#34;REDACTED&#34;)) (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 31, 2025 05:33
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 fails when model formulat built with stats::reformulate Aug 31, 2025
Copilot AI requested a review from rempsyc August 31, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants