Skip to content
Module 13 of 2155 min readBeginner

AI-assisted econometrics

Use AI to understand models, debug code, and interpret results — without letting its false confidence smuggle in a causal claim you can't defend.

62%

Listen along

Read “AI-assisted econometrics” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Learning objectives

By the end of this module, you should be able to:

  • 01Use AI as an on-demand tutor for fixed effects, instrumental variables, difference-in-differences and clustered standard errors, and sanity-check what it tells you
  • 02Get AI to read a regression table in plain English without letting it invent the causal story
  • 03Debug Stata, R and Python faster by handing AI the exact error, the data shape and your intent - then verifying the fix does what you meant
  • 04Name the five ways AI misleads on causality, and keep the identification strategy and the causal claim yours to defend

Econometrics is where AI's false confidence is most dangerous. A large language model will explain heteroskedasticity-robust standard errors flawlessly, then in the very next sentence tell you your cross-sectional OLS 'shows that schooling causes higher wages' - and say it with exactly the same calm authority. The deal for this module is simple: AI is an outstanding tutor and a fast pair of hands for drafting and debugging, but the identification strategy and the causal claim are yours to defend - at the seminar, in the referee report, and in front of the National Treasury. Use it to understand and to build. Never use it to decide what your coefficients mean.

The tutor that never sleeps

The single highest-value use of AI for an applied economist is on-demand tutoring. Fixed effects, instrumental variables, difference-in-differences, clustered versus robust standard errors, the Frisch-Waugh-Lovell theorem - you can ask for the intuition, a worked example, and the assumption each method rests on, then keep asking until it clicks. Treat it Socratically: ask 'explain it again as if I have never seen matrix algebra', then 'now show me the exact case where this method fails'. The failure case is the part a textbook buries and the part you actually need before you stake a policy brief on it.

text
You are a patient graduate econometrics tutor. Explain entity fixed effects to me in three passes:
1. The one-sentence intuition.
2. A worked example using Kenyan county panel data (47 counties, 2013-2023) predicting health spending, where county fixed effects absorb time-invariant county characteristics.
3. The single most important source of confounding that fixed effects CANNOT remove - be specific about what survives the within transformation.
Finish by stating the exact assumption I am relying on when I claim the within-county estimate is causal.

Reading a regression table in plain English

Paste a regression output and ask for a plain-language reading - AI is genuinely good at this, and it is faster than re-deriving what each column means. But bolt on a guardrail, because left to itself it will narrate your table as a causal story. Tell it explicitly to describe associations rather than effects; to state the identifying assumptions each coefficient would need before it could carry a causal reading; and to flag anything that looks read off the table wrongly. You are commissioning a translation, not a verdict.

text
Below is Stata output from a regression of log monthly wages on years of schooling and controls, estimated on KNBS labour-force cross-section data.
[paste the table]
Explain each coefficient in plain English for a policy audience. Rules:
- Describe these as ASSOCIATIONS, not causal effects. Do not use the words 'causes', 'leads to' or 'raises' about any coefficient.
- For the schooling coefficient, list the identifying assumptions I would need before a causal reading is defensible, and why each is doubtful in a cross-section.
- State what the standard errors are clustered on, if anything, and whether that is appropriate here.
- Flag any coefficient whose sign or magnitude looks suspicious, and say why.

A sounding board for identification: it suggests, you decide

When you are choosing an identification strategy, AI is a useful sounding board. Describe your question, your data and the variation you can exploit, and it will float candidates - panel fixed effects, an instrument, difference-in-differences around a policy change, a regression discontinuity at an eligibility cut-off. That is where its authority ends. Whether an instrument satisfies the exclusion restriction, whether parallel trends is credible for your NHIF roll-out, whether SUTVA survives spillovers between neighbouring counties - those are judgements about the world that only you can defend. The productive move is to make the model argue against itself: it proposes a strategy, then you order it to attack that strategy as a hostile referee.

text
Act as a hostile seminar discussant and referee. Do not be encouraging; your job is to find every reason this design fails.
My question: does access to mobile money (M-PESA) raise household consumption in rural Kenya?
My strategy: instrument household M-PESA use with distance to the nearest agent, in a 2SLS regression on cross-sectional household data, with county fixed effects and controls.
Attack this identification strategy specifically:
1. State the exclusion restriction in words. Give me three concrete channels through which distance-to-agent could affect consumption OTHER than through M-PESA use.
2. Is agent placement plausibly as-good-as-random, or is it endogenous to local wealth and infrastructure? What does that do to the instrument?
3. If the exclusion restriction fails in the direction you think most likely, which way does my estimate get biased, and roughly how much should I worry?
4. List the diagnostics you would demand (first-stage F-statistic, over-identification tests) and tell me which are NOT available given I have a single instrument.
Do not propose any fixes until you have listed every threat.

Debugging Stata, R and Python

For debugging statistical code, AI is a large accelerant. Give it three things: the exact error message, the shape of your data (variables, types, panel structure), and what you were trying to do. Paste a minimal reproducible example, not your whole 400-line do-file. It will usually spot the mismatch faster than you will. The discipline is verification - read the fix and confirm it does what you meant: that it clusters at the level you intended, absorbs the fixed effects you wanted, and has not silently dropped half your sample through a listwise deletion you never noticed.

