Estimation Code

Python estimation code for flexible Latent Class Choice Models (LCCMs)

LCCM is a Python package for estimating latent class choice models using the Expectation Maximization (EM) algorithm to maximize the likelihood function. The package was developed by Feras El Zarwi, a PhD candidate at the University of California, Berkeley, with assistance from Akshay Vij from the Institute for Choice. The package offers significant improvement over other estimation packages, some of which are listed below:

  • Supports datasets with multiple observations per decision-maker
  • Supports datasets where the choice set differs across observations
  • Supports model specifications where the coefficient for a given variable may be generic (same coefficient across all alternatives) or alternative specific (coefficients varying across all alternatives or subsets of alternatives) in each latent class
  • Accounts for sampling weights in case the data you are working with is choice-based i.e. Weighted Exogenous Sample Maximum Likelihood (WESML) from (Ben-Akiva and Lerman, 1983) to yield consistent estimates
  • Constrains the choice set across latent classes whereby each latent class can have its own subset of alternatives in the respective choice set
  • Constrains the availability of latent classes to all individuals in the sample whereby it might be the case that a certain latent class or set of latent classes are unavailable to certain decision-makers

For more information about the estimation code, see El Zarwi (2017). If the package is useful in your research or work, please cite the dissertation reference before and the package itself. For any questions, please contact Feras at


El Zarwi, Feras. "Modeling and Forecasting the Impact of Major Technological and Infrastructural Changes on Travel Demand", PhD Dissertation, 2017, University of California at Berkeley.

Areas of study and research

+ Click to minimise