Categorical choice model with panel data

I’d like to kindly ask you for your help with application of categorical choice model on panel data in brms.

As an example let’s suppose that consumers (i) enter a store and can choose one brand of cereal. Let’s say that consumers weigh up the nutrition, price and advertising that each brand has received when making their decision and we want to know what weights they put on each. (ii) Each consumer can visit store several times over time, thus she/he faces {1,…,n} choice occasions. On each store visit (choice occasion), she/he choses one brand and offered brands (choice set) don’t vary. Please find below example of a dataset:

consumer brand choice occasion choice nutrition price advertising
1 kellogs 1 1 2 5 0,9
1 general mills 1 0 4 5 0,3
1 walmart own brand 1 0 1 1 0
1 kellogs 2 0 2 5 0,9
1 general mills 2 0 4 5 0,3
1 walmart own brand 2 1 1 1 0
2 kellogs 1 0 2 5 0,9
2 general mills 1 1 4 5 0,3
2 walmart own brand 1 0 1 1 0

For instance, consumer 1 went to the store twice and she/he chose kellogs on the first visit and walmart own brand on the second visit. Consumer 2 went to the store once and she/he chose general mills.

Would it be possible to estimate multinomial logit with random intercepts for brands, but also random intercepts for individual consumers in this case with brms please? Is there any example or description how to structure dataset that feeds into this model please? (For instance, with ChoiceModelR, it needs to be formatted very specifically - data needs to be in long format, alternatives need to be integers, choice needs to be stored on the first row for each choice occasion, etc. Unfortunately, I couldn’t find any similar description/dataset example for brms.)

Thank you very very much for any advice. I have read the vignettes and tried to search for this issue extensively and I’m really sorry if I’m overlooking something.

The tricky thing it to set up the conditional logit model as described in the github issue you have linked to.
The example, I provided there was

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

bform <- 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),
  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")
bprior <-  set_prior("normal(0, 5)", nlpar = nlpars)

fit <- brm(formula = bform, data = Fishing, 
           prior = bprior, chains = 2, cores = 2)

We can readily extend such example to model varying effects on the non-linear parameters. For example, bpier ~ (1 | consumer) instead of bpier ~ 1.

The support of conditional logit models in brms is currently quite hacky (as you see above) so don’t expect things to work super smoothly.