Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 31, 2025

When using lmerTest::lmer() models with report(anova()), the output was missing denominator degrees of freedom in the F-statistic. Instead of showing F(1, 21.92) = 62.20, it only showed F(1) = 62.20.

Problem
The issue occurred because report_statistics.aov() only checked for denominator degrees of freedom in:

  1. "Residuals" rows in the Parameter column (for regular ANOVA tables)
  2. "DoF_Residuals" columns (legacy format)

However, lmerTest provides denominator degrees of freedom directly in a df_error column for each parameter, which wasn't being checked.

Solution
Added a third condition to check for the df_error column in the parameters table:

# Before (incomplete logic)
if (!is.null(DoF_residual)) {
  text <- paste0(text, ", ", insight::format_value(DoF_residual, protect_integers = TRUE))
} else if ("DoF_Residuals" %in% names(parameters)) {
  text <- paste0(text, ", ", insight::format_value(parameters$DoF_Residuals, protect_integers = TRUE))
}

# After (complete logic)  
if (!is.null(DoF_residual)) {
  text <- paste0(text, ", ", insight::format_value(DoF_residual, protect_integers = TRUE))
} else if ("DoF_Residuals" %in% names(parameters)) {
  text <- paste0(text, ", ", insight::format_value(parameters$DoF_Residuals, protect_integers = TRUE))
} else if ("df_error" %in% names(parameters)) {
  text <- paste0(text, ", ", insight::format_value(parameters$df_error, protect_integers = TRUE))
}

Example

library(lmerTest)
library(report)

m <- lmerTest::lmer(mpg ~ wt + (1| gear), data=mtcars) 
report(anova(m))

# Before: F(1) = 62.20, p < .001 (missing denominator df)
# After:  F(1, 21.92) = 62.20, p < .001 (includes denominator df)

The fix preserves all existing functionality for regular ANOVA models while properly supporting lmerTest models that provide Satterthwaite or Kenward-Roger denominator degrees of freedom.

Fixes #453.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] report() not outputting denominator degrees of freedom Fix missing denominator degrees of freedom in lmerTest ANOVA reports Aug 31, 2025
Copilot AI requested a review from rempsyc August 31, 2025 05:32
Copilot finished work on behalf of rempsyc August 31, 2025 05:32
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() not outputting denominator degrees of freedom

2 participants