Skip to content

Return probabilities of each response category for multinom models (emmeans backend) - #722

Merged
strengejacke merged 3 commits into
mainfrom
hotfix-multinom-emmeans-prob
Nov 26, 2026
Merged

strengejacke merged 3 commits into
mainfrom
hotfix-multinom-emmeans-prob

Conversation

@jmgirard

Copy link
Copy Markdown
Contributor

With backend = "emmeans", nnet::multinom() models gave 0.33 for every row of estimate_means(), because emmeans averaged over the response categories. Contrasts and slopes were zero, and a filter such as by = "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 from emtrends(), since multinomial models have no cumulative probabilities. Other predict values for multinom models are unchanged.

The new test compares means, contrasts and slopes with emmeans.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@strengejacke
strengejacke merged commit 1491f11 into main Nov 26, 2026
10 of 19 checks passed
@strengejacke
strengejacke deleted the hotfix-multinom-emmeans-prob branch November 26, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants