Interrupted Time Series
Ontario listed Renavex on 1 October 2025. Did the listing change how often doctors started an SGLT2 inhibitor, the other kidney-protective drug? With one province and monthly data, the classic design is an interrupted time series (ITS): fit the trend before the policy, project it forward as the counterfactual, and compare. Today you fit a segmented regression with seasonality, discover that its errors are autocorrelated and that the textbook fix (Newey–West) makes things worse with 84 points, switch to GLS with AR(1) errors, and learn ITS's main weakness: anything else that happened in October 2025 is attributed to the listing.
By the end of today you can
- fit a segmented regression with trend, level change, slope change and seasonality
- report the effect as the average gap to the counterfactual over a stated period
- check autocorrelation and use GLS AR(1) rather than trusting Newey–West with short series
- never compare averages before and after
- name the history threat and look for events at the same time as the policy
Today's 5.5-hour plan
In this lesson
31.1 The policy panel (30 min)
LISTING = {"ON": "2025-10-01", "QC": "2026-02-01"} # first full month on the formulary
def load_panel():
"""Region-month panel, January 2021 to December 2027, with rates per 1,000 people with diabetes."""
import duckdb
p = duckdb.sql(f"SELECT * FROM read_csv('{DATA}/drug_utilization_monthly.csv')").df()
c = duckdb.sql(f"SELECT * FROM read_csv('{DATA}/kidney_clinic_rollout.csv')").df()
p = p.merge(c, on="region")
p["month"] = pd.to_datetime(p.month)
p["t"] = (p.month.dt.year - 2021) * 12 + p.month.dt.month - 1 # 0 = January 2021
p["calendar_month"] = p.month.dt.month
for y in ("sglt2", "renavex"):
p[f"{y}_rate"] = 1000 * p[f"{y}_starts"] / p.people_with_diabetes
p["uacr_rate"] = 1000 * p.uacr_tests / p.people_with_diabetes
p["nephro_rate"] = p.sglt2_rate + p.renavex_rate
p["listed"] = (p.month >= p.province.map(pd.to_datetime(pd.Series(LISTING)))).astype(int)
opened = pd.to_datetime(p.clinic_opened)
p["g"] = ((opened.dt.year - 2021) * 12 + opened.dt.month - 1).fillna(np.inf) # first clinic month (inf = never)
p["clinic"] = (p.t >= p.g).astype(int)
return p.sort_values(["region", "t"]).reset_index(drop=True)
"""Day 31.1: the data - monthly starts of SGLT2 inhibitors and Renavex per 1,000 people with diabetes, by province."""
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
from corridor.policy import LISTING, load_panel, province_series # noqa: E402
p = load_panel()
print(f"{p.region.nunique()} regions x {p.t.nunique()} months = {len(p)} rows, {p.month.min():%b %Y} to {p.month.max():%b %Y}")
print(p.groupby("province").people_with_diabetes.agg(["min", "max"]).applymap(lambda v: f"{v:,}") if hasattr(p, "applymap")
else p.groupby("province").people_with_diabetes.agg(["min", "max"]))
fig, axes = plt.subplots(1, 2, figsize=(10, 3.6), sharey=True)
for ax, prov in zip(axes, ("ON", "QC")):
s = province_series(p, prov)
ax.plot(s.month, s.sglt2_rate, color="#a78bfa", lw=1.4, label="SGLT2 inhibitor starts")
ax.plot(s.month, s.renavex_rate, color="#3ecf8e", lw=1.4, label="Renavex starts")
ax.axvline(pd.Timestamp(LISTING[prov]), color="black", lw=0.8, ls="--")
ax.set_title(f"{prov}: listed {pd.Timestamp(LISTING[prov]):%B %Y}", fontsize=10)
ax.spines[["top", "right"]].set_visible(False)
yr = s.groupby(s.month.dt.year).sglt2_rate.mean()
print(f"{prov} SGLT2 starts per 1,000 per month, yearly means: " + ", ".join(f"{y} {v:.2f}" for y, v in yr.items()))
axes[0].set_ylabel("starts per 1,000 per month")
axes[0].legend(frameon=False, fontsize=8)
fig.tight_layout()
fig.savefig(os.path.join(ROOT, "figures", "day31_series.png"), dpi=150)
print("wrote figures/day31_series.png")
11 regions x 84 months = 924 rows, Jan 2021 to Dec 2027
min max
province
ON 33417 240152
QC 20438 189414
ON SGLT2 starts per 1,000 per month, yearly means: 2021 3.98, 2022 4.62, 2023 5.02, 2024 5.44, 2025 5.72, 2026 5.45, 2027 5.66
QC SGLT2 starts per 1,000 per month, yearly means: 2021 3.35, 2022 3.88, 2023 4.44, 2024 4.92, 2025 5.52, 2026 5.20, 2027 5.48
wrote figures/day31_series.png

