Analyzing Microeconomic Data
Given a dataset and an economic question, follow this pipeline:
Pythonimport pandas as pd import statsmodels.formula.api as smf # 1. Frame the question as a theoretical model # e.g., "Does a price increase reduce quantity demanded, controlling for confounders?" df = pd.read_csv("sales_data.csv") # 2. Specify the econometric model implied by theory model = smf.ols("log_quantity ~ log_price + income + C(region) + C(month)", data=df).fit( cov_type="cluster", cov_kwds={"groups": df["firm_id"]} ) # 3. Interpret coefficients as elasticities, test theoretical predictions print(model.summary()) elasticity = model.params["log_price"] print(f"Price elasticity of demand: {elasticity:.3f}")
Report the estimate, its confidence interval, and whether it's consistent with theoretical priors (e.g., negative own-price elasticity, expected magnitude relative to substitutes).
Progress:
- Step 1: Define the economic question and relevant theory (consumer theory, producer theory, game theory, market structure)
- Step 2: Identify the causal/structural target (elasticity, marginal cost, treatment effect, equilibrium price)
- Step 3: Assess data — cross-section, panel, time series; identify sources of endogeneity
- Step 4: Choose identification strategy (RCT, IV, RDD, diff-in-diff, panel fixed effects, structural estimation)
- Step 5: Specify and estimate the model
- Step 6: Run diagnostics (heteroskedasticity, multicollinearity, weak instruments, parallel trends)
- Step 7: Interpret results economically — sign, magnitude, statistical AND economic significance
- Step 8: Stress-test with robustness checks (alternative specifications, subsamples, placebo tests)
- Step 9: Communicate findings with policy/business implications, not just coefficients
Step 1-2: Theory-first framing
Never jump straight to regression. Ask: what does economic theory predict, and what parameter answers the question? Examples:
- Demand estimation → own-price and cross-price elasticities
- Labor economics → wage elasticity of labor supply
- Market power → markup, Lerner index, conduct parameter
- Policy evaluation → average treatment effect (ATE) or local ATE
Step 3-4: Identification strategy selection
| Data structure | Endogeneity concern | Preferred method |
|---|---|---|
| Natural experiment / policy cutoff | Selection at threshold | Regression discontinuity |
| Panel with staggered treatment | Time-invariant confounders | Fixed effects / diff-in-diff |
| Cross-section with instrument | Simultaneity (price & quantity) | 2SLS / IV |
| Observational, rich covariates | Selection on observables | Matching / propensity scores, double ML |
| Market-level data | Strategic interaction | Structural IO models (BLP, conduct-parameter) |
Always state the identifying assumption explicitly (exclusion restriction, parallel trends, no anticipation, etc.) — it's the weakest link and reviewers/stakeholders will ask.
Step 5-6: Estimation and diagnostics
- Cluster standard errors at the level of treatment assignment or economic decision-making unit.
- Test instrument strength (first-stage F > 10 rule of thumb) for IV.
- Check parallel pre-trends visually and statistically for diff-in-diff.
- Test bandwidth sensitivity for RDD.
Step 7-9: Interpretation and communication
Translate coefficients into economically meaningful units (dollars, percentages, elasticities), not just p-values. State the economic significance separately from statistical significance.
Example 1: Input: "We raised prices 10% in half our stores last quarter. Did it hurt sales?" Output:
- Frame as a natural experiment → diff-in-diff between treated and control stores
- Check parallel trends pre-intervention
- Estimate:
log_sales ~ treated * post + C(store) + C(month) - Interpretation: coefficient on
treated:post= -0.045 → 4.5% relative sales decline, implying price elasticity ≈ -0.45 (inelastic demand), i.e., revenue increased despite volume loss.
Example 2: Input: "Estimate the market power of firms in this industry using price-cost margin data." Output:
- Use conduct-parameter / Lerner index approach: (P - MC)/P
- Estimate MC via cost function or supply-side residual from a structural demand system (e.g., BLP)
- Report implied markups and compare to perfect competition (0) and monopoly benchmarks
- Flag if the model assumes Bertrand vs Cournot conduct, since conclusions are conduct-dependent
- Always state the causal question in words before writing code.
- Prefer transparent, well-identified quasi-experimental designs over black-box ML when the question is causal.
- Use ML (regularization, tree-based methods) for prediction and heterogeneity discovery (e.g., causal forests), not for asserting causal effects without a design.
- Report both point estimates and confidence intervals; avoid over-reliance on p < 0.05 thresholds.
- Pre-register or clearly separate exploratory from confirmatory analysis.
- Sanity-check estimates against theoretical bounds (e.g., elasticities should rarely exceed |10|; markups should be non-negative).
- Running a regression without an explicit identification strategy and calling the coefficient "causal."
- Ignoring clustering/correlation structure in standard errors, leading to false precision.
- Confusing statistical significance with economic significance (a precisely estimated near-zero effect is still near zero).
- Extrapolating elasticities/effects outside the range of observed data variation.
- Using structural model results without checking if functional form/behavioral assumptions (utility, cost function) are reasonable for the context.
- Overfitting flexible ML models to observational data and mistaking predictive accuracy for causal validity.