Skip to main content

BLP demand estimation with Python 3

Project description

An overview of the model, examples, references, and other documentation can be found on Read the Docs.

The pyblp package is a Python 3 implementation of routines for estimating the demand for differentiated products with BLP-type random coefficients logit models. This package was created by Jeff Gortmaker in collaboration with Chris Conlon.

Development of the package has been guided by the work of many researchers and practitioners. For a full list of references, including the original work of Berry, Levinsohn, and Pakes (1995), refer to the references section of the documentation.


If you use pyblp in your research, we ask that you also cite Conlon and Gortmaker (2019), which describes the advances implemented in the package.


The pyblp package has been tested on Python versions 3.6 and 3.7. The SciPy instructions for installing related packages is a good guide for how to install a scientific Python environment. A good choice is the Anaconda Distribution, since, along with many other packages that are useful for scientific computing, it comes packaged with pyblp’s only required dependencies: NumPy, SciPy, SymPy, and Patsy.

However, pyblp may not work with old versions of its dependencies. You can update pyblp’s dependencies in Anaconda with:

conda update numpy scipy sympy patsy

You can install the current release of pyblp with pip:

pip install pyblp

You can upgrade to a newer release with the --upgrade flag:

pip install --upgrade pyblp

If you lack permissions, you can install pyblp in your user directory with the --user flag:

pip install --user pyblp

Alternatively, you can download a wheel or source archive from PyPI. You can find the latest development code on GitHub and the latest development documentation here.


  • R-style formula interface
  • Bertrand-Nash supply-side moments
  • Multiple equation GMM
  • Demographic interactions
  • Fixed effect absorption
  • Nonlinear functions of product characteristics
  • Concentrating out of linear parameters
  • Parameter bounds and constraints
  • Random coefficients nested logit (RCNL)
  • Varying nesting parameters across groups
  • Logit and nested logit benchmarks
  • Classic BLP instruments
  • Optimal instruments
  • Elasticities and diversion ratios
  • Marginal costs and markups
  • Profits and consumer surplus
  • Merger simulation
  • Parametric boostrapping of post-estimation outputs
  • Synthetic data construction
  • SciPy or Artleys Knitro optimization
  • Fixed point acceleration
  • Monte Carlo, product rule, or sparse grid integration
  • Custom optimization and iteration routines
  • Robust and clustered errors
  • Linear or log-linear marginal costs
  • Partial ownership matrices
  • Analytic gradients
  • Finite difference Hessians
  • Market-by-market parallelization
  • Extended floating point precision
  • Robust error handling

Features Slated for Future Versions

  • Micro moments
  • Fast, “Robust,” and Approximately Correct (FRAC) estimation
  • Analytic Hessians
  • Mathematical Program with Equilibrium Constraints (MPEC)
  • Generalized Empirical Likelihood (GEL)
  • Discrete types
  • Pure characteristics model
  • Newton methods for computing equilibrium prices

Bugs and Requests

Please use the GitHub issue tracker to submit bugs or to request features.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyblp-0.7.0-py3-none-any.whl (1.1 MB) Copy SHA256 hash SHA256 Wheel py3
pyblp-0.7.0.tar.gz (1.4 MB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page