Skip to main content

Note 03: Autocorrelation, Partial Autocorrelation & White Noise

Module 1: Foundations & Exploratory Analysis

Learning Objectives

  • Define autocovariance, autocorrelation (ACF), and partial autocorrelation (PACF) via linear projections under weak stationarity.
  • Distinguish weak white noise from iid Gaussian white noise and apply Bartlett significance bounds properly.
  • Use the Ljung-Box portmanteau test and ACF/PACF patterns to diagnose trend, seasonality, and short-range serial dependence.

1. Autocovariance, ACF, and PACF

For a weakly stationary process \(\{X_t\}\) with mean \(\mu\) and variance \(\gamma_0 = \sigma^2 > 0\), the autocovariance function (ACVF) and autocorrelation function (ACF) at integer lag \(k\) are:

\[ \gamma_k = \operatorname{Cov}(X_t, X_{t+k}) = \mathbb{E}\!\left[(X_t - \mu)(X_{t+k} - \mu)\right], \qquad \rho_k = \frac{\gamma_k}{\gamma_0}. \]

Both functions are symmetric (\(\gamma_{-k} = \gamma_k\), \(\rho_{-k} = \rho_k\)), with \(\rho_0 = 1\) and \(|\rho_k| \le 1\). Given a sample \(x_1, \dots, x_n\), the standard sample estimators are:

\[ \hat{\gamma}_k = \frac{1}{n} \sum_{t=1}^{n-k} (x_t - \bar{x})(x_{t+k} - \bar{x}), \qquad \hat{\rho}_k = \frac{\hat{\gamma}_k}{\hat{\gamma}_0}, \qquad k = 0, 1, \dots, n-1. \]

Using the divisor \(n\) (rather than \(n - k\)) guarantees that the sample autocovariance matrix is always positive semi-definite and shrinks noisy high-lag estimates gently toward zero.

Because \(\rho_k\) captures both direct dependence at lag \(k\) and indirect propagation through intermediate lags \(1, \dots, k-1\), we also define the partial autocorrelation function (PACF) \(\phi_{kk}\). Set \(\phi_{11} = \rho_1\). For \(k \ge 2\), let \(\hat{X}_t\) and \(\hat{X}_{t+k}\) denote the best linear predictors of \(X_t\) and \(X_{t+k}\) based on the intervening observations \(\{X_{t+1}, \dots, X_{t+k-1}\}\). Then:

\[ \phi_{kk} = \operatorname{Corr}\!\left(X_t - \hat{X}_t,\; X_{t+k} - \hat{X}_{t+k}\right). \]

Equivalently, \(\phi_{kk}\) is the final lag coefficient in the minimum mean-squared error linear projection of \(X_t\) onto \(X_{t-1}, \dots, X_{t-k}\). When \(\{X_t\}\) is jointly Gaussian, best linear projection equals conditional expectation, so \(\phi_{kk}\) coincides with the conditional correlation \(\operatorname{Corr}(X_t, X_{t+k} \mid X_{t+1}, \dots, X_{t+k-1})\).

2. White Noise, Bartlett Bounds, and Ljung-Box

A process \(\{\varepsilon_t\}\) is weak white noise, written \(\varepsilon_t \sim \text{WN}(0, \sigma^2)\), if:

\[ \mathbb{E}[\varepsilon_t] = 0, \qquad \operatorname{Var}(\varepsilon_t) = \sigma^2 < \infty, \qquad \gamma_k = \operatorname{Cov}(\varepsilon_t, \varepsilon_{t+k}) = 0 \quad \text{for all } k \neq 0. \]

A strictly stronger condition is iid Gaussian white noise, \(\varepsilon_t \stackrel{\text{iid}}{\sim} \mathcal{N}(0, \sigma^2)\), which rules out all nonlinear dependence (such as volatility clustering) in addition to linear autocorrelation.

For an iid white noise sequence with finite variance, Bartlett’s asymptotic theorem implies that for any fixed lag \(k \ge 1\):

\[ \sqrt{n}\,\hat{\rho}_k \xrightarrow{d} \mathcal{N}(0, 1), \]

and \(\hat{\rho}_j, \hat{\rho}_k\) are asymptotically independent for \(j \neq k\). Consequently, individual sample autocorrelations fall inside the 95% confidence band \(\pm 1.96/\sqrt{n}\) with probability approximately \(0.95\). Even for pure white noise, roughly 1 in 20 plotted lags will cross the dashed threshold by chance alone.

To test the joint null hypothesis \(H_0: \rho_1 = \rho_2 = \dots = \rho_h = 0\) across multiple lags simultaneously, we use the Ljung-Box portmanteau statistic:

\[ Q(h) = n(n + 2) \sum_{k=1}^{h} \frac{\hat{\rho}_k^2}{n - k} \xrightarrow{d} \chi^2_h \quad \text{under } H_0. \]