r
# BUG: my clustered SEs come out identical to the default ones - what went wrong?
library(plm)
m <- plm(log_wage ~ educ + exper, data = d, model = "within",
index = c("id", "year"))
summary(m) # this prints DEFAULT (non-robust) standard errors
# WHY: the within transformation sweeps out the fixed effects; it does NOT cluster
# the standard errors. plm's summary() still reports classical SEs, so no clustering
# has actually happened. A good AI answer should catch this - a bad one will invent
# a phantom 'cluster = TRUE' argument that plm does not have.
# FIX: request a clustered variance-covariance matrix explicitly, then re-test.
library(lmtest); library(sandwich)
coeftest(m, vcov = vcovHC(m, type = "HC1", cluster = "group")) # cluster by panel id

Five ways AI fools econometricians

  • Correlation dressed as causation. Given any regression, AI will cheerfully narrate coefficients as effects - 'an extra year of schooling raises wages by 12%' - with nothing identifying the verb 'raises'.
  • Invented diagnostics. It will confidently cite a test that does not apply to your setting, or reach for a Hausman or Durbin-Wu-Hausman test where it is not identified, complete with a plausible-looking interpretation of the number.
  • P-value misstatement. It will tell you p = 0.03 means 'a 3% chance the result is due to chance' or 'a 97% chance the effect is real'. Both are wrong, and it will not warn you.
  • Endogeneity ignored. Ask it to interpret an OLS on observational data and it will reach straight for a causal reading, never raising omitted-variable bias, simultaneity or measurement error unless you force it to.
  • P-hacked storytelling. Feed it a table with fifteen coefficients and it will assemble a tidy narrative around the three that happen to be significant, quietly discarding the twelve that are not - the exact behaviour that manufactures false findings.

The two sentences that should make you stop

Watch for AI writing 'this shows X causes Y' about an observational regression, and for any gloss on a p-value as 'the probability the result is due to chance' or 'the probability the null is true'. Both are the classic errors, delivered with total confidence. A p-value is the probability of observing a test statistic at least as extreme as yours IF the null hypothesis were true - it says nothing about the probability that the null is true, nothing about effect size, and nothing about whether your design identifies a causal effect. The moment you see either sentence, treat everything downstream of it as suspect.

It helps to keep the mechanical facts to hand, because AI garbles them. A t-statistic is simply the coefficient divided by its standard error: t = b / se. As a rough guide, an absolute t above about 1.96 corresponds to significance at the 5% level in a large sample, which is the same thing as a 95% confidence interval that excludes zero. 'Significant' means 'distinguishable from zero given the noise' - it is a statement about precision, not about magnitude, importance or causality. A coefficient can be highly significant and economically trivial, or large and hopelessly imprecise. AI conflates all of these routinely; you must not.

The identification is yours to defend

AI can explain any method, translate any table and draft any do-file. It cannot own the exclusion restriction, vouch for parallel trends, or stand behind the sentence 'this is a causal effect'. That sentence is defended by your research design and by you - at the seminar, in the referee report, in front of the Treasury or the county assembly. Let AI explain and draft; keep the causal claim, and the responsibility for it, firmly in your own hands.

Check your understanding

An AI assistant summarises your regression like this: 'The coefficient on schooling has p = 0.02, so there is a 98% chance that schooling really affects wages.' Why is this wrong?

Check your understanding

You ask AI to help choose an identification strategy for whether a new NHIF health-insurance roll-out lowered households' out-of-pocket health spending. What is the correct division of labour between you and the model?

Check your understanding

A Mincer wage regression reports a coefficient on years of schooling of 0.12 with a standard error of 0.03. Compute the t-statistic for the null that the true coefficient is zero.

standard errors from zero

Exercise · try it first

You ask an AI assistant to interpret a regression for a policy brief. You ran a simple OLS on a cross-section of Kenyan workers: log(monthly wage) on years of schooling plus age and sex, using KNBS labour-force survey data. The schooling coefficient is 0.12 (se 0.03). The AI replies, confidently: 'The results show that an extra year of schooling causes a 12% increase in wages. This is statistically significant (p < 0.01), so we can be highly confident that schooling is a strong driver of earnings. You should recommend that the county expand secondary schooling to raise incomes.' Critique BOTH the regression and the AI's interpretation. List what is econometrically wrong, then write the prompt you would use to get AI to help you correctly instead.

Stuck? Ask Mwalimu (bottom-right) to check your reasoning.

Key takeaways

  • AI is a brilliant econometrics tutor and a reckless econometrics referee: it explains beautifully and asserts causality on no evidence, in the same calm voice
  • A p-value is the probability of a statistic at least this extreme if the null were true - not the probability the null is true, not the effect size, not proof of causation. AI garbles this constantly
  • Identification lives in the research design, not the regression command; AI can propose a strategy but only you can defend the exclusion restriction, parallel trends or SUTVA
  • Use AI to explain, translate and debug - never to launder a correlation into a causal claim you cannot defend

Further reading

  1. 01

    Mostly Harmless Econometrics: An Empiricist's Companion

    Angrist & Pischke · Princeton University Press · 2009The identification bible - what AI cannot own for you: the exclusion restriction, the counterfactual, the causal claim.

  2. 02

    The ASA Statement on p-Values: Context, Process, and Purpose

    Wasserstein & Lazar · The American Statistician · 2016The profession's own correction of the exact p-value misinterpretations AI repeats with confidence.

  3. 03

    Causal Inference: The Mixtape

    Scott Cunningham · Yale University Press · 2021A modern, readable tour of DiD, IV, RDD and matching - free online, ideal for checking whatever an AI tutor told you.

Loading progress…
LeadAfrikPublic Economics Hub