Jonathan Elliott, Georges V. Houngbonon, Marc Ivaldi, and Paul Scott
This document describes the code used to reproduce Market Structure, Investment, and Technical Efficiencies in Mobile Telecommunications (Elliott, Houngbonon, Ivaldi, and Scott, Journal of Political Economy, 2025). This document is a subset of the full replication package read me. The full replication package is available here.
This document is organized as follows:
- Description of code to run model
- Description of code to clean data and produce paper results
- Example of how to run equilibrium simulation code (can skip to here), which can be adapted for other settings
Readers interested in computing an equilibrium given a specified market structure should consult section 3 and the notebook example_counterfactual_simulation.ipynb, which demonstrates how to compute an equilibrium.
The following Python files implement the model of supply and demand presented in the paper. There are three packages: demand, supply, and welfare, each containing several modules.
demandfunctions.py: Supplies functions that summarize demand, including market shares, elasticities, and diversion ratioscoefficients.py: Supplies functions that return demand parameters for each type of consumerdataexpressions.py: Supplies functions that return expected data consumption and expected utility derived from data consumptiondemandsystem.py: Defines a classDemandSystem, containing market data and related functionsiteration.py: Supplies functions used to solve for ξ’s quickly, adapted from PyBLP (Conlon and Gortmaker, 2020) to useautograd
costs.py: Supplies functions to back out marginal costs based on observed investment and pricing decisionsinfrastructureequilibrium.py: Computes the market equilibrium given firms’ costs, demand, bandwidth allocations, and spectral efficienciesinfrastructurefunctions.py: Describes signal quality based on investment levelspriceequilibrium.py: Describes pricing first-order conditions and elasticitiestransmissionequilibrium.py: Calculates average download speeds
welfare.py: Summarizes welfare based on prices and investment levels
Running the following files in order reproduces the paper:
msize_alt.do: Computes market sizesagg_shares.do: Constructs aggregate market shares
chset.do: Constructs the choice set
import_ookla.do: Combines speed test datasets togetherget_insee_code.py: Determines municipality from latitude-longitudeookla_quality.do: Determines average download speeds by operator-market
dbar.do: Constructs average data usage from Orange customer records
income_alt.do: Constructs income distributions
pop_dist.R: Computes population densitiesbase_stations.do: Imports coordinates of base stationsbase_stations.R: Combines population density and base station datainfrastructure_calibration.do: Constructs infrastructure data by operator-market
demand_data.do: Constructs dataset used for estimating demand
contracts_table.do: Summarizes phone contract datadata_consumption_patterns.do: Summarizes data consumption over the daycontracts_table.py: Creates phone plans tabledescriptive_graphs.py: Creates descriptive graphssummary_stats.py: Creates data summary tablesdata_consumption_patterns.py: Data consumption statistics
demand.py: Estimates demand parameters
process_demand.py: Creates tables and graphs of demand estimates
preprocess_counterfactuals.py: Constructs counterfactual simulation inputscounterfactuals.py: Runs counterfactual simulationsprocess_counterfactual_arrays.py: Constructs standard errors on counterfactual outcomes
process_counterfactuals.py: Summarizes counterfactual results
paths.py: Provides file locationsmoments.py: Lists moments used for demand estimationvariancematrix.py: Variance matrix functionsweightingmatrix.py: GMM weighting matrix functionsestimation.py: Functions to estimate demand via GMMgmm.py: GMM objective function
This package includes a notebook example_counterfactual_simulation.ipynb that shows how to:
- Compute an equilibrium in prices and infrastructure given demand, products, bandwidth, costs, and market characteristics
- Modify market structure or product offerings
- Python version: 3.9.19
- NumPy: 1.22.4
- SciPy: 1.13.1
- Pandas: 1.1.5
- Autograd: 1.3
- Matplotlib: 3.8.4
- Manually install the specified versions of the packages.
- Use
environment.ymlto create a conda environment:conda env create -n telecom_test -f environment.yml
- Use the Singularity overlay image provided in the full replication package (Linux required, details provided in the full replication package here).
Conlon, Christopher, and Jeff Gortmaker. 2020. "Best practices for differentiated products demand estimation with pyblp." The RAND Journal of Economics, 51(4): 1108–1161.