Repository navigation
Return probabilities of each response category for multinom models (emmeans backend) - #722
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The change spans multiple emmeans/nnet integration paths, and its added tests cannot be run against supported dependency versions in this environment.
No open issues 🎉
What changed in this PR
This pull request updates the emmeans backend for nnet::multinom() models so marginal means, contrasts, and slopes return probabilities separately for each response category rather than averaging across categories.
Changes:
- Adds multinomial probability-mode and response-category handling.
- Computes multinomial slopes directly with
emtrends()while preserving ordinal cumulative-probability handling. - Adds regression tests, NEWS documentation, and a development version increment.
| File | Description |
|---|---|
| tests/testthat/test-ordinal.R | Adds regression tests comparing multinomial means, response filtering, contrasts, and slopes with emmeans. |
| R/get_emtrends.R | Separates direct multinomial slope calculations from ordinal cumulative-probability transformations. |
| R/get_emmeans.R | Adds multinomial detection, probability-mode configuration, and response-category handling. |
| R/get_emcontrasts.R | Updates slope-contrast handling for the revised ordinal and multinomial mode distinctions. |
| NEWS.md | Documents the multinomial probability-output behavior fix. |
| DESCRIPTION | Increments the development package version to 0.19.0.1. |
Review effort: Lite
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",nnet::multinom()models gave 0.33 for every row ofestimate_means(), because emmeans averaged over the response categories. Contrasts and slopes were zero, and a filter such asby = "Sat='Low'"gave a probability of 1 with SE 0.These models now use
mode = "prob", like the ordinal models, and return one row per response category. Slopes come directly fromemtrends(), since multinomial models have no cumulative probabilities. Otherpredictvalues for multinom models are unchanged.The new test compares means, contrasts and slopes with emmeans.