Skip to content

Fix check_singularity.lme tolerance and dropped count-model hint - #947

Merged
strengejacke merged 2 commits into
easystats:mainfrom
sims1253:fix/ry-audit-round2
Sep 10, 2026
Merged

Fix check_singularity.lme tolerance and dropped count-model hint#947
strengejacke merged 2 commits into
easystats:mainfrom
sims1253:fix/ry-audit-round2

Conversation

@sims1253

@sims1253 sims1253 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

check_singularity.lme applies the tolerance to the wrong expression

In R/check_singularity.R, the lme method closes abs() after the comparison:

any(abs(stats::na.omit(as.numeric(diag(nlme::getVarCov(x)))) < tolerance))

abs() receives the logical vector from < tolerance, not the variance estimates. The effective test is estimate < tolerance on the raw diagonal, so a strongly negative estimate counts as singular whatever its magnitude.

check_heteroscedasticity drops the count-model hint

In R/check_heteroscedasticity.R, the default method builds a longer message for count models but never assigns it, so the hint never reaches the user.

Found during my most recent ry audit.

@strengejacke

Copy link
Copy Markdown
Member

Thanks, looks good to me! Let me also request an additional AI review

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.

🟡 Changes recommended

Add the missing nlme regression test and correct the development NEWS/version placement.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes nlme singularity tolerance handling and restores the count-model hint in heteroscedasticity messages.

Changes:

  • Corrects absolute-value placement in check_singularity.lme.
  • Restores count-model guidance messaging.
  • Adds regression coverage for the restored hint.
  • Documents the fixes in NEWS.md.
File summaries
File Summary
tests/testthat/test-check_heteroskedasticity.R Tests the restored count-model hint.
R/check_singularity.R Fixes the tolerance comparison; an nlme regression test remains needed.
R/check_heteroscedasticity.R Restores count-model messaging.
NEWS.md Documents the fixes; version and (devel) placement require adjustment.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread R/check_singularity.R
insight::check_if_installed("nlme")

any(abs(stats::na.omit(as.numeric(diag(nlme::getVarCov(x)))) < tolerance))
any(abs(stats::na.omit(as.numeric(diag(nlme::getVarCov(x))))) < tolerance)
Comment thread NEWS.md
Comment on lines +5 to +9
* `check_singularity()` for models from package *nlme* now applies the
tolerance to the absolute values of the variance-covariance diagonal.

* `check_heteroscedasticity()` now includes the hint about overdispersion and
zero-inflation in the message for count models.
@strengejacke

Copy link
Copy Markdown
Member

Thanks! Comments are minor and don't need to be addressed.

@strengejacke
strengejacke merged commit 50a7504 into easystats:main Sep 10, 2026
12 of 20 checks passed
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.

3 participants