frac_blp
FRAC for macro-BLP (Salanie-Wolak).
- Github repository: https://github.com/bsalanie/frac-blp/
- Documentation https://bsalanie.github.io/frac-blp/
Overview
The package estimates a second-order approximation to the macro BLP model with random coefficients using the FRAC method of Salanie and Wolak.
At this early stage, the package only implements the basic version of the model without demographics. The random coefficients are assumed to be independently distributed.
The user should be familiar with the macro BLP model (Berry, Levinsohn, and Pakes, 1995). We use very similar notation to that of Conlon and Gortmaker in their pyblp package.
The inputs are:
T: the number of marketsJ: the number of products per market
The data must contain N=T*J observations, corresponding to all products in all markets.
The observations should be ordered by market, i.e., the first J rows correspond to market 1, the next J rows to market 2, etc.
The user must provide the following data matrices:
-
Z: a matrix of instruments, to which the program will add a constant -
shares: aN-vector of market shares. -
the regressors as a Pandas data frame with
Nrows. The program will construct the following Numpy matrices from the data frame:X1_exo, the matrix of exogenous variables with fixed coefficients, using the column names innames_X1_exoX1_endo, the matrix of endogenous variables with fixed coefficients, using the column names innames_X1_endoX2_exo, the matrix of exogenous variables with fixed coefficients, using the column names innames_X2_exoX1_endo, the matrix of endogenous variables with fixed coefficients, using the column names innames_X2_endo.
names_X1_exo, names_X1_endo, names_X2_exo, names_X2_endo are lists of strings provided by the user with the names of the columns in the data frame corresponding to each of these four types of variables.
A constant term will not be added automatically, so if desired the user must include a column of ones in X1_exo and/or X2_exo.
X2_exo must be a subset of X1_exo, and X2_endo must be a subset of X1_endo (i.e., all variables with random coefficients must also have fixed coefficients). Any of these four matrices can be None if there are no variables of that type.
The outputs are:
betas: the estimates on the variables with fixed coefficientsX1_exo,X1_endoand the mean coefficients on the variables with random coefficientsX2_exo,X2_endo, in that order.sigmas: the standard deviations of the coefficients on the variables with random coefficientsX2_exoandX2_endo, in that order.
entering the data
The data must first be entered into a FracNodemogRealData object:
from frac blp.frac classes import FracNodemogRealData
frac data = FracNodemogRealData(T, J,
names_X1_exo,
names_X1_endo,
names_X2_exo,
names_X2_endo,
df_X1,
Z,
shares,
)
Then the model can be estimated with:
from frac_blp.frac_nodemog import estimate
betabar, sigmas = frac nodemog estimate(frac data)
frac_demog_estimate also has optional arguments to define the combinations of instruments and exogeneous variables to be used in the first stage:
- if
degree_Z=dis provided, then all interactions of the columns ofZup to degreedwill be used as instruments. - if
degree_X1=d'is provided, then all interactions of the columns ofX1_exoup to degreed'will also be used, on their own and multiplied by the interactions ofZ.
The default has degree_Z=2 and degree_X1=2.
Release notes
0.4 (June 1, 2026)
Added higher-order regressors (not used for estimation yet).
0.3 (November 7, 2025)
Improved interface for data input. Still no demographics.
0.2 (October 27, 2025)
Improved README.
0.1 (October 26, 2025)
First working version, no demographics.
Metadata
Release files for frac-blp 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| frac_blp-0.4.0.tar.gz | 15.5 kB | Without provenance | Details for frac_blp-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| frac_blp-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for frac_blp-0.4.0-py3-none-any.whl |
Total release size: 30.2 kB
Release files / frac_blp-0.4.0.tar.gz
| Download URL | frac_blp-0.4.0.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6d6b1d7562b88b49e34cc2f1482ec673e31e13743b9455596733b7491cd832f
|
|
BLAKE2b-256 checksum How to use checksums |
a27d557b6c0e32c5d282a0ea1df7a466cfeb73a4af0f6b55ee7a99a1760ceae4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / frac_blp-0.4.0-py3-none-any.whl
| Download URL | frac_blp-0.4.0-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fa8b95853cc3e48839f06292aa7c27e1ed030f98a7aef7449fb866eeddfcedd
|
|
BLAKE2b-256 checksum How to use checksums |
6d992b688988ed900e618b02534ff8a828c4d45d8240409870f7c2d9dfa93d37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for frac-blp 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.