Study Notes

Time Series

Real series carry trend, seasonality, and changing variance; the first job is always to strip those until the residual is stationary, because stationarity — constant mean, and a covariance depending only on lag — is the only regime where averaging over time substitutes for the repeated samples we never get. Once stationary, every model is one object, the backshift polynomial ϕ(B)Xt=θ(B)Zt\phi(B)X_t=\theta(B)Z_t, and the roots of those polynomials decide causality, invertibility, the autocorrelation shape, and the spectrum. Running underneath is a second thread, the time ↔ frequency duality: the autocovariance and the spectral density hold the same information in two bases, and you transform to whichever makes the next step easy. Prerequisites cashed in: stationarity and Markov structure (track 5 §1, §6), MLE/CLT/χ² tests and the delta method (track 3), Toeplitz systems and projection (track 2), EM and the forward recursion (track 7 §6, §8).

1. The frame and stationarity

Picture to hold. A time series is one realization of a stochastic process indexed by time. You see a single path, not repeated samples — so you cannot estimate “the distribution at time tt” by averaging many draws. The only thing that rescues estimation is an assumption that the process looks the same after a time shift: then averaging over time substitutes for averaging over realizations. That assumption is stationarity, and it is the hinge of the whole subject.

The working decomposition for a raw series:

Xt=mt+st+ZtX_t = m_t + s_t + Z_t
  • mtm_t = trend (slow secular movement),
  • sts_t = seasonality (periodic, known period dd, st+d=sts_{t+d}=s_t),
  • ZtZ_t = the stationary residual we actually model.

White noise is the baseline residual: mean zero, finite variance, uncorrelated across time.

  • White noise (WN): EZt=0E Z_t = 0, Var(Zt)=σ2<\mathrm{Var}(Z_t)=\sigma^2<\infty, Cov(Zs,Zt)=0\mathrm{Cov}(Z_s,Z_t)=0 for sts\neq t.
  • iid noise: WN and independent (stronger — kills nonlinear dependence too).
  • Gaussian WN: iid noise with ZtN(0,σ2)Z_t\sim N(0,\sigma^2).

White noise has no exploitable structure — you cannot predict it from its past. So the entire modeling pipeline is: transform → fit → check the residuals are white noise. If they are, you have extracted all the linear signal; if they aren’t, there is structure left to model.

Strict vs weak stationarity

Strictly stationary: the joint distribution of {Xt1,,Xtk}\{X_{t_1},\dots,X_{t_k}\} equals that of the shifted block {Xt1+h,,Xtk+h}\{X_{t_1+h},\dots,X_{t_k+h}\} for every hh and every collection. The entire probabilistic law is shift-invariant.

That is far more than we can check or need. We weaken it to the first two moments:

Weakly (second-order) stationary: finite variance, and

  • (i) EXt=μE X_t = \mu constant (no trend),
  • (ii) Cov(Xt,Xt+h)=γ(h)\mathrm{Cov}(X_t, X_{t+h}) = \gamma(h) depends on the lag hh only, not on tt.

“Stationary” unqualified means weakly stationary — it is the realistic assumption. Two immediate consequences:

  • The autocovariance collapses to a one-argument function γ(h)\gamma(h), and it is symmetric: γ(h)=γ(h)\gamma(-h)=\gamma(h) (since Cov(Xt,Xt+h)=Cov(Xt+h,Xt)\mathrm{Cov}(X_t,X_{t+h})=\mathrm{Cov}(X_{t+h},X_t)).
  • The autocorrelation is ρ(h)=γ(h)/γ(0)\rho(h)=\gamma(h)/\gamma(0), with ρ(0)=1\rho(0)=1.

Strict ⟹ weak always (matching whole laws forces matching moments), but not conversely.

Counterexample (weak ⇏ strict). Build a series that is Gaussian WN on even tt and centered-and-rescaled χ2\chi^2 WN on odd tt, with the two arranged to share mean 00 and variance σ2\sigma^2. Every covariance is 00 and the mean is constant, so it is weakly stationary — yet the marginal distribution differs between even and odd tt, so it is not strictly stationary. Matching moments is not matching laws.

Special case (Gaussian). For a Gaussian process (every finite block is multivariate normal) the law is determined by mean and covariance, so weak ⟺ strict. This is why Gaussian assumptions are so convenient here.

Not stationary: a random walk (covariance grows with tt), anything with a trend (mean depends on tt), ARCH-type changing variance.

Diagnostic picture. Take two windows from the series and overlay their histograms. Stationary → the histograms overlap. Non-stationary (trend or changing variance) → they separate or spread.

Measuring dependence: ACF and the correlogram

Autocorrelation function ρ(h)\rho(h) — the correlation of the series with itself hh steps back. We estimate it with the sample ACF:

rk=t=1nk(XtXˉ)(Xt+kXˉ)t=1n(XtXˉ)2.r_k = \frac{\sum_{t=1}^{n-k}(X_t-\bar X)(X_{t+k}-\bar X)}{\sum_{t=1}^{n}(X_t-\bar X)^2}.

White-noise test. Under WN, for fixed lag kk and large nn (a CLT result — cross-link [[03_Statistical_Inference]]):

n(r1,,rk)dN(0,I),i.e.rkapproxN(0,1/n).\sqrt{n}\,(r_1,\dots,r_k)^\top \xrightarrow{d} N(0, I), \qquad\text{i.e.}\qquad r_k \overset{\text{approx}}{\sim} N(0, 1/n).

So a single rkr_k outside ±1.96/n\pm 1.96/\sqrt n is significant evidence against white noise at 5%. Plot the rkr_k with bands at ±1.96/n\pm1.96/\sqrt n — that plot is the correlogram.

Numeric anchor. n=100n=100 \Rightarrow bands at ±1.96/100=±0.196±0.2\pm 1.96/\sqrt{100}=\pm0.196\approx\pm0.2. Lag 0 is always 11.

Multiple-testing trap. With kk lags plotted, the expected number exceeding the bands under pure white noise is E[i=1k1(ri>1.96/n)]=i=1k0.05=0.05k.E\Big[\sum_{i=1}^{k}\mathbf 1(|r_i|>1.96/\sqrt n)\Big]=\sum_{i=1}^k 0.05 = 0.05k. For k=40k=40 lags you expect 22 exceedances even if the data is genuinely white noise. Never read a single border-crossing as proof of structure; this is exactly why §5 needs a joint (portmanteau) test, not eyeballing.

Implications of §1.

  • Stationarity is what makes “average over time = average over the ensemble” legitimate; without it, estimation has no ground to stand on.
  • The modeling loop is transform until residuals pass the white-noise test. Everything downstream is machinery for that loop.
  • γ\gamma being a function of lag alone is what later lets prediction reduce to a Toeplitz linear system (§5) — cross-link [[02_Linear_Algebra]].

Core competency set §1.

  • State weak stationarity (two conditions) and why γ(h)=γ(h)\gamma(-h)=\gamma(h).
  • Reproduce the WN band ±1.96/n\pm1.96/\sqrt n and the expected-exceedances calculation.
  • Give the weak-but-not-strict counterexample and the Gaussian weak⟺strict fact.

2. Getting to stationary: trend, season, variance

The residual ZtZ_t is what we model, so first remove mtm_t, sts_t, and any mean-dependent variance.

Trend estimation

Three routes, increasing in assumption-freedom:

  1. Parametric: posit a form, e.g. quadratic m^t=α^+β^t+γ^t2\hat m_t=\hat\alpha+\hat\beta t+\hat\gamma t^2 by least squares. Accurate if the form is right; gives clean forecasts; risks misspecification.
  2. Smoothing/filtering: local average m^t=12q+1j=qqXt+j\hat m_t=\frac{1}{2q+1}\sum_{j=-q}^{q}X_{t+j}. Window qq is a bias–variance dial — small qq low bias/high variance, large qq the reverse. No forecasts at the endpoints, no clean extrapolation.
  3. Isotonic (monotone trend): minimize t(Xtat)2\sum_t (X_t-a_t)^2 s.t. a1ana_1\le\cdots\le a_n — a convex program. Rarely used; can’t forecast; degenerate on already-monotone data (returns the data, residual 00, learns nothing).

Caution (ML models extrapolate flat). A random forest fit to a trended series predicts a constant outside the training range — it averages the last values and cannot continue a trend. It sees no time structure. This is the recurring weakness of memory-based methods here.

Differencing — remove the trend without estimating it

Define the difference operator Xt=XtXt1\nabla X_t = X_t-X_{t-1}.

Linear trend, worked. Xt=at+ZtX_t=at+Z_t. Then Xt=(at+Zt)(a(t1)+Zt1)=a+ZtZt1.\nabla X_t = (at+Z_t)-(a(t-1)+Z_{t-1}) = a + Z_t - Z_{t-1}. Constant mean aa, no trend. One difference kills a linear trend.

