Equity and Distributional Effects
An average effect hides who benefited. Canadian HTA and policy bodies increasingly ask the distributional question: did the policy reduce or widen health inequalities between income groups, between rural and urban areas? Today you measure the income gradient in glycemic emergencies, summarize it with a concentration index, estimate Ontario's CGM policy effect separately for each income quintile and for rural and urban areas, and ask whether the policy narrowed the gap.
By the end of today you can
- describe outcomes by income quintile and rurality before estimating anything
- compute and interpret a concentration index and a Q1/Q5 ratio
- estimate policy effects by stratum and report absolute and relative effects
- state whether a policy narrowed or widened an inequality, with the counterfactual
- check which end of every deprivation scale is disadvantaged
Today's 5.5-hour plan
In this lesson
38.1 The gradient (35 min)
"""Day 38.1: who has glycemic emergencies? Ontario, 2016-2023, by income quintile and rurality."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import matplotlib # noqa: E402
matplotlib.use("Agg")
import matplotlib.pyplot as plt # noqa: E402
from corridor.db import ROOT # noqa: E402
from corridor.evaluation import load_by_income # noqa: E402
d = load_by_income()
on = d[(d.province == "ON") & (d.quarter < "2024")]
g = on.groupby(["income_quintile", "rural"])[["glycemic_ed_visits", "adults_with_diabetes"]].sum()
rate = (1000 * g.glycemic_ed_visits / g.adults_with_diabetes).unstack()
rate.columns = ["urban", "rural"]
share = on[on.quarter == "2023Q4"].groupby("income_quintile").adults_with_diabetes.sum()
rate["share of adults with diabetes"] = (share / share.sum()).map("{:.0%}".format)
print("ED visits for glycemic emergencies per 1,000 adults with diabetes per quarter, Ontario 2016-2023:")
print(rate.round(2).to_string())
print(f"\nlowest vs highest income quintile (urban): {rate.urban[1] / rate.urban[5]:.2f} times; "
f"rural vs urban (quintile 3): {rate.rural[3] / rate.urban[3]:.2f} times")
fig, ax = plt.subplots(figsize=(6, 3.6))
for col, c in (("urban", "#4f9cf9"), ("rural", "#f5a524")):
ax.plot(rate.index, rate[col], "o-", color=c, label=col)
ax.set_xticks(range(1, 6))
ax.set_xticklabels(["Q1\n(lowest)", "Q2", "Q3", "Q4", "Q5\n(highest)"])
ax.set_ylabel("visits per 1,000 per quarter")
ax.set_xlabel("neighbourhood income quintile")
ax.legend(frameon=False)
ax.spines[["top", "right"]].set_visible(False)
fig.tight_layout()
fig.savefig(os.path.join(ROOT, "figures", "day38_gradient.png"), dpi=150)
print("wrote figures/day38_gradient.png")
ED visits for glycemic emergencies per 1,000 adults with diabetes per quarter, Ontario 2016-2023:
urban rural share of adults with diabetes
income_quintile
1 6.10 7.71 26%
2 5.07 6.15 22%
3 4.18 5.24 20%
4 3.55 4.34 17%
5 2.92 3.73 15%
lowest vs highest income quintile (urban): 2.09 times; rural vs urban (quintile 3): 1.25 times
wrote figures/day38_gradient.png

Adults with diabetes in the lowest-income neighbourhoods have about twice the rate of glycemic emergencies of those in the highest (6.1 vs 2.9 per 1,000 per quarter), and rural adults a quarter more than urban ones at every income level. Diabetes itself is also more common at lower income: the lowest quintile holds 26% of adults with diabetes, the highest 15%. Income here is neighbourhood income (area-based, as in most Canadian administrative data, from postal codes), which is a proxy for individual income.
38.2 The concentration index (40 min)
The concentration index summarizes a gradient in one number. Rank people by income, then measure how far the cumulative share of the outcome departs from the cumulative share of the population. It runs from −1 (everything concentrated among the poorest) to +1 (among the richest); 0 means equality.
def concentration_index(rate, pop, rank_low_to_high=None):
"""Concentration index for grouped data (groups ordered from lowest to highest income):
C = 2 cov(y, r) / mean(y), with r the fractional rank of each group's midpoint, weighted by population.
Negative = the outcome is concentrated among lower-income people."""
y, w = np.asarray(rate, float), np.asarray(pop, float)
w = w / w.sum()
r = np.cumsum(w) - w / 2
mu = np.sum(w * y)
return float(2 * np.sum(w * (y - mu) * (r - np.sum(w * r))) / mu)
"""Day 38.2: the concentration index - one number for how unequally an outcome falls across income."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.evaluation import concentration_index, load_by_income # noqa: E402
d = load_by_income()
pre = d[d.quarter < "2024"]
print(f"{'province':<10}{'concentration index (2016-2023)':>33}{'Q1/Q5 rate ratio':>18}")
for prov, s in pre.groupby("province"):
g = s.groupby("income_quintile")[["glycemic_ed_visits", "adults_with_diabetes"]].sum()
r = 1000 * g.glycemic_ed_visits / g.adults_with_diabetes
print(f"{prov:<10}{concentration_index(r, g.adults_with_diabetes):>33.3f}{r[1] / r[5]:>18.2f}")
province concentration index (2016-2023) Q1/Q5 rate ratio
AB -0.132 1.99
BC -0.137 2.05
MB -0.137 2.14
NB -0.143 2.14
NL -0.135 2.06
NS -0.142 2.08
ON -0.139 2.09
PE -0.146 1.90
QC -0.137 2.04
SK -0.140 2.15
Every province has a similar pro-poor concentration of glycemic emergencies (−0.13 to −0.15), with the lowest quintile having about twice the highest quintile's rate. The concentration index uses all five groups and their sizes; the Q1/Q5 ratio uses only the extremes. Report both: the ratio is easier to explain, and the index is harder to game.
Check it in R with the "convenient regression" (the slope of a transformed outcome on the fractional rank):
# Day 38: the concentration index in R by the "convenient regression" (Kakwani, Wagstaff and van Doorslaer):
# regress 2 * var(r) * y / mean(y) on the fractional rank r; the slope is the concentration index.
d <- read.csv("data/provincial_diabetes_quarterly_by_income.csv")
s <- subset(d, province == "ON" & quarter < "2024")
g <- aggregate(cbind(glycemic_ed_visits, adults_with_diabetes) ~ income_quintile, data = s, FUN = sum)
g$y <- 1000 * g$glycemic_ed_visits / g$adults_with_diabetes
w <- g$adults_with_diabetes / sum(g$adults_with_diabetes)
r <- cumsum(w) - w / 2
mu <- sum(w * g$y)
vr <- sum(w * (r - sum(w * r))^2)
m <- lm(I(2 * vr * y / mu) ~ r, weights = w, data = g)
cat(sprintf("Ontario 2016-2023: concentration index %.3f\n", coef(m)["r"]))
Ontario 2016-2023: concentration index -0.139
38.3 Effects by income and rurality (50 min)
Run Day 34's synthetic control separately for each stratum: Ontario's lowest-income quintile against a weighted combination of the lowest-income quintiles of the other provinces, and so on.
"""Day 38.3: the CGM policy's effect in each income quintile and in rural and urban Ontario - a synthetic
control per stratum, with the same stratum in the other provinces as donors."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import pandas as pd # noqa: E402
from corridor.db import ROOT # noqa: E402
from corridor.evaluation import load_by_income, stratum_people, stratum_wide # noqa: E402
from corridor.quasi import synth # noqa: E402
d = load_by_income()
rows = []
for label, by in [(f"income Q{q}", {"income_quintile": q}) for q in range(1, 6)] + [("urban", {"rural": 0}), ("rural", {"rural": 1})]:
w = stratum_wide(d, by)
r = synth(w, "ON", "2024Q1", [c for c in w.columns if c not in ("ON", "SK")])
post = w.index >= "2024Q1"
n = stratum_people(d, by)
rows.append({"stratum": label, "pre_rmspe": round(r["pre_rmspe"], 3), "synthetic_rate": round(r["synthetic"][post].mean(), 3),
"effect_per_1000": round(r["gap"][post].mean(), 3),
"relative": round(r["gap"][post].mean() / r["synthetic"][post].mean(), 3),
"visits_avoided": round(float(-(r["gap"][post] * n[post] / 1000).sum()))})
t = pd.DataFrame(rows)
t.to_csv(os.path.join(ROOT, "docs", "cgm_distributional.csv"), index=False)
print(t.to_string(index=False))
q = t[t.stratum.str.startswith("income")]
print(f"\nshare of visits avoided in the two lowest income quintiles: {q.visits_avoided[:2].sum() / q.visits_avoided.sum():.0%} "
f"(they hold 48% of adults with diabetes)")
stratum pre_rmspe synthetic_rate effect_per_1000 relative visits_avoided
income Q1 0.159 5.456 -0.764 -0.140 4447
income Q2 0.170 4.524 -0.529 -0.117 2605
income Q3 0.221 3.823 -0.386 -0.101 1730
income Q4 0.223 3.121 -0.019 -0.006 72
income Q5 0.179 2.557 0.060 0.024 -203
urban 0.139 3.964 -0.411 -0.104 7909
rural 0.260 5.050 -0.403 -0.080 1265
share of visits avoided in the two lowest income quintiles: 82% (they hold 48% of adults with diabetes)
The lowest-income quintile gained most: −0.76 visits per 1,000 per quarter (14%), against near zero in the two highest quintiles. Two mechanisms are at work. Lower-income adults had more emergencies to prevent, and higher-income adults were more likely to have private coverage that already paid for CGMs, so the public program changed little for them. 82% of the emergency visits avoided were in the two lowest quintiles, which hold 48% of adults with diabetes. Rural and urban adults gained similar absolute amounts (−0.40 and −0.41), so the relative gain was smaller for rural adults (8% vs 10%). The rural synthetic control also fits less well (pre-period RMSPE 0.26).
Try it (15 min). Some HTA bodies and governments apply equity weights: a health gain counts more for a disadvantaged group. Recompute the visits avoided with moderate and strong weights for lower-income quintiles.
Solution
"""Day 38 try it: equity-weighted visits avoided - what if avoiding a visit counts more for lower-income adults?"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import pandas as pd # noqa: E402
from corridor.db import ROOT # noqa: E402
t = pd.read_csv(os.path.join(ROOT, "docs", "cgm_distributional.csv"))
q = t[t.stratum.str.startswith("income")].reset_index(drop=True)
for name, w in (("none (all 1)", [1, 1, 1, 1, 1]), ("moderate (1.4 ... 0.6)", [1.4, 1.2, 1.0, 0.8, 0.6]),
("strong (2.0 ... 0.4)", [2.0, 1.5, 1.0, 0.7, 0.4])):
print(f"equity weights {name:<24}: weighted visits avoided {sum(a * b for a, b in zip(q.visits_avoided, w)):>8,.0f}")
equity weights none (all 1) : weighted visits avoided 8,651
equity weights moderate (1.4 ... 0.6) : weighted visits avoided 11,018
equity weights strong (2.0 ... 0.4) : weighted visits avoided 14,501
Because the gains fall mostly on lower-income adults, equity weights raise the policy's value: from 8,651 to 11,018 (moderate) or 14,501 (strong) weighted visits avoided. Distributional cost-effectiveness analysis (Day 89) formalizes this. Its key idea is already here: the same total effect is worth more when it reduces inequality.
38.4 Did inequality narrow? (30 min)
Compare the concentration index of what happened in 2026–2027 with the counterfactual one, built from each quintile's synthetic control:
"""Day 38.4: did the policy narrow the income gradient? Concentration index in 2024-2027, actual vs the
synthetic counterfactual (each quintile's synthetic control)."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.evaluation import concentration_index, load_by_income, stratum_people, stratum_wide # noqa: E402
from corridor.quasi import synth # noqa: E402
d = load_by_income()
actual, counterfactual, pop = [], [], []
for q in range(1, 6):
w = stratum_wide(d, {"income_quintile": q})
r = synth(w, "ON", "2024Q1", [c for c in w.columns if c not in ("ON", "SK")])
post = w.index >= "2026Q1" # once the effect has built up
actual.append(w.ON[post].mean())
counterfactual.append(r["synthetic"][post].mean())
pop.append(stratum_people(d, {"income_quintile": q})[post].mean())
ci_a, ci_c = concentration_index(actual, pop), concentration_index(counterfactual, pop)
print(f"Ontario 2026-2027, concentration index of glycemic ED visits: actual {ci_a:.3f}, without the policy {ci_c:.3f}")
print(f"Q1/Q5 rate ratio: actual {actual[0] / actual[4]:.2f}, without the policy {counterfactual[0] / counterfactual[4]:.2f}")
Ontario 2026-2027, concentration index of glycemic ED visits: actual -0.107, without the policy -0.141
Q1/Q5 rate ratio: actual 1.78, without the policy 2.12
Without the policy, the concentration index would have stayed at −0.141; with it, −0.107. The Q1/Q5 ratio falls from 2.12 to 1.78. The policy reduced income-related inequality in glycemic emergencies by about a quarter. This is the sentence an equity analysis exists to produce: not "the policy works", but "the policy works and narrows the gap".
Why it matters at work: CDA-AMC's guidelines discuss equity considerations, and INESSS weighs social and ethical aspects in its overall value assessment. The federal Gender-based Analysis Plus (GBA Plus) asks departments to analyse how initiatives affect diverse groups of people. Analysts who can estimate effects by income and rurality, and say whether a gap narrowed, answer these requirements with evidence instead of narrative.
Where you'll meet this: GBA Plus sections of federal evaluations; CIHI's health inequalities reporting; distributional cost-effectiveness analysis (Day 89)
38.5 Truth check (25 min)
"""Day 38 truth check: stratum effects and the change in inequality against the generator."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import pandas as pd # noqa: E402
from corridor.db import ROOT # noqa: E402
from corridor.evaluation import concentration_index, load_by_income, truth_by_income # noqa: E402
d = load_by_income()
t = truth_by_income().merge(d, on=["province", "quarter", "income_quintile", "rural"])
on = t[(t.province == "ON") & (t.quarter >= "2024")]
est = pd.read_csv(os.path.join(ROOT, "docs", "cgm_distributional.csv")).set_index("stratum")
def truth(s):
return ((s.rate_per_1000 - s.rate_no_cgm_policy) * s.adults_with_diabetes).sum() / s.adults_with_diabetes.sum()
print(f"{'stratum':<12}{'synthetic control':>18}{'truth':>8}")
for q in range(1, 6):
print(f"{'income Q' + str(q):<12}{est.effect_per_1000['income Q' + str(q)]:>+18.3f}{truth(on[on.income_quintile == q]):>+8.3f}")
for r, lab in ((0, "urban"), (1, "rural")):
print(f"{lab:<12}{est.effect_per_1000[lab]:>+18.3f}{truth(on[on.rural == r]):>+8.3f}")
late = on[on.quarter >= "2026"]
g = late.groupby("income_quintile").apply(lambda s: pd.Series({
"a": (s.rate_per_1000 * s.adults_with_diabetes).sum() / s.adults_with_diabetes.sum(),
"c": (s.rate_no_cgm_policy * s.adults_with_diabetes).sum() / s.adults_with_diabetes.sum(),
"n": s.adults_with_diabetes.sum()}), include_groups=False)
print(f"\ntrue concentration index 2026-2027 (expected rates): with the policy {concentration_index(g.a, g.n):.3f}, "
f"without {concentration_index(g.c, g.n):.3f}")
stratum synthetic control truth
income Q1 -0.764 -0.755
income Q2 -0.529 -0.507
income Q3 -0.386 -0.325
income Q4 -0.019 -0.166
income Q5 +0.060 -0.080
urban -0.411 -0.428
rural -0.403 -0.321
true concentration index 2026-2027 (expected rates): with the policy -0.111, without -0.137
The stratum effects track the truth closely in the three lowest quintiles and for urban adults. For the two highest quintiles the true effects are small (−0.17 and −0.08) and the estimates are noise around them. The true concentration index moves from −0.137 to −0.111, and the estimated change (−0.141 to −0.107) is close. Rural adults' effect is overestimated (−0.40 vs −0.32), as the poorer pre-period fit warned.
38.6 Quintiles upside down (20 min)
Bug of the day. An analyst merges Quebec results computed with the INSPQ material deprivation index into a table of Statistics Canada income quintiles:
"""Day 38 bug of the day: merging a table that numbers quintiles the other way round.
Statistics Canada income quintiles run from 1 = lowest income; Quebec's material deprivation index (INSPQ)
runs from 1 = least deprived. Merge one into the other without recoding and the gradient flips."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.evaluation import concentration_index, load_by_income # noqa: E402
d = load_by_income()
s = d[(d.province == "QC") & (d.quarter < "2024")]
g = s.groupby("income_quintile")[["glycemic_ed_visits", "adults_with_diabetes"]].sum()
r = 1000 * g.glycemic_ed_visits / g.adults_with_diabetes
print(f"Quebec, quintile 1 = lowest income: concentration index {concentration_index(r, g.adults_with_diabetes):+.3f}")
print(f"the same rates, read as 1 = least deprived: {concentration_index(r[::-1].to_numpy(), g.adults_with_diabetes[::-1].to_numpy()):+.3f}")
Quebec, quintile 1 = lowest income: concentration index -0.137
the same rates, read as 1 = least deprived: +0.137
Statistics Canada's income quintiles run from 1 = lowest income; Quebec's deprivation index (and Ontario's Marginalization Index) run from 1 = least deprived. Read without recoding, a pro-poor concentration (−0.137) becomes pro-rich (+0.137), and the conclusion reverses. Every equity table should state, in its header, which end of the scale is disadvantaged.
38.7 Mini-project: who benefited (60 min)
"""Day 38 mini-project: the distributional figure - effect per 1,000 and visits avoided, by income quintile."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import matplotlib # noqa: E402
matplotlib.use("Agg")
import matplotlib.pyplot as plt # noqa: E402
import pandas as pd # noqa: E402
from corridor.db import ROOT # noqa: E402
t = pd.read_csv(os.path.join(ROOT, "docs", "cgm_distributional.csv"))
q = t[t.stratum.str.startswith("income")]
fig, (a1, a2) = plt.subplots(1, 2, figsize=(9, 3.4))
labels = ["Q1\n(lowest)", "Q2", "Q3", "Q4", "Q5\n(highest)"]
a1.bar(labels, -q.effect_per_1000, color="#3ecf8e")
a1.set_ylabel("visits avoided per 1,000 per quarter")
a2.bar(labels, q.visits_avoided, color="#22b8cf")
a2.set_ylabel("visits avoided, 2024-2027")
for ax in (a1, a2):
ax.spines[["top", "right"]].set_visible(False)
fig.suptitle("Ontario CGM coverage: who benefited (synthetic control by income quintile)", fontsize=10)
fig.tight_layout()
fig.savefig(os.path.join(ROOT, "figures", "day38_distributional.png"), dpi=150)
print("wrote figures/day38_distributional.png")
print(f"Q1 + Q2: {q.visits_avoided.iloc[:2].sum():,.0f} of {q.visits_avoided.sum():,.0f} visits avoided")
wrote figures/day38_distributional.png
Q1 + Q2: 7,052 of 8,651 visits avoided

