Repository navigation
Probabilities by default for ordinal contrasts and slopes (emmeans backend) - #684
Merged
strengejacke merged 12 commits intoOct 18, 2026
Merged
Conversation
… (emmeans backend)
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
5 open findings
Forspecssupplied as a formula,.add_emmeans_pseudo_factor()replaces the entire formula with… · New The PR description states the version was bumped to0.17.0.16(and that the PR merged second… · New The row-order restoration aftermerge()relies on a key built only from non-numeric columns. If… · New This implementation depends on emmeans internal S4 slots (estimated@levels,… · New Line wrapping in this NEWS bullet is inconsistent (notably line 8 runs long and splits awkwardly),… · New
Files not reviewed (4)
- man/estimate_contrasts.Rd: Generated file
- man/estimate_means.Rd: Generated file
- man/estimate_slopes.Rd: Generated file
- man/get_emmeans.Rd: Generated file
🧠 Review effort: Lite
Copilot stopped reviewing on behalf of
strengejacke due to an error
October 16, 2026 17:26
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.



This follows #669, which added the ordinal
modetypes toestimate_means()with the emmeans backend. For ordinal models (MASS::polr(),ordinal::clm(),ordinal::clmm(), andglmmTMB()withfamily = ordinal()),estimate_contrasts()andestimate_slopes()withbackend = "emmeans"returned latent-scale values. The contrasts footer said "Contrasts are on the response-scale." emmeans ignorestype = "prob", sopredict = "prob"also returned latent values, with the footer "prob-scale".Now both functions pass the emmeans
modeargument, and probabilities are the default (also forpredict = "response"), as inestimate_means():Response). With"cum.prob","exc.prob"or"linear.predictor", they compare within each threshold (columnThreshold)."latent"and"mean.class"have neither column. For clmm models, the columns show the level names, not the codes 1, 2, 3, as forestimate_means().emtrends()withmode = "prob"or"mean.class"failed with "Irregular reference grid" on some polr fits, and gave slopes from -62 to 38 for a clmm fit. So these slopes are computed from the"cum.prob"trends, as linear contrasts. The probability of category k isP(y <= k) - P(y <= k - 1). The mean class is K minus the sum of the cumulative probabilities. Contrasts of slopes use the same slopes.ResponseorThreshold, as for the marginaleffects backend.predict = "latent"gives the former results.This is a breaking change, with a NEWS entry under "Breaking Changes". The
predictdocs (shared byestimate_means(),estimate_contrasts()andestimate_slopes()) now name the modes.Related changes:
merge()sorted the categories alphabetically (High, Low, Medium). Latent contrasts keep the sorted order.Response/Thresholdnow runs before the other column renames. Before, a response namedresponse,rate,proborratiowas renamed to the estimate name.Responsekeeps its column, and the categories becomeResponse.1, as inestimate_means().Tests in
test-ordinal.R:emmeans::contrast(emmeans(..., mode = "prob"), "revpairwise"). For polr and clm, also against the same-category rows of the marginaleffects backend. Each of the six modes for polr."cum.prob"trends (1e-6). Also against the marginaleffects backend (mean relative difference 1e-2), and againstemtrends()for the other modes. The slopes of each group sum to 0. The 1e-2 tolerance is needed becauseemtrends()uses a forward difference with a step of 0.001 times the range ofx. For the simulated fit, single slopes differ by up to 1.2% (emmeans 2.0.4, marginaleffects 1.0.0). A central finite difference matches marginaleffects.predict = "response", slopes with noby, the names above, and the former latent contrasts. The pinned latent contrasts in the "default predict" test now check that the default equalspredict = "prob".test-visualisation_recipe.R: the plot of ordinal emmeans slopes colors byResponseorThreshold.Not done here: brms ordinal models,
comparison = "joint"andeffectsizefor these contrasts,modepassed through..., andbyfilters on response categories. Such filters are now ignored in contrasts, where the call errored before.devtools::test()gives 0 failures and 0 errors locally.devtools::check()gives 0 errors and 0 warnings. The version is bumped to 0.17.0.16, as in #683, so the PR merged second needs 0.17.0.17.