How to estimate markups and production functions?
(using The Hitchhiker's Guide to Markup Estimation: Assessing Estimates from Financial Data joint with Maarten De Ridder and Giovanni Morzenti)We provide Python code to estimate production functions and firm-level markups from firm-level income statements. The code implements the algorithm described in the appendix of The Hitchhiker's Guide to Markup Estimation: Assessing Estimates from Financial Data
In the code that can be downloaded here, we reproduce the estimation of markup and the underlying production function coefficients from:
The Rise of Market Power and the Macroeconomic Implications, De Loecker, Eeckhout, and Unger, The Quarterly Journal of Economics, Volume 135, Issue 2, May 2020, Pages 561–644, https://doi.org/10.1093/qje/qjz041
We believe that this code is easy to use and to apply to different firm-level datasets.
Citation suggestion:
De Ridder, Grassi, and Morzenti (2024), DP17532, "The Hitchhiker’s Guide to Markup Estimation: Assessing Estimates from Financial Data", CEPR Discussion Paper No. 17532. CEPR Press, Paris & London. https://cepr.org/publications/dp17532
The Code and How to Use it
Code structure
The zip file contains:
a readme file
ProdFun_VPublic.py: a Python code that contains the production function estimation class.
Clean_Data.do: stata script which cleans the Compustat data.
Run_Compustat_VPublic.py: a Python code that estimates the production function and markup on Compustat data.
DEFL_Y.dta: a stata dataset that contains some deflators.
Note: you will need to bring your Compustat data
How does it work?
First, run the Clean_data.do in your Stata, after changing some path. This will compute the cleaned dataset COMPUSTAT_clean.csv.
Second Run_Compustat_VPublic.py with your python. This will perform the estimation and save the firm-level markups in Compustat_Markups_Python_V1.dta and the production function coefficients in the Stata datasets Compustat_Betas_Python_V1.dta and Compustat_BetasRoll_Python_V1.dta. The class ProdFun_VPublic.py allows for many different options that are explained directly in the script.
Our code produces the figure below that plots sales-weighted average markup. The times series for the average markups below can be downloaded here. The estimates from the original paper can be downloaded here from Jan De Loecker's website.