<p>In a mixed logit model, the coefficients of the logit model <span class="math-container">$\beta = (\beta_1,...,\beta_K)$</span> are assumed to be random variables. Consider, for simplicity the case where there are only two coefficients <span class="math-container">$K=2$</span>.</p>
<p>In the logit model the choice probability for alternative <span class="math-container">$j$</span> from the choice set <span class="math-container">$j \in \{1,...,J\}$</span> is given as</p>
<p><span class="math-container">$$P_j = \frac{\exp(\beta_{1j} + \beta_{2j} x_1)}{\sum_{s=1}^J \exp(\beta_{1s} + \beta_{2s} x_1)}.$$</span></p>
<p>The model therefore has relatively many parameters <span class="math-container">$J * K$</span>. Because choice alternatives are identified relative to each other only <span class="math-container">$(J-1)*K$</span> parameters are identified.</p>
<p>In the mixed logit model, the coefficients are assumed to be random. This implies that any coefficient <span class="math-container">$\beta_{kj}$</span> can be written as</p>
<p><span class="math-container">$$\beta_{kj} = \mu_{kj}+\sigma_{kj}z_{kj},$$</span></p>
<p>where <span class="math-container">$z_{kj}$</span> is the normalized draw from the relevant distribution. So if it is assumed coefficients are normally distributed then <span class="math-container">$z_{kj} \sim \mathcal N(0,1)$</span>.</p>
<p>The parameters to be estimated now include the parameters of the distribution of <span class="math-container">$\beta_{kj}$</span> which will include the location <span class="math-container">$\mu_{kj}$</span> and scale <span class="math-container">$\sigma_{kj}$</span>.</p>
<p>Here comes the really important part: Notice that</p>
<p><span class="math-container">$$\beta_{jk}x_{k} = \mu_{kj}x_k + \sigma_{kj} z_{kj} x_k,$$</span></p>
<p>now <span class="math-container">$\sigma_{kj}$</span> is estimated and if it is not significantly different from 0 you can assume that <span class="math-container">$\sigma_{kj}=0$</span> and hence</p>
<p><span class="math-container">$$\beta_{jk}x_{k} = \mu_{kj}x_k$$</span></p>
<p>which means the coefficient is non-random.</p>
<p>So one answer is that you should simply assume all coefficients are random and test whether it is the case.</p>
<p>Now, in practice, it can be very hard to estimate mixed logit models due to the many parameters being empirically unidentified. This makes it hard to test for all parameters whether they should be random or not.</p>
<p>It is therefore very often seen in applied cases where coefficients are assumed to be normally distributed that the covariances are assumed to be 0.</p>
<p>Furthermore, even in cases where the covariances are 0 still, the model can be hard to estimate. So here certain coefficients are chosen to be non-random by design. This should be based on interpretation and will therefore be context dependent - depending on the context the model is used to model.</p>
<p>Very often random coefficients are used to describe taste variation across individuals. Individual's preferences for certain alternatives are assumed to depend on <span class="math-container">$x_k$</span> and how it depends on <span class="math-container">$x_k$</span> varies from one individual to another.</p>
<p>For example, how much strawberry flavor ice cream type <span class="math-container">$j$</span> contains measured by <span class="math-container">$x_j$</span> will affect the choice of ice cream type <span class="math-container">$j$</span> differently from one individual to another. For some, it may be bad for some a good.</p>
<p>So in this case, if you do not believe different individuals have different preferences - some like strawberry some do not - then simply make the term non-random.</p>
<p>Also, note that taste variation can be modeled with observed variables by including interaction terms. Here the part <span class="math-container">$\sigma_{kj} z_{kj} x_k$</span> becomes an interaction term where <span class="math-container">$z_{kj}$</span> is observed.  Hence, the coefficients are only assumed random where there is an assumption that there exists unobserved taste variation left when all observed taste variations have been included. This obviously depends on data availability.</p>

CC BY-SA 4.0
2024-02-18T16:44:12.687Z
2024-03-17T21:46:10.863Z
2024-03-17T21:46:10.863Z
Jesper Hybel
<p>How do you decided whether to use a variable as fixed effect or random effect in mixed logit model?</p>
<p>Here, I am trying to estimate mixed logit model for discrete Choice data. X1 x2 and x3 are same for individual. They are like demographic variables. And x4, x5 and x6 varies for individual and varies by choice given. pid uniquely represent each survey respondent and gid uniquely represents each choice set.</p>
<p>mixlogit y x1 x2 x3, group(gid) id(pid) rand(x4 x5 x6 price) robust nrep(500) burn(25) difficult tech (nr 5 dfp 5)</p>
<p>In this model above I am confused how to decide which variables to use as fixed effect and which variables to use as random effects. Your suggestions are highly appreciated.</p>