For raw series (no estimated ARMA parameters), the reference distribution has \(h\) degrees of freedom (dof = 0 in feasts::ljung_box). Let us contrast pure Gaussian white noise with a lag-3 contaminated series \(Y_t = \varepsilon_t + 0.4\,\varepsilon_{t-3}\).

set.seed(493)
n <- 250
eps <- rnorm(n + 3)

sim_wn <- tsibble(
  t = 1:n,
  wn = eps[4:(n + 3)],
  contaminated = eps[4:(n + 3)] + 0.4 * eps[1:n],
  index = t
)

lb_res <- sim_wn |>
  pivot_longer(-t, names_to = "Series", values_to = "Value") |>
  as_tsibble(key = Series, index = t) |>
  features(Value, ljung_box, lag = 10, dof = 0)

lb_res |> fmt_tbl(digits = 4, caption = "Ljung-Box test (h = 10) for pure vs. lag-3 contaminated white noise.")
Ljung-Box test (h = 10) for pure vs. lag-3 contaminated white noise.
Series lb_stat lb_pvalue
contaminated 32.018 0.0004
wn 6.527 0.7692
wn_labels <- c(
  wn = TeX("Pure Gaussian White Noise", bold = TRUE, output = "character"),
  contaminated = TeX(r"(Contaminated: $Y_t = \epsilon_t + 0.4\,\epsilon_{t-3}$)", bold = TRUE, output = "character")
)

sim_wn |>
  pivot_longer(-t, names_to = "Series", values_to = "Value") |>
  mutate(Series = factor(Series, levels = c("wn", "contaminated"))) |>
  as_tsibble(key = Series, index = t) |>
  ACF(Value, lag_max = 20) |>
  autoplot() +
  facet_wrap(~ Series, ncol = 2, labeller = as_labeller(wn_labels, default = label_parsed)) +
  labs(
    title = "Sample ACF: Pure vs. Lag-3 Contaminated White Noise",
    subtitle = TeX(r"(Dashed blue bands mark $\pm 1.96/\sqrt{n}$ Bartlett bounds)"),
    x = "Lag",
    y = TeX(r"(Sample ACF ($\hat{\rho}_k$))", bold = TRUE)
  )
Figure 1: Sample ACF of pure Gaussian white noise compared with a lag-3 contaminated process Y_t = e_t + 0.4 e_{t-3}, showing the isolated lag-3 spike.

3. Canonical ACF and PACF Signatures on Real Series

Inspecting ACF and PACF plots together reveals the dominant structure of an observed time series:

  • Strong trend (aus_airpassengers): the ACF stays large and positive across many lags, decaying slowly and almost linearly, while the PACF shows a dominant spike near 1 at lag 1.
  • Strong seasonality (aus_production$Beer, from 1992 Q1): the ACF displays scalloped peaks at seasonal multiples (lags \(4, 8, 12, \dots\)) and troughs at half-cycle lags (\(2, 6, 10, \dots\)).
  • Stationary short-memory series (us_change$Consumption): both ACF and PACF die out rapidly within the first few lags.
beer_recent <- aus_production |> filter_index("1992 Q1" ~ .)

a1 <- aus_airpassengers |> ACF(Passengers, lag_max = 16) |> autoplot() +
  labs(title = "Trend: Air Passengers", x = NULL, y = TeX(r"(ACF ($\hat{\rho}_k$))", bold = TRUE))
a2 <- beer_recent |> ACF(Beer, lag_max = 16) |> autoplot() +
  labs(title = "Seasonality: Beer", x = NULL, y = NULL)
a3 <- us_change |> ACF(Consumption, lag_max = 16) |> autoplot() +
  labs(title = "Stationary: Consumption", x = NULL, y = NULL)

p1 <- aus_airpassengers |> PACF(Passengers, lag_max = 16) |> autoplot() +
  labs(x = "Lag (Years)", y = TeX(r"(PACF ($\hat{\phi}_{kk}$))", bold = TRUE))
p2 <- beer_recent |> PACF(Beer, lag_max = 16) |> autoplot() +
  labs(x = "Lag (Quarters)", y = NULL)
p3 <- us_change |> PACF(Consumption, lag_max = 16) |> autoplot() +
  labs(x = "Lag (Quarters)", y = NULL)

((a1 | a2 | a3) / (p1 | p2 | p3)) +
  plot_layout(guides = "collect") +
  plot_annotation(
    title = "Canonical ACF and PACF Signatures on Real Series",
    subtitle = TeX(r"(Top row: sample ACF ($\hat{\rho}_k$); bottom row: sample PACF ($\hat{\phi}_{kk}$))"),
    theme = theme_ts()
  ) &
  theme(legend.position = "bottom")
Figure 2: ACF (top row) and PACF (bottom row) signatures for a trending series (air passengers), a quarterly seasonal series (beer production), and a stationary macroeconomic growth series (U.S. consumption).

Practice Exercises

Exercise 1: Detecting Periodic Contamination

