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.

Citation

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.

Installation

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.

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:

library(reticulate)
pyblp <- import("pyblp")

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:

py.pyblp

Features

  • R-style formula interface

  • Bertrand-Nash supply-side moments

  • Multiple equation GMM

  • Demographic interactions

  • Micro moments that match product and agent characteristic covariances

  • Fixed effect absorption

  • Nonlinear functions of product characteristics

  • Concentrating out linear parameters

  • Parameter bounds and constraints

  • Random coefficients nested logit (RCNL)

  • 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, 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

  • Other 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.

Source Distribution

pyblp-0.8.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyblp-0.8.1-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file pyblp-0.8.1.tar.gz.

File metadata

  • Download URL: pyblp-0.8.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for pyblp-0.8.1.tar.gz
Algorithm Hash digest
SHA256 f903f1ad4d75e08e0a8834ac1e4095d8182acf95abd8c20546d780a4d83fd082
MD5 b743b34c200299c740194f47b58bbd9d
BLAKE2b-256 44e039ba85aec8c07d74a4e776e196c3fd1e6f0eafdc9e4cb0b91abe78729e00

See more details on using hashes here.

File details

Details for the file pyblp-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: pyblp-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for pyblp-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab4cddc6ce677527e4c46c985c643d6ec966e135bff3b823a4ca14a86447c3b
MD5 c1fcad14df2400c4413aa1a7de90e9a5
BLAKE2b-256 cb686f2b2f8ac1c77f27e22d83093fb451d24e9910ddf540b4c0a4749a545c8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page