Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
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
1 open issue
What changed in this PR
Fixes a bug in adjust() when additive = TRUE where numeric predictors were not reliably wrapped in s() if a factor preceded them in effect, leading to gamm4() errors or incorrect linear fits.
Changes:
- Replace a length-mismatched
==comparison with%in%to correctly identify numeric predictors to smooth. - Add a regression test that validates
adjust()output against a directgamm4()fit for the problematic ordering. - Document the bug fix in
NEWS.md.
| File | Description |
|---|---|
| tests/testthat/test-adjust.R | Adds a regression test ensuring numeric terms are smoothed correctly when a factor appears before them. |
| R/adjust.R | Fixes numeric predictor detection by using %in% instead of == to avoid recycling/mis-matches. |
| NEWS.md | Documents the additive smoothing bug fix and its user-facing impact. |
Review effort: Lite
Contributor
Author
|
I left the bare |
Copilot stopped reviewing on behalf of
jmgirard due to an error
November 26, 2026 16:15
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

With
additive = TRUE,adjust()wraps numeric predictors ins()withpredictors[predictors == predictors_num]. When a factor comes before the numeric variables ineffect, the two vectors have different lengths, so==recycles and matches the wrong positions. For example,adjust(iris[c("Sepal.Length", "Species", "Sepal.Width", "Petal.Length")], select = "Sepal.Length", additive = TRUE)errors ingamm4()because no term getss(). With the factor between two numeric variables, one of them stays linear, so the adjusted values are wrong.This PR uses
%in%instead and adds a test that compares the result with a directgamm4()fit.