blprs
Fast Berry–Levinsohn–Pakes (BLP) estimation for random coefficients logit models, written in Rust. The goal of blprs is to provide a feature-complete and performant alternative to pyBLP, accompanied by rich inline documentation and an ergonomic Rust-first API.
⚠️ This is an early preview. The demand-side estimator is implemented, but advanced functionality (supply, optimal instruments, bootstrapping, simulation aides, and the full suite of
pyBLPconveniences) is still under construction.
Highlights
- idiomatic Rust translation of the core BLP demand estimator: product data validation, simulation draws, contraction mapping, and two-step GMM.
- ready-to-read inline documentation and unit tests that mirror
pyBLPnotebooks. - modular architecture prepared for supply-side extensions, optimal instruments, and equilibrium pricing models.
- no
unsafecode; builds onnalgebra,rayon, andserde.
Getting started
Add the crate once it is published:
For now, use a Git dependency while the crate incubates:
[]
= { = "https://github.com/eam398/blprs" }
Example
use ;
use ProductDataBuilder;
use SimulationDraws;
use ;
let market_ids = vec!;
let shares = from_vec;
let x1 = from_row_slice;
let x2 = from_row_slice;
let products = new
.x1
.x2
.build
.expect;
let draws = standard_normal;
let problem = builder
.products
.draws
.options
.build
.unwrap;
let sigma = from_row_slice;
let options = default
.with_contraction
.with_weighting;
let result = problem.solve_with_options.unwrap;
println!;
println!;
API surface
data: builders and validation for product-level matrices (X1, X2, instruments).integration: Monte Carlo draws with shape checking and seeded reproducibility.demand: share prediction and the BLP contraction mapping.solving: solver configuration and diagnostics.estimation: high-levelBlpProblemwrapper that mirrorspyblp.Problemfor the demand side.
Roadmap
- Implement supply-side marginal cost recovery and equilibrium pricing.
- Add optimal instrument routines and support for demographic heterogeneity.
- Provide full pyBLP-style convenience APIs (formulations, problems, counterfactuals).
- Publish crate releases, CI, benchmarks, and docs.rs integrations.
Contributions and feature requests are welcome via pull requests or GitHub discussions.
Development
License
Licensed under the MIT License. See LICENSE for details.