CC BY-SA 4.0
2024-02-18T14:57:14.333Z
Read the book by Kenneth Train on Discrete Choice Methods ... there is a chapter on mixed logit models. It is written in a very accessible style.
Jesper Hybel
CC BY-SA 4.0
2024-02-18T15:19:35.823Z
Thank you. I will so for sure.
Dr. Banjadebaje
<logit>
Fixed Effect Vs Random Effect in Mixed Logit Model
Dr. Banjadebaje
# Fixed Effect Vs Random Effect in Mixed Logit Model

(Asked by: username_0 on 2024-02-15)

How do you decided whether to use a variable as fixed effect or random effect in mixed logit model?

Here, I am trying to estimate mixed logit model for discrete Choice data. X1 x2 and x3 are same for individual. They are like demographic variables. And x4, x5 and x6 varies for individual and varies by choice given. pid uniquely represent each survey respondent and gid uniquely represents each choice set.

mixlogit y x1 x2 x3, group(gid) id(pid) rand(x4 x5 x6 price) robust nrep(500) burn(25) difficult tech (nr 5 dfp 5)

In this model above I am confused how to decide which variables to use as fixed effect and which variables to use as random effects. Your suggestions are highly appreciated.

**Tags:** logit
> **Comments:**
> **username_1**: Read the book by Kenneth Train on Discrete Choice Methods ... there is a chapter on mixed logit models. It is written in a very accessible style.  
> **username_0**: Thank you. I will so for sure.  

---

## 1 answers

### Answer by username_1 on 2024-02-18. Score: 3

In a mixed logit model, the coefficients of the logit model $\beta = (\beta\_1,...,\beta\_K)$ are assumed to be random variables. Consider, for simplicity the case where there are only two coefficients $K=2$.

In the logit model the choice probability for alternative $j$ from the choice set $j \in \{1,...,J\}$ is given as

$$P\_j = \frac{\exp(\beta\_{1j} + \beta\_{2j} x\_1)}{\sum\_{s=1}^J \exp(\beta\_{1s} + \beta\_{2s} x\_1)}.$$

The model therefore has relatively many parameters $J \* K$. Because choice alternatives are identified relative to each other only $(J-1)\*K$ parameters are identified.

In the mixed logit model, the coefficients are assumed to be random. This implies that any coefficient $\beta\_{kj}$ can be written as

$$\beta\_{kj} = \mu\_{kj}+\sigma\_{kj}z\_{kj},$$

where $z\_{kj}$ is the normalized draw from the relevant distribution. So if it is assumed coefficients are normally distributed then $z\_{kj} \sim \mathcal N(0,1)$.

The parameters to be estimated now include the parameters of the distribution of $\beta\_{kj}$ which will include the location $\mu\_{kj}$ and scale $\sigma\_{kj}$.

Here comes the really important part: Notice that

$$\beta\_{jk}x\_{k} = \mu\_{kj}x\_k + \sigma\_{kj} z\_{kj} x\_k,$$

now $\sigma\_{kj}$ is estimated and if it is not significantly different from 0 you can assume that $\sigma\_{kj}=0$ and hence

$$\beta\_{jk}x\_{k} = \mu\_{kj}x\_k$$

which means the coefficient is non-random.

So one answer is that you should simply assume all coefficients are random and test whether it is the case.

Now, in practice, it can be very hard to estimate mixed logit models due to the many parameters being empirically unidentified. This makes it hard to test for all parameters whether they should be random or not.

It is therefore very often seen in applied cases where coefficients are assumed to be normally distributed that the covariances are assumed to be 0.

Furthermore, even in cases where the covariances are 0 still, the model can be hard to estimate. So here certain coefficients are chosen to be non-random by design. This should be based on interpretation and will therefore be context dependent - depending on the context the model is used to model.

Very often random coefficients are used to describe taste variation across individuals. Individual's preferences for certain alternatives are assumed to depend on $x\_k$ and how it depends on $x\_k$ varies from one individual to another.

For example, how much strawberry flavor ice cream type $j$ contains measured by $x\_j$ will affect the choice of ice cream type $j$ differently from one individual to another. For some, it may be bad for some a good.

So in this case, if you do not believe different individuals have different preferences - some like strawberry some do not - then simply make the term non-random.

Also, note that taste variation can be modeled with observed variables by including interaction terms. Here the part $\sigma\_{kj} z\_{kj} x\_k$ becomes an interaction term where $z\_{kj}$ is observed. Hence, the coefficients are only assumed random where there is an assumption that there exists unobserved taste variation left when all observed taste variations have been included. This obviously depends on data availability.


---