Four features of the series matter for the analysis:
- Trend. SGLT2 initiation grows every year as guidelines expand.
- Seasonality. There are dips in January, July–August and December, when fewer people see their doctor.
- Level differences. Quebec starts lower than Ontario.
- Timing. Renavex starts are zero before each province's listing and ramp up after it.
Ontario's 2026 mean SGLT2 rate (5.45) is below 2025's (5.72), the first drop in the series.
31.2 Segmented regression (50 min)
The segmented regression has four core terms:
rate = b0 + b1 · t + b2 · post + b3 · months since listing + calendar-month effects
- b1 is the pre-listing trend.
- b2 is the immediate change in level.
- b3 is the change in slope.
The counterfactual is the same model with b2 = b3 = 0: the pre-listing trend and seasonality, projected forward. The effect at any post-listing month is b2 + b3 × months since listing.
def its(s, y, start, season=True, cov="ar1", lags=3):
"""Segmented regression: y = b0 + b1 t + b2 post + b3 (months since start) [+ calendar-month effects].
cov: 'ols' (independent errors), 'nw' (Newey-West HAC SEs) or 'ar1' (GLS with AR(1) errors, the default).
Returns (fit, design frame)."""
import statsmodels.api as sm
import statsmodels.formula.api as smf
d = s.assign(post=(s.t >= start).astype(int), since=np.maximum(s.t - start + 1, 0) * (s.t >= start))
f = f"{y} ~ t + post + since" + (" + C(calendar_month)" if season else "")
if cov == "ar1":
return sm.GLSAR.from_formula(f, d, rho=1).iterative_fit(maxiter=20), d
m = smf.ols(f, d)
return (m.fit() if cov == "ols" else m.fit(cov_type="HAC", cov_kwds={"maxlags": lags})), d
def its_average_effect(fit, d, months):
"""Average effect over the first `months` post-period months, with a 95% CI: (estimate, low, high)."""
names = list(fit.model.exog_names)
L = np.zeros(len(names))
L[names.index("post")] = 1
L[names.index("since")] = d[d.post == 1].since.iloc[:months].mean()
r = fit.t_test(L).summary_frame().iloc[0]
return float(r["coef"]), float(r["Conf. Int. Low"]), float(r["Conf. Int. Upp."])
def its_effects(fit, d):
"""Fitted minus counterfactual (post = since = 0) for each post-period month."""
names = list(fit.model.exog_names)
b = np.asarray(fit.params)
eff = d.post * b[names.index("post")] + d.since * b[names.index("since")]
return eff[d.post == 1]
"""Day 31.2-31.3: segmented regression for Ontario - did the October 2025 listing change SGLT2 initiation?
Fitted by GLS with AR(1) errors (31.4 shows why)."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.policy import its, its_average_effect, its_effects, load_panel, province_series # noqa: E402
s = province_series(load_panel(), "ON")
fit, d = its(s, "sglt2_rate", start=57) # October 2025 = month 57
names = list(fit.model.exog_names)
for k in ("Intercept", "t", "post", "since"):
i = names.index(k)
print(f"{k:<10}{fit.params.iloc[i]:>9.4f} SE {fit.bse.iloc[i]:.4f}")
print(f"AR(1) coefficient of the errors: {fit.model.rho[0]:.2f}")
post = d[d.post == 1]
print("\naverage effect over the first h months after listing (starts per 1,000 per month):")
for h in (6, 12, len(post)):
est, lo, hi = its_average_effect(fit, d, h)
base = (fit.fittedvalues - its_effects(fit, d).reindex(d.index, fill_value=0))[d.post == 1].iloc[:h].mean()
print(f" {h:>2} months: {est:+.2f} ({lo:+.2f} to {hi:+.2f}), {100 * est / base:+.0f}% of the projected {base:.2f}")
eff = its_effects(fit, d)
print(f"\nmonthly effects: month 1 {eff.iloc[0]:+.2f}, month 12 {eff.iloc[11]:+.2f}, month {len(eff)} {eff.iloc[-1]:+.2f}")
Intercept 3.3657 SE 0.1131
t 0.0386 SE 0.0026
post -0.6575 SE 0.1317
since -0.0256 SE 0.0076
AR(1) coefficient of the errors: 0.44
average effect over the first h months after listing (starts per 1,000 per month):
6 months: -0.75 (-0.99 to -0.51), -12% of the projected 6.15
12 months: -0.82 (-1.06 to -0.59), -13% of the projected 6.26
27 months: -1.02 (-1.26 to -0.77), -15% of the projected 6.56
monthly effects: month 1 -0.68, month 12 -0.97, month 27 -1.35
31.3 Reading the effect (40 min)
The pre-listing trend is +0.039 starts per 1,000 per month. At the listing, the level drops by 0.66 and the slope by 0.026 per month, so the gap to the counterfactual widens: −0.68 in month 1, −1.35 by month 27. Averaged over the first year, Ontario had 0.82 fewer SGLT2 starts per 1,000 per month (95% CI 0.59 to 1.06), 13% of the projected rate.
That pattern, a drop that deepens as Renavex uptake ramps up, fits substitution: some patients who would have started an SGLT2 inhibitor started Renavex instead. For a budget impact analysis (Module 5), substitution matters a great deal. If Renavex displaces SGLT2 prescriptions, its net cost to the drug plan is smaller than its gross cost.
Report the effect for a stated period ("over the first 12 months"), not "the coefficient on post". The level and slope terms are the machinery; the averaged gap is the answer.
31.4 Autocorrelation (40 min)
Monthly residuals are rarely independent: a month that runs high is followed by another that runs high. Ordinary least squares then underestimates standard errors.
"""Day 31.4: autocorrelation - residuals one month apart are correlated, so ordinary SEs are too small."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import statsmodels.api as sm # noqa: E402
from statsmodels.stats.diagnostic import acorr_ljungbox # noqa: E402
from statsmodels.stats.stattools import durbin_watson # noqa: E402
from corridor.policy import its, load_panel, province_series # noqa: E402
s = province_series(load_panel(), "ON")
ols, d = its(s, "sglt2_rate", 57, cov="ols")
r = ols.resid
print(f"Durbin-Watson {durbin_watson(r):.2f} (2 = none); lag-1 autocorrelation {r.autocorr(1):.2f}; "
f"Ljung-Box p (6 lags) {acorr_ljungbox(r, lags=[6]).lb_pvalue.iloc[0]:.3f}")
print(f"\n{'standard errors':<34}{'level change':>14}{'slope change':>14}")
print(f"{'ordinary least squares':<34}{ols.bse.post:>14.3f}{ols.bse.since:>14.3f}")
for lags in (3, 6, 12):
nw, _ = its(s, "sglt2_rate", 57, cov="nw", lags=lags)
print(f"{'Newey-West, ' + str(lags) + ' lags':<34}{nw.bse.post:>14.3f}{nw.bse.since:>14.3f}")
g = sm.GLSAR(ols.model.endog, ols.model.exog, rho=1).iterative_fit(maxiter=10)
names = ols.model.exog_names
print(f"{'GLS with AR(1) errors (rho ' + format(g.model.rho[0], '.2f') + ')':<34}{g.bse[names.index('post')]:>14.3f}"
f"{g.bse[names.index('since')]:>14.3f}")
print(f"\nGLS estimates: level {g.params[names.index('post')]:+.3f}, slope {g.params[names.index('since')]:+.4f} "
f"(OLS {ols.params.post:+.3f}, {ols.params.since:+.4f})")
Durbin-Watson 1.14 (2 = none); lag-1 autocorrelation 0.43; Ljung-Box p (6 lags) 0.003
standard errors level change slope change
ordinary least squares 0.092 0.005
Newey-West, 3 lags 0.064 0.004
Newey-West, 6 lags 0.060 0.004
Newey-West, 12 lags 0.054 0.004
GLS with AR(1) errors (rho 0.44) 0.132 0.008
GLS estimates: level -0.658, slope -0.0256 (OLS -0.732, -0.0226)
The Durbin–Watson statistic of 1.14 and a lag-1 autocorrelation of 0.43 confirm it. The usual fix, Newey–West standard errors, gives smaller standard errors than OLS here, and fewer lags would not help: Newey–West is a large-sample method, and with 84 monthly points it underestimates the variance. GLS with AR(1) errors (Prais–Winsten, or GLSAR in statsmodels) models the correlation directly: the standard error of the level change rises from 0.09 to 0.13, and the estimates move a little too. That is why its() uses GLS AR(1) by default.
Why it matters at work: ITS is the workhorse of drug policy evaluation in Canada: formulary listings, delisting, generic pricing, opioid prescribing rules. Reviewers check three things first: enough pre-period points (at least 12, ideally 24 or more), seasonality, and autocorrelation. Getting the standard errors wrong is the most common way an ITS overstates its certainty.
Where you'll meet this: CIHI and NPDUIS reports; Ontario Drug Policy Research Network studies; provincial evaluations of formulary changes; Cochrane EPOC's criteria for including ITS studies
Check it in R:
# Day 31: the Ontario ITS in R - lm with Newey-West SEs (sandwich), and GLS with AR(1) errors (nlme).
suppressPackageStartupMessages({ library(sandwich); library(lmtest); library(nlme) })
p <- read.csv("data/drug_utilization_monthly.csv")
on <- aggregate(cbind(people_with_diabetes, sglt2_starts) ~ month, data = subset(p, province == "ON"), FUN = sum)
on <- on[order(on$month), ]
on$t <- seq_len(nrow(on)) - 1
on$rate <- 1000 * on$sglt2_starts / on$people_with_diabetes
on$post <- as.integer(on$t >= 57)
on$since <- pmax(on$t - 56, 0) * on$post
on$cal <- factor(as.integer(substr(on$month, 6, 7)))
m <- lm(rate ~ t + post + since + cal, data = on)
print(round(coeftest(m, vcov = NeweyWest(m, lag = 3, prewhite = FALSE, adjust = TRUE))[c("post", "since"), 1:2], 3))
g <- gls(rate ~ t + post + since + cal, data = on, correlation = corAR1(form = ~ t))
cat(sprintf("GLS AR(1): phi %.2f; level %+.3f (SE %.3f), slope %+.4f (SE %.4f)\n",
coef(g$modelStruct$corStruct, unconstrained = FALSE), coef(g)["post"], sqrt(vcov(g)["post", "post"]),
coef(g)["since"], sqrt(vcov(g)["since", "since"])))
Estimate Std. Error
post -0.732 0.070
since -0.023 0.005
GLS AR(1): phi 0.50; level -0.638 (SE 0.139), slope -0.0262 (SE 0.0081)
R's NeweyWest() with a small-sample adjustment gives slightly larger SEs (0.070) than Python's, and nlme::gls estimates the AR(1) parameter by maximum likelihood (0.50 vs 0.44). The conclusions are the same.
31.5 Truth check: the history threat (30 min)
"""Day 31 truth check: the ITS effects against the generator, and what happened to Ontario's counterfactual."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import numpy as np # noqa: E402
from corridor.policy import its, its_average_effect, load_panel, province_series, truth_panel # noqa: E402
p = load_panel()
tr = truth_panel().merge(p[["region", "month", "t", "people_with_diabetes", "province"]], on=["region", "month"])
o = tr[tr.province == "ON"]
w = o.people_with_diabetes
cf = (o.sglt2_rate_no_listing * w).groupby(o.t).sum() / w.groupby(o.t).sum()
true = ((o.sglt2_rate - o.sglt2_rate_no_listing) * w).groupby(o.t).sum() / w.groupby(o.t).sum()
fit, d = its(province_series(p, "ON"), "sglt2_rate", 57)
print(f"{'months after listing':<22}{'ITS (95% CI)':>22}{'truth':>8}")
for h in (6, 12, 27):
est, lo, hi = its_average_effect(fit, d, h)
print(f"{'first ' + str(h):<22}{est:>+8.2f} ({lo:+.2f} to {hi:+.2f}){true.loc[57:56 + h].mean():>+8.2f}")
pre = np.polyfit(np.arange(57), cf.loc[:56], 1)
gap = cf.loc[57:] - np.polyval(pre, np.arange(57, 84))
print(f"\nOntario's counterfactual (no listing) vs its own pre-2025 trend, after October 2025: "
f"mean {gap.mean():+.2f}, first 12 months {gap.iloc[:12].mean():+.2f}")
months after listing ITS (95% CI) truth
first 6 -0.75 (-0.99 to -0.51) -0.48
first 12 -0.82 (-1.06 to -0.59) -0.66
first 27 -1.02 (-1.26 to -0.77) -0.84
Ontario's counterfactual (no listing) vs its own pre-2025 trend, after October 2025: mean -0.21, first 12 months -0.23
The listing did lower SGLT2 initiation, by about 0.5 starts per 1,000 per month in the first 6 months, 0.66 in the first year, and 0.84 over 27 months. The ITS estimates are 0.16–0.27 too large. The 12- and 27-month intervals only just cover the truth, and the 6-month interval misses it.
The last line explains why. Without any listing, Ontario's SGLT2 rate would have run 0.21 below its pre-2025 trend after October 2025. The generator's random month-to-month shocks happened to push the series down just as the listing started. ITS has no way to tell the two apart: it attributes everything that departs from the projected trend to the policy. This is the history threat: something else happened at the same time. In real data, that something could be a supply shortage, a new guideline, a price change or a pandemic wave.
Try it (15 min). Run the same ITS for Quebec, listed in February 2026.
Solution
"""Day 31 try it: the same ITS for Quebec, listed in February 2026 (month 61)."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.policy import its, its_average_effect, load_panel, province_series, truth_panel # noqa: E402
p = load_panel()
fit, d = its(province_series(p, "QC"), "sglt2_rate", 61)
post = d[d.post == 1]
tr = truth_panel().merge(p[["region", "month", "t", "people_with_diabetes", "province"]], on=["region", "month"])
o = tr[(tr.province == "QC") & (tr.t >= 61)]
w = o.people_with_diabetes
true = ((o.sglt2_rate - o.sglt2_rate_no_listing) * w).groupby(o.t).sum() / w.groupby(o.t).sum()
for h in (12, len(post)):
est, lo, hi = its_average_effect(fit, d, h)
print(f"first {h} months: {est:+.2f} ({lo:+.2f} to {hi:+.2f}); truth {true.iloc[:h].mean():+.2f}")
import numpy as np # noqa: E402
cf = (o.sglt2_rate_no_listing * w).groupby(o.t).sum() / w.groupby(o.t).sum()
q = tr[tr.province == "QC"]
wq = q.people_with_diabetes
cfa = (q.sglt2_rate_no_listing * wq).groupby(q.t).sum() / wq.groupby(q.t).sum()
pre = np.polyfit(np.arange(61), cfa.loc[:60], 1)
print(f"Quebec's counterfactual vs its pre-listing trend after February 2026: {(cfa.loc[61:] - np.polyval(pre, np.arange(61, 84))).mean():+.2f}")
first 12 months: -0.81 (-0.99 to -0.63); truth -0.63
first 23 months: -0.97 (-1.15 to -0.80); truth -0.79
Quebec's counterfactual vs its pre-listing trend after February 2026: -0.11
Quebec's ITS is also about 0.18 too large. Quebec's counterfactual ran 0.11 below its own trend after February 2026: a smaller shock, but the same kind. Two provinces, two single-series designs, two estimates that are too large. Tomorrow's design uses one province as the other's comparison, so that shocks common to both cancel. Whether that helps depends on whether the provinces move together.
31.6 Before and after (20 min)
Bug of the day. The quickest analysis is to compare the average before with the average after:
"""Day 31 bug of the day: comparing the average before with the average after."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.policy import load_panel, province_series # noqa: E402
s = province_series(load_panel(), "ON")
before, after = s[s.t < 57].sglt2_rate.mean(), s[s.t >= 57].sglt2_rate.mean()
print(f"mean SGLT2 starts per 1,000: before listing {before:.2f}, after {after:.2f}: change {after - before:+.2f} "
f"({100 * (after / before - 1):+.0f}%)")
last = s[(s.t >= 45) & (s.t < 57)].sglt2_rate.mean()
first = s[(s.t >= 57) & (s.t < 69)].sglt2_rate.mean()
print(f"12 months before vs 12 months after: {last:.2f} vs {first:.2f}: change {first - last:+.2f}")
mean SGLT2 starts per 1,000: before listing 4.93, after 5.54: change +0.61 (+12%)
12 months before vs 12 months after: 5.75 vs 5.37: change -0.38
Averaged over all months, SGLT2 starts went up 12% after the listing: the opposite sign of the truth. The comparison mixes the policy with five years of growth. The narrower 12-months-before vs 12-months-after comparison gets the sign right (−0.38) but still includes a year of trend and a different mix of months. A before-after comparison is only valid when nothing else changes over time, and health care data always have trend and seasonality.
31.7 Mini-project: the ITS figure (50 min)
Make the figure a policy brief needs: observed points, the fitted series, and the projected counterfactual with its 95% band.
"""Day 31 mini-project: the ITS figure for a policy brief - observed, fitted, and the projected counterfactual."""
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 numpy as np # noqa: E402
import pandas as pd # noqa: E402
from corridor.db import ROOT # noqa: E402
from corridor.policy import its, load_panel, province_series # noqa: E402
s = province_series(load_panel(), "ON")
fit, d = its(s, "sglt2_rate", 57)
names = list(fit.model.exog_names)
x0 = fit.model.exog.copy()
x0[:, names.index("post")] = 0
x0[:, names.index("since")] = 0
b, v = np.asarray(fit.params), np.asarray(fit.cov_params())
mean, se = x0 @ b, np.sqrt(np.einsum("ij,jk,ik->i", x0, v, x0))
cf = pd.DataFrame({"mean": mean, "mean_ci_lower": mean - 1.96 * se, "mean_ci_upper": mean + 1.96 * se}, index=d.index)
fig, ax = plt.subplots(figsize=(8, 3.8))
ax.plot(d.month, d.sglt2_rate, "o", ms=3, color="#8b8d98", label="observed")
ax.plot(d.month, np.asarray(fit.fittedvalues), color="#a78bfa", lw=1.6, label="fitted")
m = d.post == 1
ax.plot(d.month[m], cf["mean"][m], color="#e5484d", lw=1.4, ls="--", label="projected without the listing")
ax.fill_between(d.month[m], cf.mean_ci_lower[m], cf.mean_ci_upper[m], color="#e5484d", alpha=0.15)
ax.axvline(d.month.iloc[57], color="black", lw=0.8)
ax.set_ylabel("SGLT2 starts per 1,000 per month")
ax.spines[["top", "right"]].set_visible(False)
ax.legend(frameon=False, fontsize=8, loc="upper left")
fig.tight_layout()
fig.savefig(os.path.join(ROOT, "figures", "day31_its.png"), dpi=150)
gap = (np.asarray(fit.fittedvalues) - cf["mean"].to_numpy())[m.to_numpy()]
print(f"wrote figures/day31_its.png; Ontario, Oct 2025-Dec 2027: about {-gap.mean():.2f} fewer SGLT2 starts per 1,000 "
f"per month ({-100 * gap.mean() / cf['mean'][m].mean():.0f}% of the projection)")
wrote figures/day31_its.png; Ontario, Oct 2025-Dec 2027: about 1.02 fewer SGLT2 starts per 1,000 per month (15% of the projection)

Write two sentences under it: the estimated effect over a stated period, and the main threat to validity. Here that threat is a coincident shock, which the truth check shows was real.
31.8 Save your work
python -m pytest -q
git add .
git commit -m "Day 31: interrupted time series of the Ontario listing"
Day 31 checklist
- I fit a segmented regression with trend, level change, slope change and seasonality
- I report the effect as the average gap to the counterfactual over a stated period
- I check autocorrelation and use GLS AR(1) rather than trusting Newey–West with short series
- I never compare averages before and after
- I name the history threat and look for events at the same time as the policy
Bloc français (30 min)
Thème : la série chronologique interrompue.
Pour évaluer l'inscription du Renavex sur la liste de l'Ontario, on ajuste la tendance des mois précédents et on la prolonge comme scénario contrefactuel. L'écart entre les données observées et ce scénario mesure l'effet de la politique. Les résidus mensuels sont autocorrélés : il faut en tenir compte, sinon les intervalles de confiance sont trop étroits. Tout événement survenu au même moment sera attribué à la politique.
| Français | English |
|---|---|
| la série chronologique interrompue | the interrupted time series |
| la régression segmentée | segmented regression |
| la tendance | the trend |
| le changement de niveau | the level change |
| le changement de pente | the slope change |
| la saisonnalité | seasonality |
| l'autocorrélation | autocorrelation |
| le scénario contrefactuel | the counterfactual scenario |
| l'inscription sur la liste | the formulary listing |
| la substitution | substitution |
| la menace à la validité | the threat to validity |
| un événement concomitant | a co-occurring event (history) |
Exercices
- Translate: "Over the first year, Ontario had about 13% fewer SGLT2 starts than projected."
- Translate: « Une comparaison avant-après confond la politique et la tendance. »
- In three French sentences, explain why Newey–West standard errors are not enough here.
Réponses
- Au cours de la première année, l'Ontario a enregistré environ 13 % moins d'amorces d'inhibiteurs du SGLT2 que prévu.
- "A before-after comparison confounds the policy with the trend."
- Example: Les erreurs types de Newey-West sont conçues pour les grands échantillons. Avec 84 mois, elles sous-estiment la variance quand les résidus sont autocorrélés. Un modèle des moindres carrés généralisés avec erreurs AR(1) en tient compte directement.