Skip to content
Module 12 of 1290 min readIntermediate

Three real analyses on Kenyan data

Replicate the bank-rates spread analysis, the pension-fund composition study, and the mobile-payments growth model — end to end, in Stata.

100%

Listen along

Read “Three real analyses on Kenyan data” 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:

  • 01Replicate three published Kenyan analyses end-to-end in Stata
  • 02Apply tsset, xtreg, and tsline to real time-series and panel data
  • 03Produce esttab regression tables and twoway plots ready for publication
  • 04Recognise where to go next: ivreg2 (IV), reghdfe (high-dim FE), synth (synthetic control)

Three real analyses on Kenyan data — bank rates, pension allocation, M-PESA growth — implemented end-to-end in Stata. Replicating these in your practice environment is the most useful applied exercise in this course.

Project 1 — bank-rates spread

stata
use bankrates.dta, clear
generate spread = lending_rate - deposit_rate
tsset month, monthly
tsline spread, title("Lending-deposit spread") ytitle("Spread (pp)")
* Linear time trend
generate t = _n
regress spread t, robust

Project 2 — pension allocation shift

stata
use pension.dta, clear
generate govt_share = govt_securities / total
tsset period, halfyearly
tsline govt_share, title("Govt securities share of pension assets") ///
ytitle("Share") yscale(range(0 1)) ylabel(0(0.1)1)
* Trend break test (Chow): split at period 8
generate t = _n
generate t_post = (t > 8) * (t - 8)
regress govt_share t t_post, robust

Project 3 — M-PESA growth rate

stata
use mpesa.dta, clear
tsset month, monthly
* Year-on-year growth
generate yoy = (volume / L12.volume - 1) * 100
tsline yoy, title("M-PESA YoY volume growth") ytitle("YoY growth (%)") ///
yline(0)

What you've learned

If you can load Kenyan data, transform it, run a panel regression with clustered SEs, and export an esttab table — you have working Stata at the level a Kenyan ministry, the World Bank country office, or a research consultancy expects. The next moves: ivreg2 for IV (ssc install ivreg2), reghdfe for high-dimensional FE, the synth or sdid suites for synthetic control.

Stata is invested-in once and used forever

The command grammar hasn't changed in 20+ years. A do-file you write today will run unchanged in 2045. That stability is worth a lot in a world where Python and R refactor every two years.

Exercise

A development-economics researcher has been hired by the World Bank's Africa region to evaluate a cash-transfer programme that started in three Kenyan counties in 2022. They have administrative data on 80,000 households (matched treatment and control), with monthly follow-up through 2025. The brief: produce a publication-ready impact evaluation in 4 weeks. Walk through how you'd structure the Stata do-file architecture, the estimation strategy, and the deliverables.

Key takeaways

  • Three projects, three Stata patterns: time-series trend (bank-rate spread), structural break (pension), YoY transformation (M-PESA)
  • If you can load data → transform → run xtreg → export esttab, you have working applied-economist Stata
  • ssc install gives access to the broader user-written package universe — ivreg2, reghdfe, synth, sdid
  • Stata's stability is its value: a do-file from 2005 still runs today
Loading progress…
LeadAfrikPublic Economics Hub