Skip to main content

FRAC estimation for macro-BLP models

Project description

frac_blp

FRAC for macro-BLP (Salanie-Wolak).

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 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 markets
  • J: 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: a N-vector of market shares.

  • the regressors as a Pandas data frame with N rows. 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 in names_X1_exo
    • X1_endo, the matrix of endogenous variables with fixed coefficients, using the column names in names_X1_endo
    • X2_exo, the matrix of exogenous variables with fixed coefficients, using the column names in names_X2_exo
    • X1_endo, the matrix of endogenous variables with fixed coefficients, using the column names in names_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 coefficients X1_exo, X1_endo and the mean coefficients on the variables with random coefficients X2_exo, X2_endo, in that order.
  • sigmas: the standard deviations of the coefficients on the variables with random coefficients X2_exo and X2_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=d is provided, then all interactions of the columns of Z up to degree d will be used as instruments.
  • if degree_X1=d' is provided, then all interactions of the columns of X1_exo up to degree d' will also be used, on their own and multiplied by the interactions of Z.

The default has degree_Z=2 and degree_X1=2.

Release notes

0.3 (November 67, 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.

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

frac_blp-0.3.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

frac_blp-0.3.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file frac_blp-0.3.0.tar.gz.

File metadata

  • Download URL: frac_blp-0.3.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.1

File hashes

Hashes for frac_blp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 26c21247fcceb6f45dc7b1f84bcfd83c912940ff4c8cf7fefaaea0c31308b781
MD5 47fe49e912ecc5584e378a22ab4b449f
BLAKE2b-256 1132b46dad8060fea37ceb621dee32313164f974c7b400494357fbf3e835859c

See more details on using hashes here.

File details

Details for the file frac_blp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: frac_blp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.1

File hashes

Hashes for frac_blp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f22fd75f607441b38ef76a3897b759da501e92e7c1d5c94da2cdc468f1c40455
MD5 a9662201f3c85845b09beb0d64bd26e6
BLAKE2b-256 2257fae685a04c3d95aa69c002535933e7df84a008b267d68d48e4f797946d95

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