Multinomial logistic regression

1 Why a multinomial model?

The binary outcome used earlier distinguishes only response from non-response. Sometimes we want to look at three or more outcome categories, and that is the focus of this chapter.

We use these categories:

  • low_no_to_mild: LSAS \(< 50\);
  • moderate_marked: \(50 \leq\) LSAS \(< 80\); and
  • severe_very_severe: LSAS \(\geq 80\).

Again, we choose these for teaching the course, not because they are always the ideal thresholds in clinical settings.

NoteOrdered categories

These categories are ordered: low/no-to-mild < moderate/marked < severe/very severe. The multinomial model we show here ignores that order. It treats the categories as unordered labels and estimates a separate set of treatment coefficients for each non-reference category, so with two active treatment arms it has four treatment coefficients. For an ordinal outcome, the usual first choice is a proportional-odds (cumulative logit) model, which uses the ordering and estimates one set of treatment coefficients for all categories, here two (Agresti 2010). It achieves this by assuming that the treatment odds ratio is the same at every cut-point between categories (low versus moderate or severe, and low or moderate versus severe), an assumption worth checking. The cumulative model can be motivated by an underlying (latent) continuous severity that is cut at thresholds; here that is literally how the categories were made, from LSAS cut at 50 and 80. When the full LSAS score is available, as it is here, analyzing it directly usually beats any categorical model, for the reasons given in the foundations chapter.

We use the multinomial model in this course because it is the general model for categorical outcomes, applies whether or not the categories are ordered, and makes the long-format data structure explicit. The probability-scale interpretation you learn here, how treatment redistributes probability across the categories, carries over directly to ordinal models.

2 Long data for mlogit

mlogit represents a multinomial outcome as a choice among alternatives. Each participant therefore appears once for every possible severity category. One and only one alternative is marked as the observed outcome.

library(tidyverse)
library(here)
library(mlogit)
library(marginaleffects)

options(
  marginaleffects_print_omit = c("s.value"),
  marginaleffects_print_style = ifelse(interactive(), "summary", "tinytable")
)

df_outcome <- read_csv2(here("data", "steps_clean.csv")) |>
  filter(!is.na(lsas_post), !is.na(trt)) |>
  mutate(
    severity_observed = case_when(
      lsas_post < 50 ~ "low_no_to_mild",
      lsas_post < 80 ~ "moderate_marked",
      .default = "severe_very_severe"
    ),
    severity_observed = factor(
      severity_observed,
      levels = c("low_no_to_mild", "moderate_marked", "severe_very_severe")
    ),
    trt = factor(trt, levels = c("waitlist", "therapist-guided", "self-guided"))
  ) |>
  select(id, trt, severity_observed)

Now that we have the necessary columns, let’s convert df_outcome from wide format (one row per participant) to long format (one row per response). The column severity_alt lists all outcome alternatives, and choice marks the observed outcome for each participant as TRUE and the two unobserved outcomes as FALSE. Notice how the number of rows changes between df_outcome and long.

long <- crossing(
  df_outcome,
  severity_alt = levels(df_outcome$severity_observed)
) |>
  mutate(choice = severity_alt == severity_observed)

# one participant from each treatment group
long |>
  filter(id %in% c(1, 3, 11))
id trt severity_observed severity_alt choice
1 therapist-guided moderate_marked low_no_to_mild FALSE
1 therapist-guided moderate_marked moderate_marked TRUE
1 therapist-guided moderate_marked severe_very_severe FALSE
3 waitlist moderate_marked low_no_to_mild FALSE
3 waitlist moderate_marked moderate_marked TRUE
3 waitlist moderate_marked severe_very_severe FALSE
11 self-guided severe_very_severe low_no_to_mild FALSE
11 self-guided severe_very_severe moderate_marked FALSE
11 self-guided severe_very_severe severe_very_severe TRUE

Next, we tell the mlogit package how to use the columns when fitting the model.

mlogit_data <- dfidx::dfidx(
  long,
  idx = c("id", "severity_alt"),
  choice = "choice",
  shape = "long",
  drop.index = TRUE,
  pkg = "mlogit"
)

3 Fit a multinomial model

