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
4 open issues
marginaleffects` is used in this test but the test doesn’t call… · New marginaleffects` is used in this test but the test doesn’t call… · New marginaleffects` is used in this test but the test doesn’t call… · New This print-format assertion is quite brittle: it depends on a specific separator pattern (" |")… · New
What changed in this PR
Fixes incorrect joint test (Wald/F/Chisq) statistics for ordinal-model response-category contrasts when using the emmeans backend, aligning joint tests with the displayed contrasts.
Changes:
- Regrid ordinal
"prob"-modeemmeansgrids before computing joint tests to ensure correct joint-test statistics. - Return plain
data.frameresults for joint tests without adigitsattribute to stabilize printed formatting. - Add/extend test coverage validating joint tests against delta-method,
marginaleffects, andemmeans::joint_tests(), plus NEWS + version bump.
| File | Description |
|---|---|
| tests/testthat/test-ordinal.R | Adds regression tests for ordinal joint tests (correct stats, no warnings, stable printing, mode-specific behavior). |
| R/get_jointtest.R | Forces joint-test output to be a plain data.frame without digits attribute to control downstream formatting. |
| R/get_emcontrasts.R | Applies emmeans::regrid() for ordinal "prob" mode when comparison = "joint" to correct joint-test calculations. |
| NEWS.md | Documents the bugfix and related printing/warning changes. |
| DESCRIPTION | Bumps package version. |
Review effort: Lite
Contributor
Author
|
Copilot stopped reviewing on behalf of
jmgirard due to an error
October 19, 2026 19:42
strengejacke
approved these changes
Oct 20, 2026
Member
|
Could you please resolve the merge conflicts? (I don't want to overwrite with the wrong state) Then this PR can be merged. |
Keep the response-category filter from main and regrid after it. The joint test with a contrast filter on the response now expects the regridded statistics.
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
backend = "emmeans", joint tests (comparison = "joint") of contrasts between the response categories of ordinal models gave wrong F and Chi-squared statistics. emmeans computes joint tests from the linear functions of its grid. For the"prob"mode of ordinal models, these did not match the contrasts that were shown. Afteremmeans::regrid(), the joint tests equal the Wald statistic of the contrasts.Example, with
m <- MASS::polr(Sat ~ Infl + Type, weights = Freq, data = MASS::housing, Hess = TRUE). All calls usebackend = "emmeans":estimate_contrasts(m, "Sat", by = "Infl", comparison = "joint")estimate_contrasts(m, "Infl", by = "Type", comparison = "joint")print(estimate_contrasts(m, "Infl", comparison = "joint"))114.5880000114.59print(get_emcontrasts(m, "Infl", comparison = "joint"))The new values equal a delta-method Wald test of the
Medium - LowandHigh - Lowprobability contrasts. They also equalmarginaleffects::hypotheses(joint = TRUE)of the same contrasts (45.0955, 29.2141, 90.3444).What changed:
comparison = "joint",get_emcontrasts()(R/get_emcontrasts.R) callsemmeans::regrid()on the grid of ordinal models in the"prob"mode beforeemmeans::contrast(). Other modes are not regridded, because for"linear.predictor",regrid()back-transforms the grid to cumulative probabilities. Slope contrasts are not changed..get_jointtest.emmGrid()(R/get_jointtest.R) returns a plain data frame without thedigitsattribute.insight::format_table()used that attribute (7) for theChisqcolumn. If the attribute is missing,as.data.frame()of asummary_emmobject sets it again.Tests in
test-ordinal.R:"Sat"by"Infl"equal a delta-method Wald test and marginaleffects (polr and clm)."Infl"equal the delta method andemmeans::joint_tests().Chisqprints with two decimals."latent","linear.predictor","cum.prob","exc.prob"and"mean.class"modes, joint tests keep the values ofemmeans::joint_tests().Not fixed here, the same as on main:
contrast = c("cyl", "am"), stop with an error, also forlmmodels. So do joint tests with a filter incontrast, such as"cyl=c('4','6')".ordinal::clm()fits,"Infl"joint tests still warn "NaNs produced" withpredict = "cum.prob", and with"mean.class"andby = "Type".