# How can I create a multivariable Logistic regression model and use brms to make responses correlatted？

**URL:** <https://discourse.mc-stan.org/t/how-can-i-create-a-multivariable-logistic-regression-model-and-use-brms-to-make-responses-correlatted/31945>\
**Category:** brms\
**Created:** [July 1, 2023, 1:41pm UTC](https://discourse.mc-stan.org/t/how-can-i-create-a-multivariable-logistic-regression-model-and-use-brms-to-make-responses-correlatted/31945 "2023-07-01T13:41:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zijun](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zijun](https://discourse.mc-stan.org/u/zijun)\
**Post date:** [July 1, 2023, 1:41pm UTC](https://discourse.mc-stan.org/t/how-can-i-create-a-multivariable-logistic-regression-model-and-use-brms-to-make-responses-correlatted/31945/1 "2023-07-01T13:41:52Z")

</div>

How can I create a multivariable Logistic regression model and use brms to make responses correlated？

For example, there are three alternatives for urban residents’ travel: car, bus, and subway. Therefore, I would like to use age, gender, and travel distance as independent variables, and region as grouping factor. How can I model these three alternatives as relevant?

the basic brms formular：  
model= brm(choice ~ age+ gender+travel\_distance+(1| region), data=data, family=‘categorical’)

I don’t know how to change this model to one with responses correlated.

---

<div class="post-metadata">

**Author:** ![franzsf](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/franzsf/32/8545_2.png) [@franzsf](https://discourse.mc-stan.org/u/franzsf)\
**Post date:** [July 1, 2023, 3:14pm UTC](https://discourse.mc-stan.org/t/how-can-i-create-a-multivariable-logistic-regression-model-and-use-brms-to-make-responses-correlatted/31945/2 "2023-07-01T15:14:00Z")

</div>

Brms does have some capability in conditional logit models through the nlf syntax. See:

> <https://github.com/paul-buerkner/brms/issues/560>
>
> Following up on https://twitter.com/paulbuerkner/status/1067809413581414401 
> 
> …It would be great it BRMS could support conditional logit models. They are used in a lot of places, such as analyzing conjoint experiments, purchase decisions or voting behavior. 
> 
> As an example let's suppose that consumers (i) enter a store and can choose one brand of cereal. Different stores have different inventory at different times so the choice set is not always the same. We'll 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. The data might look something like:
> 
> !\[image\](https://user-images.githubusercontent.com/11521792/49165928-54058e80-f300-11e8-8340-48d8c5db6b1c.png)
> 
> They're definitely possible in Stan in some form:
> https://www.rdocumentation.org/packages/rstanarm/versions/2.17.4/topics/stan\_clogit
> 
> Here's the original McFadden paper on the models:
> https://eml.berkeley.edu/reprints/mcfadden/zarembka.pdf
> 
> I think the key extra piece of information that needs to be given is an identifier that defines one choice situation.
> 
> brm(formula = choice|chid(consumer) ~ price + nutrition + advertising)
> 
> we might then imagine that older people are more susceptible to advertising so we would interact age and advertising
> 
> brm(formula = choice|chid(consumer) ~ price + nutrition + advertising:age + advertising)
> 
> or that the slope of advertising varies across states:
> 
> brm(formula = choice|chid(consumer) ~ price + nutrition + advertising + (1+advertising|state), data)
> 
> I wonder if we could also have brand (i.e. particular choice) specific random intercepts:
> brm(formula = choice|chid(consumer) ~ price + nutrition + advertising + (1|brand), data)

---

<div class="post-metadata">

**Author:** ![zijun](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zijun](https://discourse.mc-stan.org/u/zijun)\
**Post date:** [July 2, 2023, 1:58pm UTC](https://discourse.mc-stan.org/t/how-can-i-create-a-multivariable-logistic-regression-model-and-use-brms-to-make-responses-correlatted/31945/3 "2023-07-02T13:58:39Z")

</div>

Thanks！ It is very useful.