Quadratic trend, worked. Xt=t2X_t=t^2 (noiseless). Xt=t2(t1)2=2t1\nabla X_t = t^2-(t-1)^2 = 2t-1 — still trending. Difference again: 2Xt=XtXt1=(2t1)(2(t1)1)=2.\nabla^2 X_t = \nabla X_t - \nabla X_{t-1} = (2t-1)-(2(t-1)-1) = 2. A degree-pp polynomial trend needs pp differences.

Counterexample / caution (over-differencing). Differencing white noise introduces autocorrelation: if Xt=ZtX_t=Z_t then Xt=ZtZt1\nabla X_t=Z_t-Z_{t-1} has Cov(Xt,Xt1)=σ20\mathrm{Cov}(\nabla X_t,\nabla X_{t-1})=-\sigma^2\neq 0. So you can manufacture spurious structure by differencing too many times. Difference, check the ACF, stop at the lowest order that looks white.

Forecasting back through differencing. If Xt\nabla X_t has mean cc, invert: X^t=c+Xt1\hat X_t = c + X_{t-1}. For 2\nabla^2: since 2Xt=Xt2Xt1+Xt2\nabla^2 X_t = X_t-2X_{t-1}+X_{t-2}, forecast X^t=c+2Xt1Xt2\hat X_t = c + 2X_{t-1}-X_{t-2}.

Stochastic trend. A random-walk-with-drift trend mt=mt1+δ+Wtm_t=m_{t-1}+\delta+W_t is not deterministic, but differencing still removes it — another reason to prefer differencing when you don’t want to commit to a trend form.

Seasonality

Model Xt=st+ZtX_t = s_t + Z_t with sts_t periodic of known period dd (monthly→d=12d{=}12, weekly→d=7d{=}7). Two approaches:

  • Harmonic regression: st=a0+f=1k(afcos(2πft/d)+bfsin(2πft/d))s_t = a_0 + \sum_{f=1}^{k}\big(a_f\cos(2\pi f t/d)+b_f\sin(2\pi f t/d)\big). Start at low frequency ff (the big oscillations), add higher ff for finer structure — a bias–variance dial again. Linear in (af,bf)(a_f,b_f), so ordinary least squares fits it.
  • Seasonal differencing: dXt=XtXtd\nabla_d X_t = X_t - X_{t-d}. With Xt=st+ZtX_t=s_t+Z_t and st=stds_{t}=s_{t-d},
dXt=(ststd)+(ZtZtd)=ZtZtd,\nabla_d X_t = (s_t - s_{t-d}) + (Z_t - Z_{t-d}) = Z_t - Z_{t-d},

mean zero. You lose a full period dd of observations. For trend and season, seasonal-difference first, then ordinary-difference the result.

Variance-stabilizing transforms (delta method)

Heteroscedastic data — e.g. variance growing with the level — breaks stationarity through condition (i)/(ii) on the transformed scale. Suppose Var(Xt)=g(μt)\mathrm{Var}(X_t)=g(\mu_t) for known gg. Find ff so that Yt=f(Xt)Y_t=f(X_t) has roughly constant variance.

Derivation (delta method — cross-link [[03_Statistical_Inference]]). Taylor-expand ff about μt\mu_t:

f(Xt)f(μt)+f(μt)(Xtμt).f(X_t) \approx f(\mu_t) + f'(\mu_t)(X_t-\mu_t).

Here f(μt)f(\mu_t) is deterministic; only the last term is random. So

Var(Yt)(f(μt))2Var(Xt)=(f(μt))2g(μt).\mathrm{Var}(Y_t) \approx \big(f'(\mu_t)\big)^2\,\mathrm{Var}(X_t) = \big(f'(\mu_t)\big)^2 g(\mu_t).

Choose ff to make the right side constant.

Numeric anchors.

  • Var(Xt)=Cμt\mathrm{Var}(X_t)=C\mu_t (count-like). Try f(x)=xf(x)=\sqrt x: (12μ)2Cμ=C/4\big(\tfrac{1}{2\sqrt{\mu}}\big)^2 C\mu = C/4, constant. → square-root transform, standard for counts.
  • Var(Xt)=Cμt2\mathrm{Var}(X_t)=C\mu_t^2 (multiplicative / compounding). Try f(x)=logxf(x)=\log x: (1μ)2Cμ2=C\big(\tfrac1\mu\big)^2 C\mu^2 = C, constant. → log transform, standard for stock-like data.

Transforms are not unique (f(x)=2x1f(x)=2\sqrt x-1 works as well as x\sqrt x); pick the simplest.

Implications of §2.

  • Pipeline order: variance-stabilize → de-trend (difference or regress) → de-season → check residual ACF.
  • Differencing trades estimation for robustness — you remove trend without committing to its shape — but over-differencing injects negative autocorrelation, so it has its own cost.
  • The square-root/log dichotomy (variance ∝ mean vs ∝ mean²) is worth memorizing; it recurs in GLMs (Poisson vs lognormal).

