Repository navigation
Show response level names for clmm models with the emmeans backend - #675
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered and no approval-blocking issues were identified.
0 open findings
What changed in this PR
Updates the emmeans backend to show response and threshold names for ordinal::clmm models.
Changes:
- Maps response and threshold codes to readable level names.
- Adds ordinal-model regression tests.
- Documents the fix and bumps the development version.
| File | Summary |
|---|---|
tests/testthat/test-ordinal.R |
Adds comprehensive ordinal-model tests. |
R/get_emmeans.R |
Converts clmm codes to readable names. |
NEWS.md |
Documents the bug fix. |
DESCRIPTION |
Bumps the development version. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
For
ordinal::clmmmodels, emmeans codes the response categories as1,2,3and the thresholds as1|2,2|3. Soestimate_means(m, backend = "emmeans")showed these codes in theResponseandThresholdcolumns, not the level names. For levels like2,4, ...,10, the codes looked like real levels but were wrong..clean_names_emmeans_ordinal()now replaces the codes withmodel$y.levels, and with<level>|<next level>for thresholds. The threshold names come from the levels, becausenames(model$alpha)holds parameter names forthreshold = "symmetric","symmetric2"and"equidistant". The mapping runs only for clmm models, and only when the values are exactly the codes. Other models give the same output as before, and a new test checks this for polr, clm and glmmTMB.test-brms.R:26fails at random for me. It compares the medians of two sets of posterior draws from the marginaleffects backend, which this PR does not touch. This PR and #673 both bump the version to 0.17.0.10, so the PR that merges second needs a new bump.