Examined Algorithms
  • Writing
  • Open Source Projects
  • Talks
  • CV

Bayesian Mixed Logit in PyMC Marketing

utility
consumer choice
causal inference
Author

Nathaniel Forde

Published

January 20, 2026

Abstract
Bayesian Estimation of Mixed Logit Discrete Choice Model

Mixed Logit Choice Models for Consumer Choice

This addition completes the core discrete-choice toolkit, sitting alongside:

  • Multinomial Logit
  • Nested Logit
  • Mixed Logit (new)

The implementation supports:

  • ✅ Individual-level preference heterogeneity via hierarchical random coefficients
  • ✅ Panel data with group-level effects
  • ✅ Non-centered parameterizations for better sampling
  • ✅ Control-function correction for price endogeneity using instruments
  • ✅ Full posterior & counterfactual simulation for policy and pricing interventions
  • ✅ Wilikinson Style Formula interface

Mixed logit is the workhorse model behind modern preference estimation, WTP analysis, and market simulations — and it’s now fully Bayesian, transparent, and extensible in PyMC.

The latent utility for alternative \(j\) is

\[ U_{njt} = \underbrace{ \boldsymbol{\alpha} }_{\text{alt-specific fixed effects}} + \underbrace{ \mathbf{x}_{njt}^\top \boldsymbol{\beta}_n }_{\text{alt-specific random effects}} + \underbrace{ \mathbf{z}_{n}^\top \boldsymbol{\gamma}_j }_{\text{individual-specific effects}} + \overbrace{ \underbrace{ \mathbf{r}_{njt}^\top \boldsymbol{\lambda_{cf}} }_{\text{control function}} }^{\text{optional endogeneity correction}} + \varepsilon_{njt} \]