"Does Competition Really Saturate? Fixed Costs and Entry Thresholds in Bresnahan and Reiss (1991)"
Every number in the paper is produced by this package. A run writes to output/; the run behind the published numbers is kept, unchanged, in output_reference/. Every figure drawn from data is written to output/figures.
python3 scripts/master_run.pyThis reproduces the paper from the inputs shipped in input/. It takes a few hours, mostly in the constrained maximum-likelihood steps, the simulations, and the bootstrap. Use --list to see the plan, --only <stage> to run part of it, and --jobs inside individual scripts to control parallelism.
To rebuild the county panels from the Census API instead of using the shipped ones:
python3 scripts/master_run.py --with-dataOnly the data-construction scripts in scripts/01_data/ contact the Census API, and only to rebuild inputs that are already included here. Everything else runs offline.
If you do want to rebuild them, request your own key at https://api.census.gov/data/key_signup.html. It is issued immediately, but the confirmation email contains an activation link that must be clicked before the key works; until then the API answers every request with an Invalid Key page.
Supply the key either on the command line or in the environment:
python3 scripts/01_data/01_fetch_data.py --api-key YOUR_KEY
export CENSUS_API_KEY=YOUR_KEYNo API key is included in this package.
All paths below are relative to this directory, which is the root of the package.
input/
raw/ source files as downloaded
cleaned/ county panels and derived county-level inputs
src/
lib/ model.py (estimation core), paths.py, plot_style.py
tests/ regression tests for the estimation core
scripts/
01_data/ build the panels from CBP, SF3, RUCC (needs the API key)
02_functional_form/ fixed-cost functional form on BR's tire-dealer data
03_monte_carlo/ simulation evidence
04_results/ estimation, inference, diagnostics
05_figures/ figures
06_paper/ assemble the paper's tables and inline numbers
master_run.py run everything in dependency order
output/ written by a run of this package
tables/ every number reported in the paper
figures/ every figure reported in the paper
output_reference/ the run the paper's numbers were taken from
| file | contents |
|---|---|
BresnahanAndReiss1991_DATA.csv |
Bresnahan and Reiss (1991) tire-dealer sample |
ruralurbancodes2003.xls |
USDA 2003 Rural-Urban Continuum Codes |
e8089co.xls |
Census intercensal county population estimates, 1980-1990 |
cbp05us.txt |
2005 County Business Patterns, US totals by NAICS with establishment size classes |
EC0700CFRA1.zip |
2007 Economic Census Franchise Statistics |
naics_6_02.txt |
2002 NAICS six-digit titles |
naics_XXXXXX_2005.csv holds one row per county for one industry: the entry count N,
market size and demand variables, and cost shifters. base_counties.csv is the county
sample before industries are attached; county_geography.csv, national_ubiquity.csv
and establishment_turnover.csv carry county- and industry-level covariates used in the
analysis of cross-industry variation. final_industry_list.csv is the estimation sample.
All estimation goes through this module rather than being re-implemented per script. It
provides the ordered-probit log-likelihood with an analytic score, the constraint set
with analytic Jacobians, standard errors (observed information, outer product of
gradients, and a cluster-robust sandwich), profile likelihoods, and a parametric
bootstrap. Spec selects the fixed-cost form (step, log, power), the covariates
entering V, F and S, and which restrictions are imposed.
Run the regression tests with:
python3 src/tests/test_model.pyFiles named paper_tableN_*.csv correspond one-to-one with the numbered tables in the paper and are already in the shape they are typeset in. paper_numbers.csv holds every figure quoted inline in the text, as name, value and source. The remaining files are the full estimation output those two are built from.
The numbers printed in the paper are the ones in output_reference/, produced on the author's machine. A fresh run writes to output/ and leaves output_reference/ untouched.
Every source of randomness is seeded, and the seeds are stable across machines and across runs, so the simulated data are identical wherever the package is run. What differs is the constrained optimizer. The estimation problem has inequality constraints whose geometry is near-parallel at the optimum in some industries, and the linear-algebra libraries underneath SciPy differ across platforms in the last bits. A search that ends at the boundary can therefore stop at a slightly different point, or fall back to the interior-point stage where another machine used sequential quadratic programming.
Python 3.10 or later (3.12 used in development), with numpy, scipy, pandas,
matplotlib and requests. openpyxl and xlrd are needed for the .xls inputs.
mpmath is optional and used by one regression test.