BLP Demand Estimation with Python





GitHub Stars



Last Commit

1mo ago











|docs-badge| |pypi-badge| |downloads-badge| |python-badge| |license-badge|_

.. |docs-badge| image:: .. _docs-badge:

.. |pypi-badge| image:: .. _pypi-badge:

.. |downloads-badge| image:: .. _downloads-badge:

.. |python-badge| image:: .. _python-badge:

.. |license-badge| image:: .. _license-badge:

.. description-start

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

.. docs-start

PyBLP 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 (2020) <>_, which describes the advances implemented in the package. ::

    author = {Conlon, Christopher and Gortmaker, Jeff},
    title = {Best practices for differentiated products demand estimation with {PyBLP}},
    journal = {The RAND Journal of Economics},
    volume = {51},
    number = {4},
    pages = {1108-1161},
    doi = {},
    url = {},
    eprint = {},
    year = {2020}


The PyBLP package has been tested on Python <> versions 3.6, 3.7, and 3.8. 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 it comes packaged with the following PyBLP dependencies: NumPy <>, SciPy <>, SymPy <>, and Patsy <>. For absorption of high dimension fixed effects, PyBLP also depends on its companion package PyHDFE <>, which will be installed when PyBLP is installed.

However, PyBLP may not work with old versions of its dependencies. You can update PyBLP's Anaconda dependencies with::

conda update numpy scipy sympy patsy

You can update PyHDFE with::

pip install --upgrade pyhdfe

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 <>_.

Other Languages

Once installed, PyBLP can be incorporated into projects written in many other languages with the help of various tools that enable interoperability with Python.

For example, the reticulate <>_ package makes interacting with PyBLP in R straightforward::

pyblp <- import("pyblp")
pyblp$options$flush_output <- TRUE

Similarly, PyCall <>_ can be used to incorporate PyBLP into a Julia workflow::

using PyCall
pyblp = pyimport("pyblp")

The py command <>_ serves a similar purpose in MATLAB::



  • R-style formula interface
  • Bertrand-Nash supply-side moments
  • Multiple equation GMM
  • Demographic interactions
  • Micro moments that match demographic expectations and covariances
  • Second choice micro moments that match probabilities and covariances
  • Custom micro moments
  • Fixed effect absorption
  • Nonlinear functions of product characteristics
  • Concentrating out linear parameters
  • Normal and lognormal random coefficients
  • Parameter bounds and constraints
  • Random coefficients nested logit (RCNL)
  • Approximation to the pure characteristics model
  • Varying nesting parameters across groups
  • Logit and nested logit benchmarks
  • Classic BLP instruments
  • Differentiation instruments
  • Optimal instruments
  • Tests of overidentifying and model restrictions
  • Parametric boostrapping post-estimation outputs
  • Elasticities and diversion ratios
  • Marginal costs and markups
  • Profits and consumer surplus
  • Merger simulation
  • Custom counterfactual simulation
  • Synthetic data construction
  • SciPy or Artleys Knitro optimization
  • Fixed point acceleration
  • Monte Carlo, quasi-random sequences, quadrature, and sparse grids
  • Importance sampling
  • 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

  • Fast, "Robust," and Approximately Correct (FRAC) estimation
  • Analytic Hessians
  • Mathematical Program with Equilibrium Constraints (MPEC)
  • Generalized Empirical Likelihood (GEL)
  • Discrete types
  • Newton methods for computing equilibrium prices

Bugs and Requests

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

Rate & Review

Great Documentation0
Easy to Use0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Unwelcoming Community0