Rank-ordered logit model in brms

I am trying to fit a rank-ordered logit model using brms and am running into some trouble. This type of model is used when respondents are asked to give the full rank of their preferences among all considered options.

To begin solving this problem I first used a frequentist approach as a sanity check. Here’s an example from this tutorial using the mlogit R package:

data("Game", package = "mlogit")
G <- mlogit.data(Game, shape = "wide", choice = "ch", varying = 1:12, ranked = TRUE)
summary(mlogit(ch ~ own, G, reflevel = "GameBoy"))

mlogit(formula = ch ~ own, data = G, reflevel = "GameBoy", method = "nr")

Frequencies of alternatives:
    GameBoy    GameCube          PC PlayStation  PSPortable        Xbox 
    0.13846     0.13407     0.17363     0.18462     0.17363     0.19560 

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

Coefficients :
                        Estimate Std. Error z-value  Pr(>|z|)    
GameCube:(intercept)     0.10738    0.18467  0.5815 0.5609365    
PC:(intercept)           0.61739    0.23238  2.6568 0.0078878 ** 
PlayStation:(intercept)  1.15484    0.19514  5.9179 3.261e-09 ***
PSPortable:(intercept)   0.69416    0.18388  3.7752 0.0001599 ***
Xbox:(intercept)         1.47481    0.19317  7.6348 2.265e-14 ***
own                      0.96561    0.18323  5.2699 1.365e-07 ***
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Log-Likelihood: -532.81
McFadden R^2:  0.34294 
Likelihood ratio test : chisq = 556.19 (p.value = < 2.22e-16)

Here was my attempt to translate using brms:

brm(data = G, 
      family = multinomial(link = "logit", refcat = "Gameboy"),
      ch ~ 1 + own,
      prior(normal(0, 5), class = Intercept),
      iter = 2500, warmup = 500, cores = 2, chains = 2,
      seed = 10)

The error I’m getting is: Error: At least 2 response categories are required.

So my question is there another way to model responses using brms when I have for each respondent a rank ordered list of their preferences?

  • Operating System: mac
  • brms Version: 2.12.0

As a follow up, I’m still looking for help with this problem. Any assistance from anyone on the forum would be greatly appreciated!!

This won’t answer your question precisely, but you might want to look at the example brms syntax in this thread: https://github.com/paul-buerkner/brms/issues/560 re: the “fishing” dataset from the mlogit package. Even though the data structure differs, the brms syntax work well for discrete choice models and might be able to be adapted to meet your needs. Sorry in advance if unhelpful.

Thank you for responding to my question. I have tried the brms syntax on the thread you suggested and I still can’t get the parameter estimates to roughly correspond to the frequentist estimates I get from the mlogit package.

I’ve also tried syntax from some other threads but they didn’t work. Thus, I’m still looking for an answer to this question.

Can you post the updated model code you are using?

I’m basically using code like @paul.buerkner used in the github link earlier in this thread:

# choice data in **wide** format
data("Fishing", package = "mlogit")

Fishing$noboat <- 0
# the first 50 persons did not have the "boat" option
Fishing$noboat[1:50] <- -100

bform2 <- bf(
  mode ~ 1,
  nlf(mubeach ~ bprice * price.beach + bcatch * catch.beach),
  nlf(mupier ~ bpier + bprice * price.pier + bcatch * catch.pier),
  nlf(muboat ~ bboat + bprice * price.boat + bcatch * catch.boat + noboat),
  nlf(mucharter ~ bcharter + bprice * price.charter + bcatch * catch.charter),
  bpier + bboat + bcharter + bprice + bcatch ~ 1,
  family = categorical(refcat = NA)

nlpars <- c("bpier", "bboat", "bcharter", "bprice", "bcatch")
bprior2 <-  set_prior("normal(0, 5)", nlpar = nlpars)

fit2 <- brm(formula = bform2, data = Fishing,
           prior = bprior2, chains = 2, cores = 2)

# p(boat) is 0 for the first 50 observations
round(fitted(fit2, newdata = Fishing[1:100, ])[, 1, ], 5)

The other possibility is that I’m on the wrong track entirely. There just seems like there has to be a more rich way to analyze a rank order of a list from each participant than modeling their top choice. For example, if someone ranks their favorite colors as being blue, green, red, and then yellow, it would be better if a model could fully capture that compared to just modeling their top choice (blue).

For this kind of data, I recommend ordinal models, which have rich support in brms. I have also written a paper about this topic in case you are interested: https://psyarxiv.com/x8swp/

1 Like

Interesting. Though I got the sense from the paper (which seems great by the way) that ordinal models are only applicable when an outcome variable is both categorical and has natural orderings. I’m interested in how to model where people fully rank a variable like color where the levels don’t have a natural ordering (e.g., blue, green, red, yellow). Does your suggestion still hold in my case?

I see. In such a case, models such as the Thurstonian IRT model may be more appropriate, but I am not enough into the details of your question to be able to tell exactly. Some basic Thurstonian IRT models can be fitted with my thurstonianIRT package (https://github.com/paul-buerkner/thurstonianIRT) and for more complex stuff you may have to go back to pure Stan.

1 Like

I was interested in the rank ordered logit model because for each respondent I have their ranking of the response options of a categorical variable with no natural ordering. This is very common in marketing. For example, data video game console preference might show that a respondent’s first preference now XBOX, second preference is PlayStation, and third preference is Gameboy. Ranking data from the second respondent might be that their preferences are PlayStation, Gameboy, and then XBOX.

I was hoping there might be able to model these ranking preferences.

I understand. This is something that would imply modeling all pairwise comparisons between options as done, for example, in the Thurstonian IRT model, or generalizations of it.

This is the natural setting for an ordered logit model, which is often described in the econometrics literature as an ordinal set of utilities. By having people rank options, you are implying they get more/less utility from higher/lower orderings.