mod_multinomial <- mlogit(
  choice ~ 1 | trt,
  data = mlogit_data,
  reflevel = "low_no_to_mild"
)
summary(mod_multinomial)

Call:
mlogit(formula = choice ~ 1 | trt, data = mlogit_data, reflevel = "low_no_to_mild", 
    method = "nr")

Frequencies of alternatives:choice
    low_no_to_mild    moderate_marked severe_very_severe 
           0.25444            0.46746            0.27811 

nr method
5 iterations, 0h:0m:0s 
g'(-H)^-1g = 1.13E-05 
successive function values within tolerance limits 

Coefficients :
                                       Estimate Std. Error z-value  Pr(>|z|)
(Intercept):moderate_marked             1.50408    0.45134  3.3325 0.0008607
(Intercept):severe_very_severe          1.42712    0.45461  3.1392 0.0016939
trttherapist-guided:moderate_marked    -1.41707    0.53928 -2.6277 0.0085967
trttherapist-guided:severe_very_severe -2.43872    0.61410 -3.9712 7.151e-05
trtself-guided:moderate_marked         -0.87992    0.55325 -1.5905 0.1117305
trtself-guided:severe_very_severe      -1.49611    0.58716 -2.5480 0.0108335
                                          
(Intercept):moderate_marked            ***
(Intercept):severe_very_severe         ** 
trttherapist-guided:moderate_marked    ** 
trttherapist-guided:severe_very_severe ***
trtself-guided:moderate_marked            
trtself-guided:severe_very_severe      *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Log-Likelihood: -169.37
McFadden R^2:  0.05419 
Likelihood ratio test : chisq = 19.409 (p.value = 0.00065319)
# Store one coefficient for the calculation below
b_multinomial <- coef(mod_multinomial)
b_guided_moderate <- b_multinomial[["trttherapist-guided:moderate_marked"]]

3.1 Interpreting the coefficients

As in binary logistic regression, the coefficients are on the log-odds scale. With three outcome categories, the model estimates two sets of coefficients because low_no_to_mild is the reference category:

  • moderate_marked versus low_no_to_mild

  • severe_very_severe versus low_no_to_mild

For example, the coefficient for therapist-guided treatment and moderate_marked is approximately -1.42. Exponentiating gives:

exp(b_guided_moderate)
[1] 0.2424244

This gives an odds ratio of approximately 0.24. In other words, the odds of a moderate/marked rather than a low/no-to-mild outcome are lower in the therapist-guided group than in the waitlist group. More precisely, they are 0.24 times as high in the therapist-guided group as in the waitlist group.

These odds ratios can become difficult to interpret because each compares one outcome category with the reference outcome category. We will therefore focus primarily on model-based probabilities, which show more directly how treatment redistributes the probability across the three severity categories.

# marginaleffects cannot recover the training data from an mlogit model,
# so attach the ordinary long data frame explicitly. Supply the same data
# frame, rather than mlogit_data, when requesting predictions.
mod_multinomial <- set_modeldata(mod_multinomial, as.data.frame(long))

severity_probabilities <- avg_predictions(
  mod_multinomial,
  newdata = as.data.frame(long),
  by = "trt"
)
severity_probabilities
Group trt Estimate Std. Error z Pr(>|z|) 2.5 % 97.5 %
Type: response
low_no_to_mild waitlist 0.103 0.0400 2.59 0.00968 0.0251 0.182
low_no_to_mild therapist-guided 0.407 0.0669 6.09 < 0.001 0.2764 0.538
low_no_to_mild self-guided 0.263 0.0583 4.51 < 0.001 0.1488 0.377
moderate_marked waitlist 0.466 0.0655 7.11 < 0.001 0.3371 0.594
moderate_marked therapist-guided 0.444 0.0676 6.57 < 0.001 0.3119 0.577
moderate_marked self-guided 0.491 0.0662 7.42 < 0.001 0.3614 0.621
severe_very_severe waitlist 0.431 0.0650 6.63 < 0.001 0.3036 0.558
severe_very_severe therapist-guided 0.148 0.0483 3.06 0.00218 0.0534 0.243
severe_very_severe self-guided 0.246 0.0570 4.31 < 0.001 0.1339 0.357