Write the distributional paragraph for the Day 40 brief: the gradient before the policy, who gained, and the change in the concentration index, with the caveat that income is measured at the neighbourhood level.
38.8 Save your work
python -m pytest -q
git add .
git commit -m "Day 38: equity - concentration index and distributional effects of CGM coverage"
Day 38 checklist
- I describe outcomes by income quintile and rurality before estimating anything
- I compute and interpret a concentration index and a Q1/Q5 ratio
- I estimate policy effects by stratum and report absolute and relative effects
- I state whether a policy narrowed or widened an inequality, with the counterfactual
- I check which end of every deprivation scale is disadvantaged
Bloc français (30 min)
Thème : l'équité en santé.
Les adultes diabétiques des quartiers les plus défavorisés ont deux fois plus d'urgences glycémiques que ceux des quartiers les plus aisés. La couverture des glucomètres en continu a surtout profité au premier quintile de revenu. L'indice de concentration est passé de −0,14 à −0,11 : la politique a réduit les inégalités d'environ un quart. Le revenu est mesuré à l'échelle du quartier.
| Français | English |
|---|---|
| l'équité en santé | health equity |
| les inégalités sociales de santé | social inequalities in health |
| le quintile de revenu | the income quintile |
| l'indice de défavorisation | the deprivation index |
| le milieu rural | rural areas |
| l'indice de concentration | the concentration index |
| le gradient social | the social gradient |
| l'effet distributionnel | the distributional effect |
| la pondération d'équité | equity weighting |
| l'analyse comparative entre les sexes plus (ACS Plus) | Gender-based Analysis Plus (GBA Plus) |
| défavorisé / favorisé | disadvantaged / advantaged |
| réduire l'écart | to narrow the gap |
Exercices
- Translate: "82% of the visits avoided were in the two lowest income quintiles."
- Translate: « Dans l'indice de l'INSPQ, le quintile 5 est le plus défavorisé. »
- In three French sentences, explain why an equal relative effect can still widen an absolute gap.
Réponses
- 82 % des visites évitées l'ont été dans les deux quintiles de revenu les plus bas.
- "In the INSPQ index, quintile 5 is the most deprived."
- Example: Si le risque baisse de 10 % dans tous les groupes, la baisse absolue est plus grande là où le risque est élevé. Mais si l'effet relatif est plus fort chez les mieux nantis, l'écart peut s'élargir. Il faut donc présenter les effets absolus et relatifs par groupe.