Simulate \(n = 240\) observations from \(Z_t = \varepsilon_t - 0.5\,\varepsilon_{t-4}\) with \(\varepsilon_t \stackrel{\text{iid}}{\sim} \mathcal{N}(0, 1)\) (set.seed(103)). Compute the theoretical lag-4 autocorrelation \(\rho_4\), verify it against the sample ACF, and test for white noise with the Ljung-Box test at \(h = 10\).

Solution

Since \(\operatorname{Var}(Z_t) = 1 + (-0.5)^2 = 1.25\) and \(\gamma_4 = -0.5\), the exact theoretical lag-4 autocorrelation is \(\rho_4 = -0.5 / 1.25 = -0.40\), with \(\rho_k = 0\) for all other \(k \ge 1\).

set.seed(103)
n_ex <- 240
e <- rnorm(n_ex + 4)
z_ts <- tsibble(t = 1:n_ex, z = e[5:(n_ex + 4)] - 0.5 * e[1:n_ex], index = t)

acf_lag4 <- z_ts |> ACF(z, lag_max = 10) |> filter(lag == 4) |> pull(acf)
lb_z <- z_ts |> features(z, ljung_box, lag = 10, dof = 0)

tibble(
  `Theoretical rho_4` = -0.40,
  `Sample r_4` = acf_lag4,
  `LB Q(10)` = lb_z$lb_stat,
  `LB p-value` = lb_z$lb_pvalue
) |> fmt_tbl(digits = 4, caption = "Lag-4 contamination verification and Ljung-Box diagnostic.")
Lag-4 contamination verification and Ljung-Box diagnostic.
Theoretical rho_4 Sample r_4 LB Q(10) LB p-value
-0.4 -0.362 39.6 0

Exercise 2: Raw vs. First-Differenced Gas Production

Filter aus_production from 1970 Q1 onward and compare the ACF and Ljung-Box statistics (lag = 12) of raw Gas versus its first difference difference(Gas). What structure remains after first differencing?

Solution

First differencing removes the slow trend decay from the ACF, exposing strong positive autocorrelation at lags \(4, 8, 12\) and negative correlation at lag \(2\). Because quarterly seasonality remains, the Ljung-Box test still strongly rejects white noise.

gas_df <- aus_production |>
  filter_index("1970 Q1" ~ .) |>
  mutate(dGas = difference(Gas))

bind_rows(
  gas_df |> features(Gas, ljung_box, lag = 12, dof = 0) |> mutate(Series = "Raw Gas"),
  gas_df |> features(dGas, ljung_box, lag = 12, dof = 0) |> mutate(Series = "Differenced Gas")
) |>
  select(Series, lb_stat, lb_pvalue) |>
  fmt_tbl(digits = 4, caption = "Ljung-Box statistics (h = 12) before and after first differencing Gas.")
Ljung-Box statistics (h = 12) before and after first differencing Gas.
Series lb_stat lb_pvalue
Raw Gas 1342.3 0
Differenced Gas 864.2 0
gas_labels <- c(
  raw = TeX(r"(Raw Gas: $y_t$)", bold = TRUE, output = "character"),
  diff = TeX(r"(First-Differenced Gas: $\nabla y_t$)", bold = TRUE, output = "character")
)

gas_df |>
  select(Quarter, raw = Gas, diff = dGas) |>
  pivot_longer(-Quarter, names_to = "Series", values_to = "Value") |>
  mutate(Series = factor(Series, levels = c("raw", "diff"))) |>
  as_tsibble(key = Series, index = Quarter) |>
  ACF(Value, lag_max = 16) |>
  autoplot() +
  facet_wrap(~ Series, ncol = 2, labeller = as_labeller(gas_labels, default = label_parsed)) +
  labs(
    title = "ACF Before and After First Differencing Quarterly Gas",
    subtitle = TeX(r"(Differencing removes trend decay, exposing seasonal spikes at lags $4, 8, 12$)"),
    x = "Lag (Quarters)",
    y = TeX(r"(Sample ACF ($\hat{\rho}_k$))", bold = TRUE)
  )
Figure 3: ACF of raw quarterly Australian gas production versus first-differenced gas production, highlighting persistent quarterly seasonality.

Key Takeaways

  • Sample autocovariances use divisor \(n\) so that the estimated covariance matrix remains positive semi-definite.
  • The PACF \(\phi_{kk}\) measures the correlation between \(X_t\) and \(X_{t+k}\) after projecting out the linear effects of intermediate lags \(X_{t+1}, \dots, X_{t+k-1}\).
  • Bartlett’s \(\pm 1.96/\sqrt{n}\) bands test one lag at a time; use the Ljung-Box test \(Q(h)\) to evaluate joint serial correlation across lags \(1, \dots, h\).
  • Slowly decaying ACFs indicate trend, scalloped peaks at multiples of \(m\) indicate seasonality, and rapid decay indicates stationary short-range dependence.
Back to top