Q&A 6 Which EAC country has the most stable vs most volatile GDP growth?
6.1 Explanation
Beyond average growth, economists also care about stability.
- A country with steady growth is usually more attractive for investment and policy planning.
- A country with highly volatile growth may face economic shocks, conflicts, or dependence on narrow sectors (e.g., oil, minerals).
We can measure volatility by looking at the standard deviation of GDP growth rates over time.
- High standard deviation → volatile growth
- Low standard deviation → stable growth
6.2 SQL/MySQL Code
Once you have computed GDP growth rates (using a self-join into a derived table or a stored table), you can measure volatility:
-- Calculate average growth and volatility (std dev) by country
SELECT
country,
ROUND(AVG(gdp_growth_rate), 2) AS avg_growth,
ROUND(STDDEV(gdp_growth_rate), 2) AS volatility
FROM (
SELECT
curr.country,
curr.year,
((curr.gdp_usd_current - prev.gdp_usd_current) / prev.gdp_usd_current) * 100 AS gdp_growth_rate
FROM gdp_wdi curr
JOIN gdp_wdi prev
ON curr.country = prev.country
AND curr.year = prev.year + 1
WHERE curr.country IN ('KE','TZ','UG','RW','BI','CD','SS','SO')
) AS growth_rates
GROUP BY country
ORDER BY volatility DESC;6.3 Python Code
import pandas as pd
# Load dataset
df = pd.read_csv("data/gdp_wdi_EAC_USA_2000_2024.csv")
# Keep only EAC
eac_codes = ["KE","TZ","UG","RW","BI","CD","SS","SO"]
eac = df[df["country"].isin(eac_codes)].sort_values(["country","year"])
# Calculate GDP growth rates
eac["gdp_growth_rate"] = eac.groupby("country")["gdp_usd_current"].pct_change() * 100
# Compute mean and volatility (std deviation)
stats = eac.groupby("country")["gdp_growth_rate"].agg(["mean","std"]).reset_index()
stats = stats.rename(columns={"mean":"avg_growth","std":"volatility"})
print(stats.sort_values("volatility", ascending=False)) country avg_growth volatility
5 SS 0.214993 28.246220
4 SO 7.554278 19.767841
1 CD 7.639088 16.916869
7 UG 10.263052 15.497807
0 BI 4.528763 11.711263
2 KE 10.310812 8.980763
3 RW 8.662015 8.199373
6 TZ 7.850297 6.481448
6.4 Learning Outcome
By the end of this Q&A you will be able to: - Calculate GDP growth volatility using SQL (via STDDEV). - Use Python to compute and compare growth stability across countries. - Interpret volatility as a measure of economic risk and uncertainty.
⸻
6.5 Takeaway
- Stable growth (low volatility) indicates consistent expansion, often linked to stronger institutions and diversified economies.
- Volatile growth (high volatility) can signal vulnerability to shocks, conflicts, or reliance on a single sector.
- This analysis helps policymakers and analysts understand not just how fast economies grow, but also how reliable that growth is over time.