---
title: "CSSS/POLS 512"
subtitle: "Lab 4: Non-Stationary Time Series, ARDL/ECM, Cointegration, and ITS"
author: "Ramses Llobet"
date: "Spring 2026"
output:
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts]
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
      ratio: "16:9"
editor_options:
  chunk_output_type: console
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, fig.align = "center",
                      fig.width = 12, fig.height = 5.5,
                      warning = FALSE, message = FALSE,
                      dev = "svg", fig.retina = 2)
library(forecast)
library(MASS)
library(patchwork)
library(tidyverse)
set.seed(512)
```

# Today's Plan

.pull-left[
**Part 1: Diagnosing Non-Stationarity**
- Three flavors: TS, DS, breaks
- ADF & KPSS pitfalls
- The diagnostic trap

**Part 2: ARMAX with Breaks**
- Bush approval misdiagnosis
- Differencing destroys structure

**Part 3: ARDL & Distributed Lags**
- Where the persistence lives
- Long-run multiplier, IRF, simulation
]

.pull-right[
**Part 4: ARDL → ECM**
- Algebraic bridge
- $\lambda$ as a coefficient

**If time permits:**

**Part 5: Cointegration & ECM**
- Balance & spurious regression
- US fiscal sustainability

**Part 6: Interrupted Time Series**
- Conditional ignorability
- BC carbon tax with covariates
]

---
class: inverse, center, middle

# Part 1: Diagnosing Non-Stationarity (Properly)

---

# Don't Just Difference It

The textbook recipe says:

> *"If it's non-stationary, take first differences and re-apply ARMA."*

--

That's right **only when the data are difference-stationary** (a true unit root).

For two other common cases — **trend-stationary** series and **stationary series with structural breaks** — differencing is the *wrong* cure:

- introduces a non-invertible MA root,
- can rescale persistent level shifts into one-period pulses (attenuation),
- produces ARIMA models with the wrong dynamics.

--

**Today's lesson:** *diagnose before you difference.*

---

# Three Flavors of Non-Stationarity

<img src="output/slides/p1_flavors.png" width="92%" style="display:block; margin:auto;" />

Each cure removes a different kind of non-stationarity. Differencing only fits flavor (b).

.footnote[*Code: `Lab4.Rmd` → §1.2*]

---

# ADF and KPSS — Complementary, Not Redundant

| ADF | KPSS | Conclusion |
|:----|:-----|:-----------|
| Reject $I(1)$ | Don't reject $I(0)$ | Stationary |
| Don't reject | Reject | Non-stationary (or unit root) |
| **Reject** | **Reject** | **Conflict — investigate (often a structural break)** |
| Don't reject | Don't reject | Inconclusive (low power) |

--

**Three pitfalls:** (i) low power against near-unit-root alternatives, (ii) verdict depends on deterministic regressors, (iii) structural breaks fool *both* tests in opposite directions (Perron 1989).

--

→ Tests are **diagnostics, not oracles.** Pair them with visual inspection and substantive knowledge.

---

# The Diagnostic Trap (Series C)

<img src="output/slides/p1_sim_series.png" width="68%" style="display:block; margin:auto;" />

| Series | Truth | ADF | KPSS | Verdict |
|:-------|:------|:----|:-----|:--------|
| A: AR(1) | I(0) | reject | don't reject | ✓ |
| B: random walk | I(1) | don't reject | reject | ✓ |
| **C: i.i.d. + level break** | **I(0)** | **don't reject** | **reject** | **✗ both fooled** |

**Series C** is the trap: tests *agree* on non-stationarity, but the truth is "stationary within each regime."

.footnote[*Code: `Lab4.Rmd` → Appendix A.1*]

---
class: inverse, center, middle

# Part 2: ARMAX with Breaks — The Approval Misdiagnosis

---

# Bush Approval, 2001–2006

<img src="output/slides/p2_approval_plot.png" width="92%" style="display:block; margin:auto;" />

Monthly $T = 65$. Two pulse dummies (9/11, Iraq War) plus oil price. The ACF decays slowly — textbook reflex says *"unit root, difference it."*

---

# Three Tests, Three Verdicts

| Test | $H_0$ | $p$-value | Verdict |
|:-----|:------|:---------|:--------|
| ADF (constant + trend) | unit root | $0.017$ | **reject** ⇒ stationary |
| KPSS (Level) | stationary around $\mu$ | $0.010$ | reject ⇒ non-stationary |
| KPSS (Trend) | stationary around trend | $0.100$ | don't reject ⇒ trend-stationary |

ADF and KPSS-Trend agree: **trend-stationary with two pulse interventions.**  KPSS-Level rejects only because it (wrongly) assumed a constant mean.

→ **Pitfall 2 from Part 1**: same series, different deterministic specification, opposite verdicts.

---

# Naïve ARIMA(1,1,0) vs. ARMAX(1,0,0)

<img src="output/slides/p2_coef_compare.png" width="92%" style="display:block; margin:auto;" />

- **ARIMA(1,1,0):** $\hat\phi = 0.07$, s.e. $0.13$ — persistence has been *destroyed* by overdifferencing.
- **ARMAX(1,0,0):** $\hat\phi = 0.92$, s.e. $0.05$ — persistence recovered; coefficients on level of approval.

.footnote[*Code: `Lab4.Rmd` → §2.6*]

---
class: inverse, center, middle

# Part 3: ARDL — Distributed Lags and Dynamic Effects

---

# From ARMAX to ARDL

ARMAX gives intervention effects on the level, but **covariate effects don't propagate**. To trace dynamic adjustment, add lags of $x$ and $y$:

$$y_t = \alpha + \phi\, y_{t-1} + \beta_0 x_t + \beta_1 x_{t-1} + \varepsilon_t \tag{ARDL(1,1)}$$

Three quantities of interest:

1. **Long-run multiplier** $\theta_{LR} = \frac{\beta_0 + \beta_1}{1 - \phi}$ — destination
2. **Speed of adjustment** $\lambda = 1 - \phi$ — pace
3. **Impulse-response trajectory** — path

For approval/oil: $\hat\theta_{LR} \approx -0.19$ (10-unit oil shock $\Rightarrow$ ~1.9 pp drop), half-life ~4 months.

---

# Two Stories of Persistence

When a series is autocorrelated, where does the persistence *live*?

--

.pull-left[
**Story A — shocks themselves persist**

$$y_t = X_t\beta + u_t,$$
$$u_t = \phi\, u_{t-1} + \varepsilon_t$$

AR coefficient on the **errors**.

`Arima(y, xreg = X, order = c(1,0,0))`

Covariates do **not** propagate.
]

--

.pull-right[
**Story B — yesterday's $y$ shapes today's**

$$y_t = \alpha + \phi\, y_{t-1} + X_t\beta + \varepsilon_t$$

AR coefficient on **$y$ itself**.

`lm(y ~ lag(y) + X)`

Covariates **propagate** through $y$.
]

--

These are **different models**, not different estimators of the same model.

.footnote[*Code: `Lab4.Rmd` → §3.1*]

---

# Same Equation, Different Restrictions

Both stories are *nested* in the unrestricted ARDL(1,1):

$$y_t = \alpha + \phi\, y_{t-1} + \beta_0 X_t + \beta_1 X_{t-1} + \varepsilon_t$$

| Specification | Restriction | Long-run multiplier |
|:---|:---|:---:|
| **Unrestricted ARDL(1,1)** | none | $(\beta_0+\beta_1)/(1-\phi)$ |
| Story A (AR errors) | $\beta_1 = -\phi\beta_0$ — **COMFAC** | $\beta_0$ |
| Story B (LDV-only) | $\beta_1 = 0$ — partial adjustment | $\beta_0/(1-\phi)$ |

--

The COMFAC restriction's lagged-$X$ coefficient *exactly cancels* the LDV propagation that Story B would generate. Same algebraic family — different long-run predictions.

.footnote[*De Boef & Keele 2008, Table 1, p. 187.*]

---

# Same $\beta$, Same $\phi$ — Different LRM

<img src="output/slides/p3_two_stories_irf.png" width="78%" style="display:block; margin:auto;" />

.font90[
**Top:** covariate shock — Story A flat, Story B rises to $\beta/(1-\phi) = 5$.
**Bottom:** innovation shock — *identical* $\phi^t$ decay in both stories.
]

**Innovations propagate the same way; covariates don't.** That asymmetry is the COMFAC restriction.

---

# Match the Estimator to the Spec

| Specification | Estimator | $\hat\beta$ unbiased? | Consistent? | SE correct? |
|:---|:---|:---:|:---:|:---:|
| Static + AR errors | naive OLS | ✓ | ✓ | ✗ |
| Static + AR errors | GLS / `Arima` | ✓ | ✓ | ✓ |
| LDV + WN errors | `lm(...)` | ✗ ($O(1/T)$) | ✓ | ✓ |
| LDV + AR errors | OLS | ✗ | ✗ | ✗ |

--

**Not** "don't use OLS in row 4" — instead, "fix the spec so OLS has nothing left to ignore." Add lags of $y$ until BG passes (still OLS), or move to ML/`Arima`. **Almost all of our work lives in rows 2 or 3.**

--

**Discipline:** fit *unrestricted* ARDL, test the restrictions:

- Partial adjustment $H_0$: $\beta_1 = 0$ — standard $t$-test.
- COMFAC $H_0$: $\beta_1 + \phi\beta_0 = 0$ — nonlinear Wald, $\chi^2_1$.

For our approval/oil ARDL: $\hat g = -0.026$, $W \approx 3.6$, $p \approx 0.06$ — **borderline**. Choose Story A or B by *theory*, then read the LRM with the formula matching that choice.

.footnote[*Code: `Lab4.Rmd` → §3.1 (Wald test on approval data).*]

---

# Fixing Biased SEs in DL: Three Routes

When DL residuals are autocorrelated, three routes — two stay within **Story A**, one moves to **Story B**:

| Route | Tool | Story | What it fixes |
|:------|:-----|:-----|:--------------|
| **HAC** | `coeftest(fit, vcov = NeweyWest(fit))` | A | SEs only; estimates unchanged |
| **GLS-AR(1)** | `gls(y ~ x, correlation = corAR1())` | A | Both estimates and SEs (under correct $\Omega$) |
| **ARDL** | `lm(y ~ y_lag + x + x_lag)` | **B** | Dissolves the problem — moves dynamics into the mean equation |

--

HAC and GLS *patch inference within Story A*; ARDL is the **structural move to Story B**. Choose Option B (LDV) only when there's a substantive theory for $y_{t-1}$ causing $y_t$ (Cook & Webb 2021).

.footnote[*Code: `Lab4.Rmd` → §3.2 (HAC + GLS-AR(1)) and §3.3 (ARDL).*]

---

# Impulse Response with 95% CI

<img src="output/slides/p3_ardl_irf.png" width="78%" style="display:block; margin:auto;" />

**Parametric simulation (King–Tomz–Wittenberg).** Draw $\beta^{(s)} \sim \mathcal{N}(\hat\beta, V(\hat\beta))$ for $s = 1, \ldots, 1000$, compute IRF on each draw, take pointwise quantiles.

Wraps as a reusable `simulate_dynamic(fit, fn, H)` function — reused in Parts 4–5.

.footnote[*Code: `Lab4.Rmd` → §3.5*]

---
class: inverse, center, middle

# Part 4: ARDL → ECM (Algebraic Bridge)

---

# Two Parameterizations of the Same Model

$$y_t = \alpha + \phi\, y_{t-1} + \beta_0 x_t + \beta_1 x_{t-1} + \varepsilon_t \tag{ARDL}$$

is algebraically identical to

$$\Delta y_t = \alpha + \beta_0\, \Delta x_t - \lambda\, \bigl(y_{t-1} - \theta\, x_{t-1}\bigr) + \varepsilon_t \tag{ECM}$$

with $\lambda = 1 - \phi$ and $\theta = (\beta_0 + \beta_1)/(1 - \phi)$.

--

**Why bother?**

- $\lambda$ is now a **coefficient** with a $t$-test, not a derived quantity.
- The short-run/long-run decomposition is *visible* in the regression.
- The bracketed deviation $(y_{t-1} - \theta\, x_{t-1})$ is the **bridge to cointegration** in Part 5.

Same data, same residuals, same fit. *Reparameterization, not a new model.*

---
class: inverse, center, middle

# Part 5 *(if time permits)*: Cointegration and a Real ECM

---

# Balance: When Is a Regression in Levels Well-Behaved?

A regression is **balanced** when both sides have the same order of integration.

| $y$ | $x$ | residual $u_t$ | What you have |
|:---|:---|:---|:---|
| I(0) | I(0) | I(0) | **Standard.** $\sqrt{T}$-asymptotic normality. |
| I(1) | I(1) | **I(1)** | **Spurious regression.** $t$-stats diverge. |
| I(1) | I(1) | **I(0)** | **Cointegration.** $\hat\theta$ super-consistent (rate $T$). |
| I(1) | I(0) (or vice versa) | — | Only OK with ARDL/LDV or bounds testing |

--

**Cointegration = the I(1) version of balance.** Without it, regressing two trending series on each other is the spurious-regression trap. With it, the same regression recovers a long-run relationship.

---

# US Fiscal Sustainability: Engle-Granger

**Question:** are federal receipts and expenditures cointegrated? (i.e., is debt growth bounded?)

Three steps:

1. **Verify each is I(1)** — ADF doesn't reject; KPSS rejects. Both are I(1). ✓
2. **Estimate long-run relationship** by static OLS: $\hat\theta \approx 0.95$. Test the Stage-1 residual for stationarity (ADF on $\hat z_t$, MacKinnon CVs). Cointegration holds. ✓
3. **Estimate ECM:** $\hat\lambda \approx 0.06$ per quarter $\Rightarrow$ half-life ~11 quarters.

--

**Bottom line:** receipts cover ~95% of expenditures in long-run equilibrium; deviations correct at 6%/quarter.  US fiscal policy is *sustainable but slow.*

.footnote[*Code: `Lab4.Rmd` → §5.2–5.5*]

---
class: inverse, center, middle

# Part 6 *(if time permits)*: Interrupted Time Series (ITS)

---

# ITS as a Quasi-Experimental Design

Causal effect = observed post-period vs. *projected* counterfactual built from the pre-period model:

$$y_t = \beta_0 + \beta_1 t + \beta_2 D_t + \beta_3 S_t + \varepsilon_t$$

with $D_t = \mathbf{1}\{t \geq T^*\}$ (regime), $S_t = (t-T^*)\,D_t$ (time-since). $\beta_2$ = immediate level shift; $\beta_3$ = slope change.

--

**Identifying assumption — conditional ignorability of treatment timing.** Once we condition on the covariates and dynamics our model includes, the post-period would have followed the pre-period model in expectation, absent the intervention. The pre-trend would have continued — *if our model captures everything that mattered*.

---

# What ITS Assumes — Defend Each Piece

1. **No anticipation.** Agents don't respond to the policy *before* $T^*$. Date of policy = date of response.
   *Defense:* announcement dummies + ramp (§6.4); restrict the analysis window.

2. **Stable pre-trend (conditional).** Pre-period model — given covariates and AR structure — would have continued.
   *Defense:* substantively-justified covariates (§6.3); AR errors (§6.5); placebo dates.

3. **No co-occurring shocks.** Nothing else affecting $y$ also changes at $T^*$.
   *Defense:* condition on observables; or use a *true* untreated control (CITS).

4. **Stable measurement.** No instrument/coding/sample-frame change at $T^*$.

--

**The assumption is the substance.** Asserting it by default is the most common form of weak inference in applied ITS. *Modeling choices are the operational tool.*

.footnote[*Code: `Lab4.Rmd` → §6.1.1*]

---

# Visualizing the Design — Example 1: Level + Slope

<img src="output/slides/p6_its_levelslope.png" width="86%" style="display:block; margin:auto;" />

.font90[
- **Solid blue** = mean function. **Dashed grey** = counterfactual (extrapolated pre-trend).
- $\beta_2$ = vertical jump at $T^*$. $\beta_3$ = slope difference after $T^*$.
- **Effect at horizon $h$** = vertical gap (red shading) at $T^* + h$ — grows over time when $\beta_3 \neq 0$.
]

---

# Visualizing the Design — Example 2: Pulse

<img src="output/slides/p6_its_pulse.png" width="86%" style="display:block; margin:auto;" />

.font90[
- One-period spike $\omega$ at $T^*$; immediate return to trend in $t = T^* + 1$.
- Use when the intervention is a single news event, an election day, a quickly-reversed policy.
- **Permanent vs. transient** — the central pedagogical contrast with Example 1.
]

---

# Modeling Choices = Identification Commitments

| Choice | Threat addressed | When justified |
|:---|:---|:---|
| **Covariates $X_t$** | Time-varying observable confounders | Theory says they're confounders (oil price → gasoline) |
| **AR errors** | Persistent unmodeled noise | Substantive process has dynamic noise |
| **LDV** | Genuine state-dependence | Theory predicts momentum (Cook & Webb caveat) |
| **Anticipation/ramp** | Agents respond before $T^*$ | Policy was credibly pre-announced |
| **True control unit (CITS)** | Common shocks | An untreated control unit *exists* |

--

**Theory first.** AIC/BIC will let you add or drop any of these. Only theory tells you which are defensible — and which strengthen conditional ignorability.

---

# A Credibility Ladder (Single-Policy Designs)

1. **Single-unit ITS** — pre-trend extrapolation does all the identification work.
2. **+ Falsification** — placebo dates, alt. pre-periods, covariate sensitivity.
3. **CITS** — *true* untreated control absorbs common shocks; interactions identify the differential.

--

**Critically:** CITS requires a control unit that does **not** receive the intervention. If the policy hits all units uniformly (federal law, no opt-out, global event), the differential is zero by symmetry — CITS doesn't apply.

--

When a true control isn't available, **exit ramps live in design space, not model space:**

- **Synthetic control** — weighted donor pool; factor-model assumption.
- **Panel diff-in-diff** — many treated/untreated units; parallel trends *across* units.

Different identification assumptions, **not strict upgrades**. Different commitments for different settings.

---

# AR Errors vs. Lagged $y$ in ITS

Same Story-A-vs-Story-B choice from Part 3:

**Option A — AR errors.** `Arima(y, xreg = X, order = c(p,0,q))`. AR structure as *nuisance*; coefficients keep their causal meaning.

**Option B — LDV.** $y_t = \cdots + \rho\, y_{t-1} + u_t$. AR structure as *structural propagation*; past $y$ **causes** future $y$.

--

**B is defensible only with theory.** Sticky prices/wages, habit formation, capital accumulation — yes. Correlated polling noise, slow-moving omitted variables — no.

**Default to A** when in doubt; it makes the strictly weaker claim.

---

# BC Carbon Tax (Jul 2008): Identifying the Pre-Trend

Monthly BC gasoline sales, 1993–2015. Carbon tax effective 1 July 2008 ($10/tCO₂, 2.34 ¢/L). Global oil prices spiked and crashed during the same window.

| Specification | $\hat\beta_2$ (level change) | log(price) elasticity |
|:---|---:|---:|
| Bare ITS (form a, no covariates) | $-0.049$ ($-4.9\%$) | — |
| **+ log(retail price)** | $-0.039$ ($-3.9\%$) | $-0.17$ |
| + announcement dummy | $-0.029$ (n.s.) | $-0.16$ |
| AR(1) errors | $-0.039$ | $-0.16$ |

--

**Reading the table.** The bare ITS overstates the tax effect by ~25% — it attributes the global oil-price spike to BC's local policy. Conditioning on retail price brings the estimate to a defensible ~3–4% drop and recovers a textbook elasticity. Anticipation effect at announcement is small and not significant. AR(1) correction barely moves the headline.

.footnote[*Code: `Lab4.Rmd` → §6.2–6.5*]

---

# Summary

**Today we covered the methodological progression:**

- **Part 1:** Diagnose non-stationarity *before* differencing.
- **Part 2:** Differencing destroys structure; ARMAX recovers it.
- **Part 3:** ARDL gives the *path*, not just the destination — with simulation-based CIs.
- **Part 4:** ARDL ↔ ECM is an algebraic identity, not a new model.
- **Part 5:** Cointegration is the I(1) version of balance.
- **Part 6:** ITS gives causal estimates *if* the counterfactual is defensible — covariates make it more defensible.

--

**Self-study (lab Appendix):**

- A.1 — ADF and KPSS false-positive simulation

**Next time (Lab 5):** Panel data — fixed effects, random effects, CRE/Mundlak.

---

# Selected References

.font80[
**Audited core (literature folder):**

- [Box-Steffensmeier, Freeman, Hitt & Pevehouse (2014)](https://www.cambridge.org/core/books/time-series-analysis-for-the-social-sciences/16E0BBE6E2D6CD7E5F62FC937B9F0117). *Time Series Analysis for the Social Sciences*. Cambridge UP.
- [Cook & Webb (2021)](https://doi.org/10.1017/pan.2020.43). Lagged outcomes, lagged predictors, and lagged errors. *Political Analysis*, 29(4).
- [De Boef & Keele (2008)](https://doi.org/10.1111/j.1540-5907.2007.00307.x). Taking time seriously. *AJPS*, 52(1).
- [Keele & Kelly (2006)](https://doi.org/10.1093/pan/mpj006). Dynamic models for dynamic theories. *Political Analysis*, 14(2).
- [Philips (2018)](https://doi.org/10.1111/ajps.12318). Have your cake and eat it too: cointegration and ARDL. *AJPS*, 62(1).

**Methods cited inline:**

- [Bernal, Cummins & Gasparrini (2017)](https://doi.org/10.1093/ije/dyw098). Interrupted time series for public-health interventions. *Int J Epidemiol*, 46(1).
- [Engle & Granger (1987)](https://doi.org/10.2307/1913236). Co-integration and error correction. *Econometrica*, 55(2).
- [Hakkio & Rush (1991)](https://doi.org/10.1111/j.1465-7295.1991.tb00837.x). Is the budget deficit "too large"? *Economic Inquiry*, 29(3).
- [King, Tomz & Wittenberg (2000)](https://doi.org/10.2307/2669316). Making the most of statistical analyses. *AJPS*, 44(2).
- [MacKinnon (2010)](https://www.econ.queensu.ca/sites/econ.queensu.ca/files/qed_wp_1227.pdf). Critical values for cointegration tests.
- [Murray & Rivers (2015)](https://doi.org/10.1016/j.enpol.2015.08.011). BC's revenue-neutral carbon tax. *Energy Policy*, 86.
- [Newey & West (1987)](https://doi.org/10.2307/1913610). HAC covariance matrix. *Econometrica*, 55(3).
- [Pesaran, Shin & Smith (2001)](https://doi.org/10.1002/jae.616). Bounds testing for level relationships. *J Appl Econometrics*, 16(3).
- [Perron (1989)](https://doi.org/10.2307/1913712). Great crash, oil price shock, unit root. *Econometrica*, 57(6).
]

---
class: inverse, center, middle

# Questions?
