Return per-category and per-threshold estimates for ordinal models with the emmeans backend - #670
Merged
strengejacke merged 4 commits intoSep 30, 2026
Conversation
…th the emmeans backend
… docs - Name the response pseudo-factor after the formula's left-hand side, so that models with e.g. factor(y) as response no longer fail. - Add Latent, Linear_predictor, and Mean_class to the known estimate names. - Document the ordinal modes and the "prob" default for estimate_means(). - Check the number of matched rows in the glmmTMB test.
strengejacke
approved these changes
Sep 30, 2026
strengejacke
merged commit Sep 30, 2026
ff69ccb
into
easystats:support_emmeans_ordinal
1 check failed
strengejacke
added a commit
that referenced
this pull request
Oct 1, 2026
* Support ordinal (argument `mode` for emmeans backend * Return per-category and per-threshold estimates for ordinal models with the emmeans backend (#670) * Add tests for ordinal modes with the emmeans backend (failing) * Return per-category and per-threshold estimates for ordinal models with the emmeans backend * Update NEWS entry for ordinal models with the emmeans backend * Fix ordinal emmeans output for transformed responses, plot names, and docs - Name the response pseudo-factor after the formula's left-hand side, so that models with e.g. factor(y) as response no longer fail. - Add Latent, Linear_predictor, and Mean_class to the known estimate names. - Document the ordinal modes and the "prob" default for estimate_means(). - Check the number of matched rows in the glmmTMB test. * Update R/get_emmeans.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * skip test --------- Co-authored-by: Jeffrey Girard <me@jmgirard.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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 PR goes into
support_emmeans_ordinal(#669), not intomain.With #669,
estimate_means(m, "Type", predict = "prob", backend = "emmeans")returns 0.333 in every row. For ordinal modes, emmeans adds a pseudo-factor to the reference grid. If that factor is not inspecs, emmeans averages over it. This PR adds that factor tospecs:predict = "prob", the response factor is added. The output has one row per response category, in aResponsecolumn."cum.prob","exc.prob"and"linear.predictor", thecutfactor is added. The output has one row per threshold, in aThresholdcolumn.Probability,Mean_class,LatentandLinear_predictor. These names are also added to the list of known estimate names, socoef_nameis set.factor(y). The PR uses the same name.For ordinal models (not brms), the default
predicton the emmeans means path is now"prob". Before, the default was"response", which emmeans ignores for these models, so latent values were printed as "Probability".estimate_contrasts()andestimate_slopes()are not changed. A test pins their current output forpolr.Tests in
test-ordinal.R:predict = "prob"and the default, for one and two focal terms, compared with the marginaleffects backend (polr, clm), within 1e-6.mean.classandlatent, and the three threshold modes, compared withemmeans::emmeans()directly (polr).factor(SatNum)in the formula.The glmmTMB block keeps the version skip (needs glmmTMB >= 1.1.15.2). The NEWS entry and the
predictdocs are updated.Found but not changed here:
estimate_means(m, "Type", backend = "emmeans", mode = "latent"), withmodepassed through..., fails with a memory error. It fails in the same way onmain.nnet::multinomwithpredict = "prob"and the emmeans backend, every row is still 0.33, because only ordinal models get the pseudo-factor.test-brms.R:26fails at random, also onmain.