Core competency set §2.

  • Difference a linear and a quadratic trend by hand; invert a one-step and two-step difference for forecasting.
  • Derive the variance-stabilizing condition (f)2g=const(f')^2 g = \text{const} and produce \sqrt{\cdot} / log\log for the two canonical gg‘s.
  • Explain why over-differencing is harmful and how seasonal differencing works.

3. MA and AR models — the backshift polynomial

Now the residual is stationary. The two atoms are moving-average (build the present from past noise) and autoregressive (build the present from past values). The unifying device is the backshift operator BB: BXt=Xt1BX_t=X_{t-1}, BjXt=XtjB^j X_t = X_{t-j}.

Moving average MA(q)

Xt=Zt+θ1Zt1++θqZtq=θ(B)Zt,θ(B)=1+θ1B++θqBq.X_t = Z_t + \theta_1 Z_{t-1} + \cdots + \theta_q Z_{t-q} = \theta(B)Z_t,\qquad \theta(B)=1+\theta_1 B+\cdots+\theta_q B^q.

A finite linear combination of white-noise shocks (not a true average — just a linear model in the ZZ‘s).

MA(1) is weakly stationary — worked. Xt=Zt+θZt1X_t=Z_t+\theta Z_{t-1}, Var(Zt)=σ2\mathrm{Var}(Z_t)=\sigma^2.

EXt=0,Var(Xt)=σ2+θ2σ2=σ2(1+θ2).E X_t = 0,\qquad \mathrm{Var}(X_t) = \sigma^2 + \theta^2\sigma^2 = \sigma^2(1+\theta^2). Cov(Xt,Xt1)=Cov(Zt+θZt1,Zt1+θZt2)=θσ2,\mathrm{Cov}(X_t,X_{t-1}) = \mathrm{Cov}(Z_t+\theta Z_{t-1},\, Z_{t-1}+\theta Z_{t-2}) = \theta\sigma^2, Cov(Xt,Xtj)=0(j>1).\mathrm{Cov}(X_t,X_{t-j}) = 0 \quad (j>1).

No tt appears → weakly stationary. Every MA(q) is weakly stationary (finitely many shocks, constant-in-tt covariances). The general autocovariance:

γ(h)=σ2j=0qhθjθj+h(0hq),γ(h)=0 (h>q).\gamma(h) = \sigma^2\sum_{j=0}^{q-h}\theta_j\theta_{j+h}\quad(0\le h\le q),\qquad \gamma(h)=0\ (h>q).

Signature in the ACF. MA(q) autocorrelations are nonzero up to lag qq then cut off sharply to zero. (Contrast AR, which decays exponentially without a hard cutoff — §3 AR.) Seeing a clean cutoff at lag qq is the fingerprint of MA(q).

Invertibility — pinning down the parameters

Two different MA models can generate the same process, so the parameters aren’t identified without a restriction.

The two-representations problem, worked (Gaussian). With σ2=1\sigma^2=1, Xt=Zt+θZt1X_t=Z_t+\theta Z_{t-1} has Var=1+θ2\mathrm{Var}=1+\theta^2, Cov1=θ\mathrm{Cov}_1=\theta. Now set Z~t=θZt\tilde Z_t=\theta Z_t (so Var(Z~)=θ2\mathrm{Var}(\tilde Z)=\theta^2) and consider X~t=Z~t+1θZ~t1\tilde X_t=\tilde Z_t+\tfrac1\theta\tilde Z_{t-1}: Var(X~t)=θ2+1,Cov(X~t,X~t1)=1θθ2=θ.\mathrm{Var}(\tilde X_t)=\theta^2+1,\qquad \mathrm{Cov}(\tilde X_t,\tilde X_{t-1})=\tfrac1\theta\cdot\theta^2=\theta. Identical mean, variance, and covariances. For Gaussian noise that means identical law — two MA(1) models (θ\theta and 1/θ1/\theta) for one process.

The fix: require the shock at time tt to dominate, θ<1|\theta|<1, equivalently the polynomial has its root outside the unit circle:

θ<1    θ(z)=1+θz0  z1.|\theta|<1 \iff \theta(z)=1+\theta z\neq 0\ \ \forall\,|z|\le 1.

Definition. MA(q) is invertible if θ(z)0\theta(z)\neq 0 for all z1|z|\le 1 (all roots strictly outside the unit circle).

Theorem (why invertibility matters). A model is invertible iff the noise can be recovered as a convergent linear combination of the observations:

Zt=π(B)Xt=j0πjXtj,jπj<, π0=1,Z_t = \pi(B)X_t = \sum_{j\ge0}\pi_j X_{t-j},\qquad \sum_j|\pi_j|<\infty,\ \pi_0=1,

i.e. there is a stable AR()\mathrm{AR}(\infty) form Xt=j1πjXtj+ZtX_t=-\sum_{j\ge1}\pi_j X_{t-j}+Z_t. This is exactly the form prediction needs.

Why we insist on it — worked. Non-invertible Xt=Zt+2Zt1X_t=Z_t+2Z_{t-1}. Solving for the AR form by repeated substitution gives weights 1,2,4,8,16,1,2,4,8,16,\dots — they explode, so the infinite past has unbounded influence: useless for prediction. The invertible twin X~t=Z~t+12Z~t1\tilde X_t=\tilde Z_t+\tfrac12\tilde Z_{t-1} gives decaying weights 1,12,14,1,\tfrac12,\tfrac14,\dots. Same process, but only the invertible representation is usable.

Numeric anchors (root test).

  • Xt=ZtZt1+14Zt2X_t=Z_t-Z_{t-1}+\tfrac14 Z_{t-2}: θ(z)=1z+14z2=(112z)2\theta(z)=1-z+\tfrac14 z^2=(1-\tfrac12 z)^2, root z=2>1z=2>1invertible.
  • Xt=Zt3Zt1+2Zt2X_t=Z_t-3Z_{t-1}+2Z_{t-2}: θ(z)=13z+2z2\theta(z)=1-3z+2z^2, roots {1,12}\{1,\tfrac12\} → root on the boundary ⇒ not invertible.

Autoregressive AR(p)

Xt=ϕ1Xt1++ϕpXtp+Zt,ϕ(B)Xt=Zt,  ϕ(B)=1ϕ1BϕpBp.X_t = \phi_1 X_{t-1}+\cdots+\phi_p X_{t-p} + Z_t,\qquad \phi(B)X_t = Z_t,\ \ \phi(B)=1-\phi_1 B-\cdots-\phi_p B^p.

Note the sign convention: the ϕ\phi‘s move to the same side as XX before forming the polynomial (opposite of MA, where θ(B)\theta(B) acts on the ZZ‘s).

The geometric-series inversion. Treat ϕ(B)\phi(B) as a number and divide:

ϕ(B)Xt=Zt  Xt=1ϕ(B)Zt.\phi(B)X_t=Z_t \ \Rightarrow\ X_t = \frac{1}{\phi(B)}Z_t.

For AR(1), ϕ(B)=1ϕB\phi(B)=1-\phi B, so if ϕ<1|\phi|<1 use 11x=j0xj\frac{1}{1-x}=\sum_{j\ge0}x^j:

Xt=(1+ϕB+ϕ2B2+)Zt=j0ϕjZtj,X_t = (1+\phi B+\phi^2 B^2+\cdots)Z_t = \sum_{j\ge0}\phi^j Z_{t-j},

the MA()\mathrm{MA}(\infty) representation. (Rigorously: BB is a norm-1 shift operator, so the Neumann series converges iff ϕ<1|\phi|<1 — same unit-root condition as MA, in disguise.)

Lemma — the guess solves the recursion. With Xt=j0ϕjZtjX_t=\sum_{j\ge0}\phi^j Z_{t-j},

Xt=Zt+ϕj0ϕjZt1j=Zt+ϕXt1.X_t = Z_t + \phi\sum_{j\ge0}\phi^j Z_{t-1-j} = Z_t + \phi X_{t-1}. \checkmark

Uniqueness — the remainder vanishes. Suppose YtY_t also solves Yt=ϕYt1+ZtY_t=\phi Y_{t-1}+Z_t. Iterating:

Yt=Zt+ϕZt1++ϕk1Ztk+1+ϕkYtk.Y_t = Z_t + \phi Z_{t-1} + \cdots + \phi^{k-1}Z_{t-k+1} + \phi^k Y_{t-k}.

The remainder’s size (stationary, so EY2E Y^2 constant):

E[(ϕkYtk)2]=ϕ2kE[Y02]k0iff ϕ<1.E[(\phi^k Y_{t-k})^2] = \phi^{2k}E[Y_0^2] \xrightarrow{k\to\infty} 0 \quad\text{iff } |\phi|<1.

So Yt=j0ϕjZtj=XtY_t=\sum_{j\ge0}\phi^j Z_{t-j}=X_t: the unique stationary solution. (Non-stationary solutions exist — add αϕt\alpha\phi^t for any α\alpha — but only one is stationary.)

AR(1) autocovariance via the MA(∞) form. Using γ(h)=σ2j0ψjψj+h\gamma(h)=\sigma^2\sum_{j\ge0}\psi_j\psi_{j+h} with ψj=ϕj\psi_j=\phi^j:

γ(h)=σ2j0ϕjϕj+h=σ2ϕhj0ϕ2j=σ2ϕh1ϕ2,ρ(h)=ϕh.\gamma(h)=\sigma^2\sum_{j\ge0}\phi^j\phi^{j+h}=\sigma^2\phi^h\sum_{j\ge0}\phi^{2j}=\frac{\sigma^2\phi^{h}}{1-\phi^2},\qquad \rho(h)=\phi^{h}.

Signature in the ACF. AR(1) autocorrelations decay exponentially ρ(h)=ϕh\rho(h)=\phi^h — no hard cutoff. ϕ>0\phi>0: smooth positive decay. ϕ<0\phi<0: decaying oscillation (alternating sign), a good visual cue that an AR term is needed.

Causality — depend only on the past

Mirror of invertibility, but for AR: we want XtX_t expressible as a stable combination of past noise (an MA()\mathrm{MA}(\infty)), not future noise.

Definition. AR(p) ϕ(B)Xt=Zt\phi(B)X_t=Z_t is causal if ϕ(z)0\phi(z)\neq0 for all z1|z|\le 1 (roots outside the unit circle) — equivalently it has an MA()\mathrm{MA}(\infty) form Xt=j0ψjZtjX_t=\sum_{j\ge0}\psi_j Z_{t-j}.

Non-causal, worked. Xt=2Xt1+ZtX_t=2X_{t-1}+Z_t, ϕ(z)=12z\phi(z)=1-2z, root z=12<1z=\tfrac12<1 → not causal. Forward substitution gives weights 1,2,4,8,1,2,4,8,\dots (explode). Reversing time, Xt1=12Xt12ZtX_{t-1}=\tfrac12 X_t-\tfrac12 Z_t, yields a convergent expansion — but in terms of future noise Zt,Zt+1,Z_{t},Z_{t+1},\dots. There is a stationary solution, but it depends on the future: useless.

Numeric anchors (root test).

  • Xt=0.9Xt1+ZtX_t=0.9X_{t-1}+Z_t: ϕ(z)=10.9z\phi(z)=1-0.9z, root z=10/9>1z=10/9>1causal.
  • Random walk Xt=Xt1+ZtX_t=X_{t-1}+Z_t: ϕ(z)=1z\phi(z)=1-z, root z=1z=1 on the boundary → not causal (and not stationary). Fix by differencing: Xt=Zt\nabla X_t=Z_t. When a root sits near 1, difference.
  • Xt=Xt2+ZtX_t=-X_{t-2}+Z_t: ϕ(z)=1+z2\phi(z)=1+z^2, roots ±i\pm i on the unit circle → not causal.

The duality, stated cleanly:

processthe polynomial restrictionwhat it buys
MA(q)invertible: θ(z)0\theta(z)\neq 0, $z
AR(p)causal: ϕ(z)0\phi(z)\neq 0, $z

MA↔AR are two views of one model. AR(1)\mathrm{AR}(1) is an MA()\mathrm{MA}(\infty) (shown above); conversely an MA()\mathrm{MA}(\infty) with θj=ϕj\theta_j=\phi^j collapses to AR(1)\mathrm{AR}(1) by the same geometric-series trick run backwards. The notation you choose is whichever makes the next step easy: MA for the ACF, AR for prediction.

Implications of §3.

  • Roots outside the unit circle is one condition wearing two names (causality for AR, invertibility for MA); both ensure the relevant infinite expansion converges.
  • The ACF/PACF shapes (cutoff vs decay) are how you read the order off a plot — the practical payoff of all this algebra (§4 PACF).
  • The geometric-series inversion is the workhorse you reuse for ARMA (§4) and for the spectral density (§7).

Core competency set §3.

  • Show MA(1) is stationary and compute its γ(h)\gamma(h); state the MA(q) cutoff.
  • Invert AR(1) to MA()\mathrm{MA}(\infty) via geometric series; prove existence (it solves the recursion) and uniqueness (remainder 0\to0).
  • Derive ρ(h)=ϕh\rho(h)=\phi^h and γ(h)=σ2ϕh/(1ϕ2)\gamma(h)=\sigma^2\phi^h/(1-\phi^2).
  • Test causality/invertibility by the unit-root rule on three worked polynomials.

4. ARMA — combining, computing, and Yule–Walker

ARMA(p,q): ϕ(B)Xt=θ(B)Zt\phi(B)X_t=\theta(B)Z_t. AR and MA together; the earlier models are special cases ARMA(0,0)=WN, ARMA(p,0)=AR, ARMA(0,q)=MA. Always assume ϕ\phi and θ\theta share no common roots (else you’re describing a simple process with needless parameters).

Common-factor counterexample. Xt=Xt1+ZtZt1X_t=X_{t-1}+Z_t-Z_{t-1} has ϕ(z)=1z=θ(z)\phi(z)=1-z=\theta(z). It looks like ARMA(1,1), but substituting shows Xt=ZtX_t=Z_t — plain white noise, ARMA(0,0). Cancel common factors first. (Another: θ=(113z)(112z)\theta=(1-\tfrac13 z)(1-\tfrac12 z), ϕ=(112z)(114z)\phi=(1-\tfrac12 z)(1-\tfrac14 z) share (112z)(1-\tfrac12 z) ⇒ reduce ARMA(2,2) to ARMA(1,1).)

Conditions. ARMA is causal iff ϕ(z)0\phi(z)\neq0 on z1|z|\le1 (⇒ MA()\mathrm{MA}(\infty)), invertible iff θ(z)0\theta(z)\neq0 on z1|z|\le1 (⇒ AR()\mathrm{AR}(\infty)).

Getting the MA(∞) form — polynomial division by geometric series. Want ψ(z)=θ(z)/ϕ(z)\psi(z)=\theta(z)/\phi(z).

Worked, ARMA(1,1). Xt=13Xt1+Zt12Zt1X_t=\tfrac13 X_{t-1}+Z_t-\tfrac12 Z_{t-1}, so ϕ(z)=113z\phi(z)=1-\tfrac13 z, θ(z)=112z\theta(z)=1-\tfrac12 z. θ(z)ϕ(z)=(112z)(1+13z+(13z)2+)\frac{\theta(z)}{\phi(z)}=\Big(1-\tfrac12 z\Big)\Big(1+\tfrac13 z+(\tfrac13 z)^2+\cdots\Big) =1+j0zj+1((13)j+112(13)j),= 1 + \sum_{j\ge0} z^{j+1}\Big(\big(\tfrac13\big)^{j+1}-\tfrac12\big(\tfrac13\big)^{j}\Big), giving Xt=Zt+j0((13)j+112(13)j)Ztj1X_t=Z_t+\sum_{j\ge0}\big((\tfrac13)^{j+1}-\tfrac12(\tfrac13)^j\big)Z_{t-j-1}. (R: ARMAtoMA.)

Why bother with each representation? The MA(∞) gives the ACF; the AR(∞) gives predictions.

ACF of ARMA — the difference-equation route

Computing γ\gamma from the MA()\mathrm{MA}(\infty) needs the whole infinite {ψj}\{\psi_j\} even for one lag — wasteful. Instead, take covariances of both sides of the ARMA equation against XtkX_{t-k}.

Derivation. From ϕ(B)Xt=θ(B)Zt\phi(B)X_t=\theta(B)Z_t, take Cov(,Xtk)\mathrm{Cov}(\cdot, X_{t-k}). LHS:

Cov(Xtϕ1Xt1ϕpXtp,Xtk)=γ(k)ϕ1γ(k1)ϕpγ(kp).\mathrm{Cov}(X_t-\phi_1 X_{t-1}-\cdots-\phi_p X_{t-p},\,X_{t-k}) = \gamma(k)-\phi_1\gamma(k-1)-\cdots-\phi_p\gamma(k-p).

RHS (using that ZtjZ_{t-j} correlates with XtkX_{t-k} only through the MA()\mathrm{MA}(\infty) weights ψ\psi):

Cov(θ(B)Zt,Xtk)={σ2j=kqθjψjk,0kq,0,k>q.\mathrm{Cov}(\theta(B)Z_t,\,X_{t-k}) = \begin{cases}\sigma^2\sum_{j=k}^{q}\theta_j\psi_{j-k}, & 0\le k\le q,\\[2pt] 0, & k>q.\end{cases}

Equating gives a finite recursion for γ\gamma.

Yule–Walker (the AR(p) special case)

For pure AR(p) the RHS is σ2\sigma^2 at k=0k=0 and 00 for k>0k>0. Writing the recursion for k=1,,pk=1,\dots,p and using γ(h)=γ(h)\gamma(-h)=\gamma(h):

(γ(0)γ(1)γ(p1)γ(1)γ(0)γ(p2)γ(p1)γ(p2)γ(0))Γ (Toeplitz, symmetric)(ϕ1ϕ2ϕp)=(γ(1)γ(2)γ(p)),\underbrace{\begin{pmatrix}\gamma(0)&\gamma(1)&\cdots&\gamma(p-1)\\ \gamma(1)&\gamma(0)&\cdots&\gamma(p-2)\\ \vdots& &\ddots&\vdots\\ \gamma(p-1)&\gamma(p-2)&\cdots&\gamma(0)\end{pmatrix}}_{\Gamma\ (\text{Toeplitz, symmetric})}\begin{pmatrix}\phi_1\\\phi_2\\\vdots\\\phi_p\end{pmatrix} = \begin{pmatrix}\gamma(1)\\\gamma(2)\\\vdots\\\gamma(p)\end{pmatrix},

i.e. ΓΦ=γ\Gamma\Phi=\gamma. Then recover σ2\sigma^2 from k=0k=0: σ2=γ(0)ϕ1γ(1)ϕpγ(p)\sigma^2=\gamma(0)-\phi_1\gamma(1)-\cdots-\phi_p\gamma(p).

Γ\Gamma is symmetric Toeplitz (constant along diagonals — cross-link [[02_Linear_Algebra]]) and full rank, hence invertible: the system always solves, and the Toeplitz structure makes it fast (Levinson–Durbin).

Worked AR(2) numeric. Sample autocorrelations ρ^(1)=0.6\hat\rho(1)=0.6, ρ^(2)=0.2\hat\rho(2)=0.2. Dividing the YW system by γ(0)\gamma(0) gives it in correlation form: (1ρ(1)ρ(1)1)(ϕ1ϕ2)=(ρ(1)ρ(2))  (10.60.61)(ϕ1ϕ2)=(0.60.2).\begin{pmatrix}1&\rho(1)\\\rho(1)&1\end{pmatrix}\begin{pmatrix}\phi_1\\\phi_2\end{pmatrix}=\begin{pmatrix}\rho(1)\\\rho(2)\end{pmatrix}\ \Rightarrow\ \begin{pmatrix}1&0.6\\0.6&1\end{pmatrix}\begin{pmatrix}\phi_1\\\phi_2\end{pmatrix}=\begin{pmatrix}0.6\\0.2\end{pmatrix}. Determinant 10.36=0.641-0.36=0.64. By Cramer’s rule: ϕ1=0.60.60.20.64=0.480.64=0.75,ϕ2=0.20.60.60.64=0.160.64=0.25.\phi_1=\frac{0.6-0.6\cdot0.2}{0.64}=\frac{0.48}{0.64}=0.75,\qquad \phi_2=\frac{0.2-0.6\cdot0.6}{0.64}=\frac{-0.16}{0.64}=-0.25. Then σZ2=γ(0)(1ϕ1ρ(1)ϕ2ρ(2))=γ(0)(10.45+0.05)=0.60γ(0)\sigma_Z^2=\gamma(0)\big(1-\phi_1\rho(1)-\phi_2\rho(2)\big)=\gamma(0)(1-0.45+0.05)=0.60\,\gamma(0) — the AR(2) explains 40% of the variance. (Check causality: ϕ(z)=10.75z+0.25z2\phi(z)=1-0.75z+0.25z^2 has complex roots of modulus 1/0.25=2>1\sqrt{1/0.25}=2>1 ✓.)

When does Yule–Walker fail? When Γ\Gamma degenerates — all covariances equal (a noiseless, perfectly correlated series). Near-zero noise ⇒ near-singular Γ\Gamma ⇒ unstable estimates. Opposite of ordinary stats, where low noise helps.

PACF — reading AR order off a plot

Partial autocorrelation pacf(h)\mathrm{pacf}(h) = the coefficient of XthX_{t-h} in the best linear predictor of XtX_t from Xt1,,XthX_{t-1},\dots,X_{t-h} — the correlation of XtX_t with XthX_{t-h} after removing the intervening lags’ influence.

Why AR(p) PACF cuts off at pp — derivation. Regress XtX_t on the previous hh lags; pacf(h)\mathrm{pacf}(h) is the last coefficient ϕhh\phi_{hh}.

  • For h=ph=p: the AR(p) equation Xt=ϕ1Xt1++ϕpXtp+ZtX_t=\phi_1 X_{t-1}+\cdots+\phi_p X_{t-p}+Z_t already is the best linear predictor from pp lags, with ZtZ_t\perp past. So the order-pp regression returns the true coefficients exactly, and ϕpp=ϕp0\phi_{pp}=\phi_p\neq0.
  • For h>ph>p: write the best predictor from hh lags. Because Xt=j=1pϕjXtj+ZtX_t=\sum_{j=1}^{p}\phi_j X_{t-j}+Z_t with ZtZ_t uncorrelated with all of Xt1,,XthX_{t-1},\dots,X_{t-h} (causality ⇒ ZtZ_t independent of the past), the optimal weights put ϕ1,,ϕp\phi_1,\dots,\phi_p on the first pp lags and exactly zero on lags p+1,,hp{+}1,\dots,h — adding older lags cannot reduce error once the pp-lag predictor already achieves the irreducible Var(Zt)\mathrm{Var}(Z_t). Hence ϕhh=0\phi_{hh}=0 for h>ph>p. ∎

The mirror statement for MA(q) (ACF cuts off at qq) is immediate from γ(h)=0\gamma(h)=0 for h>qh>q (§3). The two cutoffs are duals:

MA(q)AR(p)
ACF00 for h>qh>q (sharp cutoff)decays to 00 as hh\to\infty
PACFdecays to 00 as hh\to\infty00 for h>ph>p (sharp cutoff)

They are mirror images: ACF cuts off for MA; PACF cuts off for AR. A mixed ARMA shows neither clean cutoff — which is why you fit low-order AR or MA first and only escalate to ARMA if needed.

Numeric/diagnostic anchor. ACF cuts off after lag 2 → consider MA(2); but a single sharp PACF spike at lag 1 → an AR(1) may be the simpler truth. Start simple, check residuals.

Implications of §4.

  • Common-factor cancellation enforces parsimony — the simplest equivalent model is the one you want.
  • Yule–Walker turns AR estimation into a Toeplitz solve, fast and always solvable (away from the noiseless degeneracy).
  • ACF/PACF cutoffs are the bridge from the algebra of §3 to actual model-order choice.

Core competency set §4.

  • Divide θ/ϕ\theta/\phi by geometric series to get MA()\mathrm{MA}(\infty).
  • Derive Yule–Walker by covariancing both sides; write ΓΦ=γ\Gamma\Phi=\gamma and note Toeplitz/invertible; solve a 2×2 AR(2) system by hand.
  • Derive why AR(p) PACF cuts off at pp (causality ⇒ older lags get zero weight); state the full ACF/PACF cutoff table and use it to pick orders.
  • Give the common-factor counterexample.

5. Fitting, prediction, and selection

Best linear prediction (the projection view)

With only weak stationarity we trust linear predictors (higher moments may drift; cross-link [[02_Linear_Algebra]] projection). Predict YY from predictors W1,,WnW_1,\dots,W_n by aiWi\sum a_i W_i; the optimal weights are

a=Δ1ζ,Δij=Cov(Wi,Wj),  ζi=Cov(Y,Wi),a^\star = \Delta^{-1}\zeta,\qquad \Delta_{ij}=\mathrm{Cov}(W_i,W_j),\ \ \zeta_i=\mathrm{Cov}(Y,W_i),

exactly (XX)1Xy(X^\top X)^{-1}X^\top y with covariances in place of cross-products. For forecasting, the predictors are past values and YY is the future value, so XX appears on both sides.

Under stationarity, Δij=γ(ij)\Delta_{ij}=\gamma(i-j) (Toeplitz) and ζi=γ(i)\zeta_i=\gamma(i) — so prediction reduces to a Toeplitz solve.

One-step, worked. Predict Xt+1X_{t+1} from XtX_t: Δ=γ(0)\Delta=\gamma(0), ζ=γ(1)\zeta=\gamma(1), so X^t+1=Xtγ(1)/γ(0)=ρ(1)Xt\hat X_{t+1}=X_t\,\gamma(1)/\gamma(0)=\rho(1)X_t — the lag-1 autocorrelation times the last value.

For a causal AR(p) with n>pn>p, the best linear predictor is the model equation: X^n+1=ϕ1Xn++ϕpXn+1p\hat X_{n+1}=\phi_1 X_n+\cdots+\phi_p X_{n+1-p}. Gaussian noise ⇒ prediction interval X^n+1±1.96σ\hat X_{n+1}\pm 1.96\,\sigma.

ARMA prediction: switch to the AR()\mathrm{AR}(\infty) form Xt=Ztj1πjXtjX_t=Z_t-\sum_{j\ge1}\pi_j X_{t-j}, truncate, and forecast X^t=j=1JπjXtj\hat X_t=-\sum_{j=1}^{J}\pi_j X_{t-j}. Multi-step: iterate (predict one step, feed it back) — optimal by iterated expectations.

Long-horizon punchline. As the horizon grows, the prediction converges to the overall mean and the interval widens to 1.96×1.96\times the stationary SD (you’re taking powers of a matrix with eigenvalues <1<1 in modulus). If log-returns follow an invertible ARMA, the long-run forecast of log-returns is just their mean — no free lunch.

Parameter estimation — three methods

  1. Yule–Walker / method of moments (AR only): match sample ACVF at lags 0..p0..p, solve ΓΦ=γ\Gamma\Phi=\gamma (§4). Linear, fast, but AR-only and not efficient for ARMA.
  2. Conditional least squares (general ARMA): rewrite the noise recursively, e.g. MA(1) Zt=XtμθZt1Z_t=X_t-\mu-\theta Z_{t-1}; set Z0=0Z_0=0, recurse Z~t\tilde Z_t, minimize Z~t2\sum \tilde Z_t^2. “Conditional” because it conditions on the made-up initial Z0=0Z_0=0 — harmless asymptotically since the past’s influence decays exponentially. (ARMA(1,1) needs XX-history too, so start at t=2t{=}2.) Nonlinear for ARMA.
  3. Maximum likelihood (Gaussian): maximize the exact likelihood from the autocovariance matrix. Same idea as conditional LS but handles the start-up exactly. Standard practice: warm-start MLE from conditional-LS estimates (R arima method="CSS-ML"). The three usually agree closely.

Model selection

  • AIC =2logL^+2k=-2\log\hat L + 2k (for ARIMA k=p+q+2k=p+q+2, the +2+2 for the estimated mean and σ\sigma). Estimates out-of-sample error, asymptotically like CV → use for prediction. Tends to pick a slightly-too-large model.
  • BIC =2logL^+klogn=-2\log\hat L + k\log n. Heavier penalty ⇒ smaller models; model-selection consistent (recovers the true order as nn\to\infty) → use to identify the true process. Small risk of choosing too-small a model, which can hurt prediction.
  • Time-series CV. Fit on X1,,XtX_1,\dots,X_t, forecast Xt+1X_{t+1}, record et+1=Xt+1X^t+1e^\star_{t+1}=X_{t+1}-\hat X_{t+1}; sweep t=m,,n1t=m,\dots,n-1; average the squared errors. Train on the past, validate on the future only — ordinary CV would illegally train on the future to predict the past. Seasonal data: leave out whole periods; kk-step goal: forecast X^t+k\hat X_{t+k}.

Testing white noise — the portmanteau test

Eyeballing the correlogram fails the multiple-testing problem (§1). Use a joint statistic.

For white noise, r1,,rkiidN(0,1/n)r_1,\dots,r_k\overset{iid}{\sim}N(0,1/n), so

Q=ni=1kri2 d χk2.Q = n\sum_{i=1}^{k} r_i^2 \ \xrightarrow{d}\ \chi^2_k.

After fitting an ARMA with estimated parameters, the degrees of freedom drop and we use the Ljung–Box–Pierce statistic

Q~=n(n+2)i=1kr^i2ni d χkpq2.\tilde Q = n(n+2)\sum_{i=1}^{k}\frac{\hat r_i^2}{n-i}\ \xrightarrow{d}\ \chi^2_{k-p-q}.

Reject “residuals are white / model adequate” if Q~\tilde Q exceeds the (1α)(1-\alpha) quantile (one-sided). Subtract p+qp+q because parameters were estimated from the data (cross-link [[03_Statistical_Inference]] — same df-deduction as in goodness-of-fit). Choose max lag kk carefully: too small misses far seasonal spikes; too large breaks the χ2\chi^2 approximation. Pair the test with the residual ACF and standardized-residual plots — the test can miss what the eye catches and vice versa.

Implications of §5.

  • Prediction is a Toeplitz projection; AR makes it trivial because the model is the predictor.
  • AIC-for-prediction vs BIC-for-truth is the one-line rule to memorize.
  • “Validate only on the future” is the non-negotiable difference from ordinary CV.

Core competency set §5.

  • Write the best-linear-predictor formula and specialize to one-step (ρ(1)Xt\rho(1)X_t) and causal AR.
  • Contrast Yule–Walker / conditional-LS / MLE and say when each applies.
  • State AIC vs BIC roles and the time-series CV protocol.
  • Write the QQ and Ljung–Box statistics with the right df and explain the pq-p-q.

6. Extensions: ARIMA and seasonal models

Bundle differencing and seasonality into the ARMA machinery.

  • ARIMA(p,d,q): difference dd times, then fit ARMA: ϕ(B)(1B)dXt=θ(B)Zt\phi(B)(1-B)^d X_t=\theta(B)Z_t (plus mean). Removes polynomial trends / random walks inside the model. (R arima, middle index =d=d.)
  • Seasonal ARMA (period ss): Φ(Bs)Xt=Θ(Bs)Zt\Phi(B^s)X_t=\Theta(B^s)Z_t — AR/MA terms only at the seasonal lags s,2s,s,2s,\dots. Why not plain ARMA(2s,2s)? That would carry 2s2s AR + 2s2s MA parameters (e.g. 24+2424+24 for s=12s=12) — unstable. S-ARMA fits 4.
  • Multiplicative seasonal ARMA: Φ(Bs)ϕ(B)Xt=Θ(Bs)θ(B)Zt\Phi(B^s)\phi(B)X_t=\Theta(B^s)\theta(B)Z_t — captures short-range and seasonal dependence together with few parameters. Use when the ACF/PACF show spikes at the seasonal lags and in the small lags around them; the width of the surrounding spikes signals the order of the short-range terms.
  • SARIMA: the full object — multiplicative seasonal ARMA with both ordinary (d\nabla^d) and seasonal (sD\nabla_s^D) differencing:
Φ(Bs)ϕ(B)sDdYt=δ+Θ(Bs)θ(B)Zt.\Phi(B^s)\,\phi(B)\,\nabla_s^D\,\nabla^d\,Y_t = \delta + \Theta(B^s)\,\theta(B)\,Z_t.

Fit step by step (plot → de-trend → ACF/PACF → low-order AR/MA → escalate); R sarima (package astsa) gives the diagnostics.

Core competency set §6. Read ARIMA(p,d,q)(p,d,q); explain why multiplicative S-ARMA beats a giant plain ARMA on parameter count/stability; write the SARIMA operator.


7. Frequency domain

Picture to hold. A stationary process is a superposition of random periodic components at different frequencies. The time domain (ACF) and frequency domain (spectrum) hold the same information in two bases; you Fourier-transform to whichever is easier — exactly the MA↔AR spirit, now for the whole series.

Why transform: optimizing cos(2πft+ϕ)\cos(2\pi ft+\phi) over a phase ϕ\phi is non-convex, but the identity cos(x+y)=cosxcosysinxsiny\cos(x+y)=\cos x\cos y-\sin x\sin y rewrites it as a linear combination of cos\cos and sin\sin (amplitudes are linear coefficients). Euler eix=cosx+isinxe^{ix}=\cos x+i\sin x packages this in complex form.

Discrete Fourier transform and its inverse

bj=t=0n1xte2πijt/n(contribution of frequency j/n),xt=1nj=0n1bje2πijt/n.b_j = \sum_{t=0}^{n-1} x_t\,e^{-2\pi i jt/n}\quad(\text{contribution of frequency } j/n),\qquad x_t = \frac1n\sum_{j=0}^{n-1} b_j\,e^{2\pi i jt/n}.

Inversion proof (geometric sum / Euler). Substitute bjb_j into the inverse:

1nj=0n1(s=0n1xse2πijs/n)e2πijt/n=1ns=0n1xsj=0n1(e2πi(ts)/n)j.\frac1n\sum_{j=0}^{n-1}\Big(\sum_{s=0}^{n-1}x_s e^{-2\pi i js/n}\Big)e^{2\pi i jt/n} = \frac1n\sum_{s=0}^{n-1}x_s\sum_{j=0}^{n-1}\big(e^{2\pi i (t-s)/n}\big)^{j}.

The inner sum: if t=st=s every term is 11, total nn; if tst\neq s, geometric series

j=0n1(e2πi(ts)/n)j=1e2πi(ts)1e2πi(ts)/n=0\sum_{j=0}^{n-1}\big(e^{2\pi i (t-s)/n}\big)^{j} = \frac{1-e^{2\pi i (t-s)}}{1-e^{2\pi i (t-s)/n}} = 0

(numerator 00 since e2πiinteger=1e^{2\pi i\cdot\text{integer}}=1). So the inner sum is n1(t=s)n\,\mathbf 1(t=s), and the whole thing is 1nnxt=xt\frac1n\cdot n\, x_t = x_t. \checkmark

The Fourier frequencies j/nj/n give exact reconstruction; the basis vectors u(j)u^{(j)} are orthogonal (same geometric-sum argument on u(l),u(k)\langle u^{(l)},u^{(k)}\rangle). The bjb_j are typically sparse — a few frequencies carry the signal — which is why this is great for compression.

Periodogram and spectral density

Periodogram (sample power at frequency j/nj/n):

I(j/n)=bj2n,j=1,,n/2I(j/n) = \frac{|b_j|^2}{n},\qquad j=1,\dots,\lfloor n/2\rfloor

(only to n/2n/2 by symmetry bnj=bˉjb_{n-j}=\bar b_j). Divide by nn because white-noise coefficients scale like n\sqrt n, so bj2/n|b_j|^2/n keeps noise at a constant floor while true signals grow with nn.

White-noise periodogram is not flat-looking. It shows random spikes, and a fresh sample gives entirely different spikes — white noise is an equal-weight (high-variance) superposition of all frequencies. Don’t over-read individual periodogram peaks (the §1 lesson, frequency-side).

Time↔frequency duality (sample side). The periodogram is the DFT of the sample autocovariance:

I(j/n)=h=(n1)n1γ^(h)e2πijh/n.I(j/n) = \sum_{h=-(n-1)}^{n-1}\hat\gamma(h)\,e^{-2\pi i jh/n}.

(Proof: expand bj2=bjbˉj|b_j|^2=b_j\bar b_j after centering — legal since the constant-signal DFT is 00 — collect the double sum by lag h=tsh=t-s, recognize γ^(h)\hat\gamma(h).)

Spectral density (population limit): for ACVF γ(h)\gamma(h),

f(λ)=h=γ(h)e2πiλh,12λ12,f(\lambda) = \sum_{h=-\infty}^{\infty}\gamma(h)\,e^{-2\pi i\lambda h},\qquad -\tfrac12\le\lambda\le\tfrac12,

the periodogram with true γ\gamma and continuous λ\lambda. It is invertible:

γ(h)=1/21/2e2πiλhf(λ)dλ=1/21/2cos(2πλh)f(λ)dλ.\gamma(h)=\int_{-1/2}^{1/2} e^{2\pi i\lambda h}f(\lambda)\,d\lambda = \int_{-1/2}^{1/2}\cos(2\pi\lambda h)f(\lambda)\,d\lambda.

Inversion sketch (continuous orthogonality). Substitute the definition of ff and swap sum and integral:

1/21/2e2πiλhf(λ)dλ=kγ(k)1/21/2e2πiλ(hk)dλ.\int_{-1/2}^{1/2} e^{2\pi i\lambda h}f(\lambda)\,d\lambda = \sum_{k}\gamma(k)\int_{-1/2}^{1/2} e^{2\pi i\lambda(h-k)}\,d\lambda.

The integral is the continuous analogue of the DFT orthogonality used above: 1/21/2e2πiλmdλ=1(m=0)\int_{-1/2}^{1/2}e^{2\pi i\lambda m}d\lambda = \mathbf 1(m=0) (for integer mm it’s sin(πm)πm=0\frac{\sin(\pi m)}{\pi m}=0 unless m=0m=0). So only the k=hk=h term survives, leaving γ(h)\gamma(h). The cos\cos form follows because γ\gamma is symmetric, killing the imaginary part. ∎ (Same orthogonality move as the DFT inversion, run in the continuum.)

So the spectral density and the ACVF carry identical information — switch freely. White noise: γ(h)=σ21(h=0)\gamma(h)=\sigma^2\mathbf 1(h=0)f(λ)=σ2f(\lambda)=\sigma^2, flat (equal power at all frequencies — and clearly not a probability density).

Linear filters

An LTI filter Yt=jajXtjY_t=\sum_j a_j X_{t-j} (differencing, smoothing, lagging are all special cases). Its effect on the spectrum is multiplicative:

fY(λ)=fX(λ)A(λ)2,A(λ)=jaje2πijλ (transfer function), A2=power transfer.f_Y(\lambda) = f_X(\lambda)\,|A(\lambda)|^2,\qquad A(\lambda)=\sum_j a_j e^{-2\pi i j\lambda}\ (\text{transfer function}),\ |A|^2=\text{power transfer}.

Derivation. From γY(h)=j,kajakγX(hk+j)\gamma_Y(h)=\sum_{j,k}a_j a_k\gamma_X(h-k+j), write each γX\gamma_X as a spectral integral and factor:

γY(h)=1/21/2e2πiλhfX(λ)(jaje2πiλj)(kake2πiλk)dλ=e2πiλhfX(λ)A(λ)2dλ,\gamma_Y(h)=\int_{-1/2}^{1/2} e^{2\pi i\lambda h} f_X(\lambda)\Big(\sum_j a_j e^{2\pi i\lambda j}\Big)\Big(\sum_k a_k e^{-2\pi i\lambda k}\Big)d\lambda = \int e^{2\pi i\lambda h} f_X(\lambda)|A(\lambda)|^2 d\lambda,

and the integrand multiplying e2πiλhe^{2\pi i\lambda h} must be fYf_Y. \checkmark

Worked filter. Lag-ss differencing Yt=XtXtsY_t=X_t-X_{t-s}: A(λ)2=4sin2(πsλ)|A(\lambda)|^2=4\sin^2(\pi s\lambda). For s=1s=1 this is 00 at λ=0\lambda=0 (kills constants) and rises toward high λ\lambda — a high-pass filter. For s=6s=6 it has zeros at λ=0,16,26,36\lambda=0,\tfrac16,\tfrac26,\tfrac36 — it removes exactly the period-6 seasonal frequencies.

Spectral density of ARMA. For causal ARMA,

fX(λ)=σ2θ(e2πiλ)2ϕ(e2πiλ)2.f_X(\lambda)=\sigma^2\frac{|\theta(e^{-2\pi i\lambda})|^2}{|\phi(e^{-2\pi i\lambda})|^2}.

As λ\lambda traces the unit circle, near a root of ϕ\phi the denominator → 00 and ff peaks (AR resonances); near a root of θ\theta the numerator → 00 and ff dips (MA nulls). This is the frequency-domain echo of “roots govern everything.”

Aliasing. Sampling too slowly folds high frequencies onto low ones (the helicopter-blade-stops illusion at 24 fps). Sample fast enough or high frequencies masquerade as low — critical for audio.

Process representation — building a series with a target spectrum

The spectral density isn’t just a diagnostic; it tells you how to construct a process with prescribed frequency content. Represent

Xt=j=1m(Ajcos(2πλjt)+Bjsin(2πλjt)),X_t = \sum_{j=1}^{m}\big(A_j\cos(2\pi\lambda_j t)+B_j\sin(2\pi\lambda_j t)\big),

with Aj,BjA_j,B_j uncorrelated, mean zero, Var(Aj)=Var(Bj)=σj2\mathrm{Var}(A_j)=\mathrm{Var}(B_j)=\sigma_j^2. This is stationary with γ(h)=j=1mσj2cos(2πλjh)\gamma(h)=\sum_{j=1}^m\sigma_j^2\cos(2\pi\lambda_j h).

Why it approximates a target ff — derivation. Choose λj=j2m\lambda_j=\tfrac{j}{2m} and σj2=f(λj)m\sigma_j^2=\tfrac{f(\lambda_j)}{m}. Then

γ(h)=j=1mf(λj)mcos(2πλjh)=22mj=1mf(j2m)cos(2πhj2m).\gamma(h)=\sum_{j=1}^m \tfrac{f(\lambda_j)}{m}\cos(2\pi\lambda_j h) = \tfrac{2}{2m}\sum_{j=1}^m f\big(\tfrac{j}{2m}\big)\cos\big(2\pi h\tfrac{j}{2m}\big).

As mm\to\infty this Riemann sum (step 12m\tfrac{1}{2m} over [0,12][0,\tfrac12]) becomes

γ(h)201/2f(λ)cos(2πhλ)dλ=1/21/2f(λ)cos(2πhλ)dλ\gamma(h)\to 2\int_0^{1/2} f(\lambda)\cos(2\pi h\lambda)\,d\lambda = \int_{-1/2}^{1/2} f(\lambda)\cos(2\pi h\lambda)\,d\lambda

(last step by symmetry of ff and cos\cos) — exactly the inversion formula. So XtX_t has spectral density ff in the limit. ∎ This makes concrete the opening picture: a stationary process is a superposition of random sinusoids, weighted by the spectrum.

Implications of §7.

  • ACVF ⟷ spectrum is a lossless change of basis; pick the view where the operation is simple (filtering is multiplication in frequency).
  • The same geometric-sum identity underlies DFT inversion, basis orthogonality, and the duality theorems — one move, many corollaries.
  • ARMA roots show up as spectral peaks/dips, tying §3’s algebra to what you see in a periodogram.

Core competency set §7.

  • Prove DFT inversion via the geometric sum; sketch the continuous-orthogonality version for the spectrum.
  • State the ACVF↔spectrum pair and the white-noise flat spectrum.
  • Derive fY=fXA2f_Y=f_X|A|^2 and read a differencing filter’s power transfer.
  • Write the ARMA spectral density and explain peaks/dips from roots.
  • Build a process with target spectrum via random sinusoids (σj2=f(λj)/m\sigma_j^2=f(\lambda_j)/m) and show the Riemann-sum limit.

8. State space and hidden Markov models

Picture to hold. A latent process XtX_t evolves; you see only noisy measurements YtY_t. Want past/present/future of XX (smoothing/filtering/prediction). GPS: a true trajectory, scattered measurements — recover the path. This generalizes everything above and links to [[07_Bayesian_Statistics]] (EM) and [[05_Stochastic_Processes]] (Markov).

Hidden Markov model assumptions. XX is a Markov chain (future ⊥ past given present XtX_t); given XX, the YtY_t are conditionally independent (measurement errors independent, not systematic). The joint factorizes:

f(X0T,Y1T)=f0(X0)t=1Tft(XtXt1)gt(YtXt).f(X_0^T,Y_1^T) = f_0(X_0)\prod_{t=1}^{T} f_t(X_t\mid X_{t-1})\,g_t(Y_t\mid X_t).

Draw as a DAG: Xt1XtYtX_{t-1}\to X_t\to Y_t.

Linear state space model: Xt=GtXt1+VtX_t=G_t X_{t-1}+V_t, Yt=HtXt+WtY_t=H_t X_t+W_t (position/velocity + noisy location). A causal/invertible ARMA is a state space model — stack lags into the state.

AR(2) as state space, worked. Yt=ϕ1Yt1+ϕ2Yt2+WtY_t=\phi_1 Y_{t-1}+\phi_2 Y_{t-2}+W_t. State Xt=(Yt,Yt1)X_t=(Y_t,Y_{t-1})^\top: (YtYt1)=(ϕ1ϕ210)(Yt1Yt2)+(Wt0),Yt=(1 0)Xt.\begin{pmatrix}Y_t\\Y_{t-1}\end{pmatrix}=\begin{pmatrix}\phi_1&\phi_2\\1&0\end{pmatrix}\begin{pmatrix}Y_{t-1}\\Y_{t-2}\end{pmatrix}+\begin{pmatrix}W_t\\0\end{pmatrix},\qquad Y_t=(1\ 0)X_t. This is the state augmentation move — bundle history into the state so the dynamics become first-order Markov. (Cross-link [[07_Bayesian_Statistics]] augment-then-marginalize.)

Filtering and prediction (the forward recursion)

Let πjt+kt=P(Xt+k=jy1t)\pi^{t+k\mid t}_j=P(X_{t+k}=j\mid y_1^t). Prediction (k>0k>0), filtering (k=0k=0), smoothing (k<0k<0). With transition matrix AA (Aij=P(Xt+1=iXt=j)A_{ij}=P(X_{t+1}=i\mid X_t=j)) and emission matrix BB (Boj=P(Yt=oXt=j)B_{oj}=P(Y_t=o\mid X_t=j)):

Prediction step: πt+1t=Aπtt\pi^{t+1\mid t}=A\,\pi^{t\mid t}.

Update step — derive via Bayes. We have the model as P(YX)P(Y\mid X), P(XX)P(X\mid X); filtering needs the reverse condition. Using P(AB,C)=P(BA,C)P(AC)P(BC)P(A\mid B,C)=\frac{P(B\mid A,C)P(A\mid C)}{P(B\mid C)} with A={Xt+1=j}A=\{X_{t+1}{=}j\}, B={Yt+1=yt+1}B=\{Y_{t+1}{=}y_{t+1}\}, C={Y1t}C=\{Y_1^t\}, and dropping the observed past inside the emission (HMM conditional independence):

πjt+1t+1=Byt+1,jπjt+1tiByt+1,iπit+1t.\pi^{t+1\mid t+1}_j = \frac{B_{y_{t+1},\,j}\,\pi^{t+1\mid t}_j}{\sum_i B_{y_{t+1},\,i}\,\pi^{t+1\mid t}_i}.

So the recursion alternates predict (πttπt+1t\pi^{t\mid t}\to\pi^{t+1\mid t}, multiply by AA) and update (πt+1tπt+1t+1\pi^{t+1\mid t}\to\pi^{t+1\mid t+1}, reweight by the emission and renormalize) — the HMM forward algorithm. Start from a prior π0\pi^0 (often uniform). Predicting YY: pt+kt=BAkπttp^{t+k\mid t}=B\,A^k\,\pi^{t\mid t}.

Smoothing — the backward pass

Filtering uses data up to tt; smoothing uses all data y1Ty_1^T to estimate a past state XtX_t (k<0k<0) — better, because the future is informative about where you were. Define forward (filtered, unnormalized) messages αt(j)=P(Xt=j,y1t)\alpha_t(j)=P(X_t=j,\,y_1^t) from the forward pass, and backward messages

βt(j)=P(yt+1TXt=j),\beta_t(j) = P(y_{t+1}^T\mid X_t=j),

the likelihood of all future observations given the current state. The backward recursion runs T1T\to1, conditioning on the next state and marginalizing it out:

βt(j)=iAi,jByt+1,iβt+1(i),βT(j)=1.\beta_t(j) = \sum_{i} A_{i,j}\,B_{y_{t+1},\,i}\,\beta_{t+1}(i),\qquad \beta_T(j)=1.

(Read right to left: from state jj, transition to each next state ii with prob Ai,jA_{i,j}, emit yt+1y_{t+1} with prob Byt+1,iB_{y_{t+1},i}, then carry the rest of the future βt+1(i)\beta_{t+1}(i).) The smoothed posterior multiplies the two passes:

P(Xt=jy1T)    αt(j)βt(j)P(X_t=j\mid y_1^T) \;\propto\; \alpha_t(j)\,\beta_t(j)

— past evidence (α\alpha) times future evidence (β\beta), renormalized. This forward–backward algorithm is exactly the E-step quantity EM needs below; it is the discrete cousin of the Kalman smoother.

Most likely trajectory — Viterbi

Find argmaxx0TP(X0TY1T)\arg\max_{x_0^T} P(X_0^T\mid Y_1^T). Take logs; the normalizer logP(Y1T)\log P(Y_1^T) is constant in xx, so

logP(X0TY1T)=logπ0(x0)+t=1T[logAxt,xt1+logByt,xt]+C.\log P(X_0^T\mid Y_1^T) = \log\pi^0(x_0) + \sum_{t=1}^{T}\big[\log A_{x_t,x_{t-1}} + \log B_{y_t,x_t}\big] + C.

Read each term as a cost of traversing states over time: a start cost, a transition cost per move, an emission cost per stay. Minimizing total cost = shortest path through the trellis. Viterbi does it in one forward pass (cheapest path to each state at each time) + a backward trace — O(TK2)O(T\cdot K^2) instead of KTK^T brute force.

Parameter estimation — EM / Baum–Welch

When A,B,π0A,B,\pi^0 are unknown, the likelihood

Pθ(Y1T)=x0Tπ0(x0)t=1TAxt,xt1Byt,xtP_\theta(Y_1^T)=\sum_{x_0^T}\pi^0(x_0)\prod_{t=1}^{T}A_{x_t,x_{t-1}}B_{y_t,x_t}

sums over exponentially many latent paths — non-convex, generally non-unique. EM (Baum–Welch) alternates: (E) estimate the latent XX distribution given YY and current θ\theta (the forward–backward recursions); (M) update θ\theta. Cross-link [[07_Bayesian_Statistics]] — same EM as for mixtures, here on a chain. Caveats: can diverge or stick in local optima (restart from random seeds). Hard EM replaces the E-step distribution with the single most likely path (Viterbi) — a Viterbi step + an MLE step.

Implications of §8.

  • State augmentation unifies AR/ARMA with Kalman-style filtering — “stack the history” turns any finite-memory model Markov.
  • Filtering is recursive Bayes: predict-then-update, the discrete Kalman filter; it’s why HMMs scale to long series.
  • Viterbi (max path) vs forward (sum over paths) is the recurring max-vs-sum duality; both are dynamic programming over the trellis.

Core competency set §8.

  • State the HMM factorization and write an AR(2) in state space form.
  • Derive the filter update from Bayes; state the predict/update alternation.
  • Write the backward recursion and the smoothing product P(Xty1T)αtβtP(X_t\mid y_1^T)\propto\alpha_t\beta_t (forward–backward).
  • Write the Viterbi log-decomposition and explain the DP cost-path reading.
  • Say what EM/Baum–Welch and hard EM do and their failure modes.

9. Memorize cold

Must be instant:

  • Weak stationarity: constant mean; Cov(Xt,Xt+h)=γ(h)\mathrm{Cov}(X_t,X_{t+h})=\gamma(h) (lag only); γ(h)=γ(h)\gamma(-h)=\gamma(h); ρ(h)=γ(h)/γ(0)\rho(h)=\gamma(h)/\gamma(0).
  • WN band ±1.96/n\pm1.96/\sqrt n; expected exceedances 0.05k0.05k.
  • \nabla kills linear trend; 2\nabla^2 kills quadratic; d\nabla_d kills period-dd season.
  • Variance-stabilize: Varμ\mathrm{Var}\propto\mu\Rightarrow\sqrt{\cdot}; Varμ2log\mathrm{Var}\propto\mu^2\Rightarrow\log.
  • MA(q): Xt=θ(B)ZtX_t=\theta(B)Z_t; ACF cuts off after qq; invertible     θ(z)0\iff\theta(z)\neq0 on z1|z|\le1.
  • AR(p): ϕ(B)Xt=Zt\phi(B)X_t=Z_t; PACF cuts off after pp; causal     ϕ(z)0\iff\phi(z)\neq0 on z1|z|\le1.
  • AR(1): ρ(h)=ϕh\rho(h)=\phi^h, γ(h)=σ2ϕh/(1ϕ2)\gamma(h)=\sigma^2\phi^h/(1-\phi^2), MA()=ϕjZtj\mathrm{MA}(\infty)=\sum\phi^j Z_{t-j}.
  • Geometric-series inversion: 11ϕB=j0ϕjBj\frac{1}{1-\phi B}=\sum_{j\ge0}\phi^j B^j.
  • Yule–Walker: ΓΦ=γ\Gamma\Phi=\gamma, Γ\Gamma symmetric Toeplitz.
  • ACF cuts off → MA order; PACF cuts off → AR order.
  • AIC (+2k+2k) for prediction; BIC (+klogn+k\log n) for the true model.
  • Time-series CV: train past, validate future only.
  • Ljung–Box Q~=n(n+2)r^i2/(ni)χkpq2\tilde Q=n(n+2)\sum \hat r_i^2/(n-i)\to\chi^2_{k-p-q}.
  • Spectral density f(λ)=hγ(h)e2πiλhf(\lambda)=\sum_h\gamma(h)e^{-2\pi i\lambda h}; WN ⇒ flat f=σ2f=\sigma^2; filter ⇒ fY=fXA2f_Y=f_X|A|^2; ARMA f=σ2θ2/ϕ2f=\sigma^2|\theta|^2/|\phi|^2.
  • HMM filter: predict πt+1t=Aπtt\pi^{t+1\mid t}=A\pi^{t\mid t}, update reweight-by-emission-and-renormalize.
  • HMM smoothing: P(Xty1T)αt(j)βt(j)P(X_t\mid y_1^T)\propto\alpha_t(j)\beta_t(j) (forward × backward).

Rederivable on demand: MA(1) stationarity, AR(1) uniqueness (remainder 0\to0), Yule–Walker from covariancing both sides + the AR(2) solve, the PACF-cutoff argument, DFT inversion, fY=fXA2f_Y=f_X|A|^2, the process-representation Riemann-sum limit, the filter recursion from Bayes, the backward recursion, Viterbi log-decomposition.

Named moves (cross-track glossary)

  • Invert-via-geometric-series — treat ϕ(B)\phi(B) as a scalar, expand 1/(1ϕB)1/(1-\phi B); converts AR↔MA and divides ARMA polynomials. (§3, §4)
  • Roots-outside-the-unit-circle — one condition, two names: causal (AR) / invertible (MA); also locates spectral peaks/dips. (§3, §7)
  • Difference-to-stationary — remove trend/season without estimating it; one ∇ per polynomial degree, d\nabla_d per season; beware over-differencing. (§2)
  • Time↔frequency duality — ACVF and spectrum are the same info; transform to make the operation easy (filtering = multiplication). (§7)
  • State augmentation (“stack the history”) — bundle lags into a Markov state; turns ARMA into a state-space/Kalman problem. Mirrors augment-then-marginalize in [[07_Bayesian_Statistics]]. (§8)
  • Predict-then-update — recursive Bayes filtering; the discrete Kalman filter / HMM forward pass. (§8)
  • Delta method — variance of a transform via first-order Taylor; here for variance stabilization, same tool as in [[03_Statistical_Inference]]. (§2)
  • Recognize-the-shape — match ACF/PACF cutoff-vs-decay to model order; the time-series version of the [[07_Bayesian_Statistics]] move. (§4)