Skip to content

Fix survey GLM degrees of freedom and reuse performance tables - #618

Open
M-Colley wants to merge 13 commits into
easystats:mainfrom
M-Colley:codex/fix-model-statistic-df
Open

M-Colley wants to merge 13 commits into
easystats:mainfrom
M-Colley:codex/fix-model-statistic-df

Conversation

@M-Colley

@M-Colley M-Colley commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Survey logistic models return t statistics, but report_table() removed their df_error column, causing report() to fail in format_value(NULL). Retain degrees of freedom for t tests, use exact column lookups (with a legacy df fallback), and omit unavailable df without changing the statistic's distribution. Reuse supplied performance tables to avoid redundant refits and repeated diagnostics.

Adds survey integration and linear-model regressions, including strict partial-match warnings and supplied-table reuse. Updates mixed-model and survival snapshots only to remove duplicate diagnostics.

Fixes #613. Fixes #228.

Validation: Targeted model, intercept, performance, and statistics tests pass, including 8 new assertions; changed R files have no lint findings.

Broader verification with all seven fixes combined: installed-package tests reported 757 passing expectations, 0 test warnings, and 17 skips. The only 2 failures are lavaan snapshots also reproduced on unchanged main (622 passing expectations). R CMD check passed code, documentation, examples, and vignette-code checks; it retains the baseline snapshot error and 2 warnings because vignettes were intentionally not built. Independent review and git diff --check passed.

CI investigation: updated the optional ivreg snapshot to expect one standardization message, matching the reused performance table. The affected linear, mixed, IV, survival, and survey test files pass locally. The full matrix also exposes failures shared by independent PRs: Stan compilation before reporting code runs, existing lavaan/stanreg snapshot drift, and optional-dependency resolution on R 4.2–4.4. These remain separate from this fix.

M-Colley and others added 5 commits November 17, 2026 20:41
Because this pull request edits tests/testthat/test-report_intercept.R,
the lint-changed-files check lints the whole file and fails on the
existing top-level `<<-` assignments (assignment_linter). They are
intentional, since insight::get_data() needs the data in the global
environment, so mark them with `# nolint` as elsewhere in the package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
1 file not reviewed
  • man/report.Rd: Generated file
What changed in this PR

This PR fixes failures in report()/report_statistics() stemming from dropped or partially matched degrees-of-freedom columns (notably for survey logistic models), and improves performance reporting by reusing provided tables instead of refitting/recomputing diagnostics.

Changes:

  • Preserve/lookup df_error correctly for t-statistics (with legacy df fallback) and omit df text when unavailable.
  • Reuse supplied performance tables to avoid redundant report_table() recomputation and duplicate diagnostics.
  • Add/adjust tests and snapshots for SEM fit formatting, Bayesian diagnostics ESS columns, survey GLM df handling, and CI workflows.
File Description
vignettes/​report_ai.Rmd Doc wording tweak for report_ai() narrative.
tests/​testthat/​test-report_intercept.R Lint suppression for intentional global assignments and whitespace cleanup.
tests/​testthat/​test-report_diagnostics.R New unit tests for lavaan fit text formatting and Bayesian diagnostics ESS handling.
tests/​testthat/​test-report.stanreg.R Snapshot updated to disable diagnostics; adds assertions aligning diagnostics with fitted posterior.
tests/​testthat/​test-report.lavaan.R Snapshot normalization for version-varying GFI; adds fitted-value consistency checks.
tests/​testthat/​test-model-statistic-df.R New tests for exact df column lookup, survey t-test df retention, and performance table reuse.
tests/​testthat/​_snaps/​windows/​report.survreg.md Snapshot updated to remove duplicated diagnostics output.
tests/​testthat/​_snaps/​windows/​report.stanreg.md Snapshot updated for include_diagnostic = FALSE output.
tests/​testthat/​_snaps/​windows/​report.lmer.md Snapshot updated to remove duplicated diagnostics output.
tests/​testthat/​_snaps/​windows/​report.lavaan.md Snapshot updated to normalize GFI rendering and reflect new print calls.
tests/​testthat/​_snaps/​windows/​report.ivreg.md Snapshot updated to remove duplicated standardization message.
lychee.toml Excludes r-universe URL that returns a Cloudflare JS challenge.
inst/​WORDLIST Adds new terms used in docs/tests (e.g., LLM/LLMs, suboptimal).
README.md Updates stars badge link target.
README.Rmd Updates stars badge link target (source Rmd).
R/​report_performance.R Fixes formatting to preserve sign/integer part (avoids truncating first character).
R/​report_parameters.R Updates Bayesian diagnostics text to support ESS_tail/ESS_bulk and legacy ESS.
R/​report.lm.R Fixes df handling for t-statistics and reuses supplied performance tables.
NEWS.md Documents df fix, performance reuse, and diagnostics formatting changes.
DESCRIPTION Adds survey to Suggests for survey model support/testing.
.github/​workflows/​test-coverage.yml Replaces reused workflow with in-repo workflow steps and Windows coverage run.
.github/​workflows/​check-random-test-order.yml Adds explicit Windows job to run tests in randomized file order.
.github/​workflows/​R-CMD-check.yml Replaces reused workflow with explicit matrix, compatibility pins, and stricter checks.
.Rbuildignore Excludes lychee.toml from package builds.

Review effort: Lite

Comment thread R/report_parameters.R
Comment on lines +266 to +284
stability <- effectsize::interpret_ess(ess, ...)
stability_text <- c(
"TRUE TRUE" = " and the indices are reliable",
"TRUE FALSE" = " even though the indices appear as reliable",
"FALSE TRUE" = " but the indices are unreliable",
"FALSE FALSE" = " and the indices are unreliable"
)[paste(
stability == "sufficient",
convergence == "converged"
)]
text_output <- paste0(
text_output,
stability_text,
" (",
ess_label,
" = ",
insight::format_value(ess, digits = 0),
")"
)
"t(30) = ",
fixed = TRUE
)
expect_no_warning(report(model))
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.37%. Comparing base (58c7492) to head (a0a954b).
⚠️ Report is 95 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #618       +/-   ##
===========================================
+ Coverage   72.36%   87.37%   +15.00%     
===========================================
  Files          54       55        +1     
  Lines        3684     5046     +1362     
===========================================
+ Hits         2666     4409     +1743     
+ Misses       1018      637      -381     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

[Bug]: report() fails on svyglm objects: format_value(NULL) error from missing df column in report_statistics.glm() Get rid of partial match warning

2 participants