3.2 Probability redistribution

The following custom hypothesis calculates therapist-guided minus waitlist probability differences separately for each severity category.

therapist_minus_waitlist <- function(x) {
  x |>
    group_by(.data$group, .data$trt) |>
    summarize(estimate = mean(.data$estimate), .groups = "drop") |>
    pivot_wider(names_from = "trt", values_from = "estimate") |>
    transmute(
      term = .data$group,
      estimate = .data[["therapist-guided"]] - .data$waitlist
    )
}

severity_differences <- predictions(
  mod_multinomial,
  newdata = as.data.frame(long),
  hypothesis = therapist_minus_waitlist
)
severity_differences
Term Estimate Std. Error z Pr(>|z|) 2.5 % 97.5 %
Type: response
low_no_to_mild 0.3040 0.0779 3.901 <0.001 0.151 0.457
moderate_marked -0.0211 0.0941 -0.224 0.823 -0.206 0.163
severe_very_severe -0.2829 0.0810 -3.491 <0.001 -0.442 -0.124

And the code-block below calculates the odds ratios for the two active groups compared to waitlist, with Wald confidence intervals:

# Category-versus-reference ORs for therapist-guided versus waitlist
# Wald intervals on the log-odds scale, then exponentiate
multinomial_log_or <- b_multinomial[
  c(
    "trttherapist-guided:moderate_marked",
    "trttherapist-guided:severe_very_severe"
  )
]
# grab variance from the two contrasts of interest
multinomial_se <- sqrt(diag(vcov(mod_multinomial)))[names(multinomial_log_or)]
# exponentiate to get ORs and Wald intervals
severity_or <- tibble(
  category = c("moderate_marked", "severe_very_severe"),
  estimate = exp(multinomial_log_or),
  conf.low = exp(multinomial_log_or - qnorm(0.975) * multinomial_se),
  conf.high = exp(multinomial_log_or + qnorm(0.975) * multinomial_se)
)

severity_or
category estimate conf.low conf.high
moderate_marked 0.2424244 0.0842440 0.6976120
severe_very_severe 0.0872728 0.0261911 0.2908061

Compared with waitlist, therapist-guided treatment is associated with the following changes in the estimated probability of each post-treatment severity category (therapist-guided minus waitlist):

  • low/no-to-mild: rises by 30.4 percentage points (95% CI 15.1 to 45.7);
  • moderate/marked: falls by 2.1 percentage points (95% CI -20.6 to 16.3); and
  • severe/very severe: falls by 28.3 percentage points (95% CI -44.2 to -12.4).

The category probabilities sum to one, so the three differences sum to zero: whatever probability one category gains, the others lose.

For therapist-guided treatment versus waitlist, the OR for moderate/marked rather than low/no-to-mild severity is 0.24 (95% CI 0.08 to 0.70). The OR for severe/very severe rather than low/no-to-mild severity is 0.09 (95% CI 0.03 to 0.29).

severity_probabilities |>
  ggplot(aes(x = trt, y = estimate, color = group, group = group)) +
  geom_point(position = position_dodge(width = .2)) +
  geom_errorbar(
    aes(ymin = conf.low, ymax = conf.high),
    width = .1,
    position = position_dodge(width = .2)
  ) +
  labs(
    title = "Estimated post-treatment severity probabilities",
    subtitle = "Multinomial logit; 95% confidence intervals",
    x = "Treatment group",
    y = "Estimated probability",
    color = "Severity category"
  ) +
  theme_minimal()

4 Summary

  • Multinomial logit models probabilities for multiple outcome categories.
  • mlogit needs a long participant-by-alternative data structure.
  • Interpret the model as a redistribution of outcome probabilities, not as isolated coefficient changes.
  • The probability differences for the categories sum to zero across any treatment contrast.
  • Multinomial logit ignores any ordering of the categories; for an ordinal outcome, a proportional-odds model is usually the first choice.

References

Agresti, Alan. 2010. Analysis of Ordinal Categorical Data. 2nd ed. Wiley. https://doi.org/10.1002/9780470594001.