Solution (source code)

= Solution

For a <weakly stationary process> with <mean> $m$ and nonzero <variance>, put $\gamma(h)=\operatorname{Cov}(X_{t+h},X_t)$ and $\rho(h)=\gamma(h)/\gamma(0)$. The function $\rho$ is its <autocorrelation function>. For observations $x_1,\ldots,x_N$, one common <sample autocorrelation function> is
$$
\widehat\gamma(h)=\frac1N\sum_{t=1}^{N-h}(x_t-\overline x)(x_{t+h}-\overline x),
\qquad \widehat\rho(h)=\frac{\widehat\gamma(h)}{\widehat\gamma(0)}.
$$
A <correlogram> plots these estimates against lag; the population analogue plots $\rho(h)$.

The lag-$h$ <partial autocorrelation function> measures the <correlation> between $X_t$ and $X_{t-h}$ after removing their <linear projections> on the intervening observations. Its sample counterpart can be calculated by the <Yule-Walker equations>: solve
$$
\widehat R_h\widehat\phi_h=\widehat r_h,
\qquad (\widehat R_h)_{ij}=\widehat\rho(|i-j|),
\qquad (\widehat r_h)_i=\widehat\rho(i),
$$
and take $\widehat\alpha(h)=\widehat\phi_{h,h}$, assuming the matrix is nonsingular. This defines a standard <sample partial autocorrelation function>.

For a minimal causal <autoregressive model> of order $p$, the <autocorrelation> typically decays geometrically, possibly with damped oscillations, whereas the <partial autocorrelation function> is zero beyond lag $p$: after those $p$ preceding values have been projected out, the innovation is orthogonal to older values. For a <moving-average model> of order $q$, nonoverlapping sets of driving <white noise> give $\gamma(h)=0$ for $|h|>q$; its <partial autocorrelation function> generally tails off when the representation is invertible. Thus \b[an ACF cutoff suggests an MA order; a PACF cutoff suggests an AR order]. An <ARMA> model generally has neither cutoff. These are population properties; sample noise makes cutoffs approximate, so fitted residuals and uncertainty should also be inspected. Under <independent> <white noise>, fixed-lag sample <correlations> have approximate standard error $N^{-1/2}$, giving a rough diagnostic band rather than a universal simultaneous test.