ECON 4354 / 6354 Forecasting

Lecture 7: Cycles I, Stationarity and Autoregression

Zhan Gao

08 October 2026

The third component

Previously we wrote y_t = T_t + S_t + C_t + \varepsilon_t and dealt with trend and seasonality. Both are deterministic: fixed functions of the calendar, hence trivial to extrapolate.

Every residual plot in that lecture told the same story: what was left over has rich dynamics.

That the third component C_t - the cycle.

Cycles, broadly defined

When you hear “cycle” you may picture the rigid up-and-down pattern on the left. Fluctuations in business, finance and economics are rarely that regular.

What we mean by a cycle is any stable, mean-reverting dynamics not captured by the trend or the seasonal: the series is persistent, yet shocks eventually die out and the series returns toward a fixed mean. The right panel qualifies; so does every residual series from the previous lecture.

Today

Trend and seasonal dynamics were simple to model. Cyclical dynamics are richer, and so are the models…

Today:

  • the language for describing such dynamics (covariance stationarity, autocorrelation)

  • the simplest model that produces them (the autoregression)

  • how to forecast with it (Wold’s chain rule).

Roadmap

Diebold, Forecasting in Economics, Business, Finance and Beyond, Chapter 6. Sections 1 to 3 also draw on Pesaran (2015), Time Series and Panel Data Econometrics, Chapter 14.

Stationarity


A time series is one realization

  • A time series is a chronologically ordered collection of random variables. In theory the sequence \ldots, y_{-1}, y_0, y_1, y_2, \ldots runs from the infinite past to the infinite future; what we observe, y_1, \ldots, y_T, is a finite piece of one draw, the sample path.
  • The observations are dependent: y_t is related to y_{t-1}. Cross-sectional analysis relies on independence across observations. Here the dependence is the object of study, because it is what links the future to the past.
  • We see a single realization. Statistical analysis needs repeated patterns: something about the process must be the same at t_0 as at t_0 + h.

A time line with the values at t0, t0+1, t0+2 in red and the values at t0+h, t0+h+1, t0+h+2 in yellow: the same pattern, shifted by h

Strict and weak stationarity

Stationarity requires the “patterns” to be invariant across time.

  • Strict stationarity. The joint distribution of (y_{t_1}, \ldots, y_{t_k}) equals that of (y_{t_1+h}, \ldots, y_{t_k+h}) for every k, every choice of dates, and every shift h.
  • Weak, or covariance, stationarity restricts only the first two moments:
    1. E(y_t) = \mu for all t: the mean is constant, so it needs no time subscript;
    2. \gamma(t, \tau) = \operatorname{cov}(y_t, y_{t-\tau}) = \gamma(\tau) for all t: the autocovariance depends only on the displacement \tau, not on the date;
    3. \gamma(0) = \operatorname{var}(y_t) < \infty.
  • Strict stationarity implies covariance stationarity when the first two moments exist. Everything in this course rests on the weak version.

Because only means and covariances are restricted, covariance stationarity is also called second-order stationarity. It says nothing about skewness, kurtosis, or the shape of the distribution.

The autocovariance function

\gamma(\tau) = E[(y_t - \mu)(y_{t-\tau} - \mu)], viewed as a function of \tau, is the basic summary of a stationary series’ dynamics.

  • It is symmetric, \gamma(\tau) = \gamma(-\tau): only the displacement matters, not its direction. We plot \tau \geq 0.
  • \gamma(0) = \operatorname{var}(y_t), and |\gamma(\tau)| \leq \gamma(0) by the Cauchy-Schwarz inequality. A finite variance therefore makes every autocovariance finite.
  • Its units are the square of the units of y. A covariance of ten million says nothing about the strength of association; a correlation of 0.95 does.

So we standardize. The autocorrelation function is

\rho(\tau) = \frac{\operatorname{cov}(y_t, y_{t-\tau})}{\sqrt{\operatorname{var}(y_t)}\sqrt{\operatorname{var}(y_{t-\tau})}} = \frac{\gamma(\tau)}{\sqrt{\gamma(0)}\sqrt{\gamma(0)}} = \frac{\gamma(\tau)}{\gamma(0)}, \qquad \tau = 0, 1, 2, \ldots

using that under stationarity both variances equal \gamma(0). Always \rho(\tau) \in [-1, 1] and \rho(0) = 1; only the displacements beyond 0 carry information.

The partial autocorrelation function

The partial autocorrelation at displacement \tau, p(\tau), is the coefficient on y_{t-\tau} in the population linear regression

y_t \;\text{ on }\; y_{t-1},\, y_{t-2},\, \ldots,\, y_{t-\tau} .

Such regressions are called autoregressions: the variable is regressed on its own lags.

  • The autocorrelation \rho(\tau) is the simple correlation between y_t and y_{t-\tau}.
  • The partial autocorrelation p(\tau) is the correlation between y_t and y_{t-\tau} after controlling for y_{t-1}, \ldots, y_{t-\tau+1}.
  • At displacement 1 there is nothing to control for, so p(1) = \rho(1). Beyond it they diverge, and each summarizes the dynamics in its own way.

Like \rho(0), p(0) = 1 by construction. Plots of both functions start at displacement 1.

“Population regression”: imagine an infinite sample, so that the coefficients are the true values, free of sampling variation.

Shapes of autocorrelation functions

All the processes we study have autocorrelations and partial autocorrelations that approach zero as the displacement grows. How they approach zero is the fingerprint we will read.

  • Panels (a) and (c): gradual decay, monotone in one case, oscillating in the other.
  • Panel (d): an abrupt drop to zero beyond some displacement.
  • Panel (b) is ruled out: a stationary series must eventually forget its past.

Otherwise one realization could never reveal the mean. Strictly this is an ergodicity condition on top of stationarity; Diebold folds it into the definition.

Is nonstationarity fatal?

Many economic series are not covariance stationary. A trend is a mean that rises over time; seasonality is a mean that varies with the season. Both violate requirement 1.

Two strategies make the assumption workable nonetheless:

  1. Model the nonstationary components explicitly, as in later lectures, and treat the cycle that is left over as stationary. That is the plan for most of the course.
  2. Transform. Series nonstationary in levels often look stationary in growth rates.

The tell-tale sign of a trend: a sample ACF that barely decays (left). In growth rates the same data show modest, quickly fading persistence (right).

White noise, and the Wold representation


The fundamental building block

Before estimating anything we need the population properties of a few time series processes. The simplest one is the block from which all others are built:

y_t = \varepsilon_t, \qquad \varepsilon_t \sim (0, \sigma^2), \qquad \sigma^2 < \infty,

with the shock \varepsilon_t uncorrelated over time. A process with zero mean, constant variance and no serial correlation is white noise: y_t \sim WN(0, \sigma^2).

Two stronger versions, by adding assumptions:

  • Independent white noise, y_t \sim \text{iid}(0, \sigma^2): serially independent, not merely uncorrelated. Zero correlation implies independence only in the normal case, so this is a genuine strengthening.
  • Gaussian white noise, y_t \sim \text{iid}\, N(0, \sigma^2): uncorrelated and normal, hence independent.

The name is by analogy with white light, which contains every color of the spectrum in equal amounts: white noise is composed of cycles of every periodicity, in equal amounts.

A realization of Gaussian white noise

set.seed(1)
wn <- data.frame(t = 1:150, y = rnorm(150))
ggplot(wn, aes(t, y)) + geom_hline(yintercept = 0, colour = "grey40") +
  geom_line(colour = smu_blue) + labs(x = NULL, y = NULL)

There are no patterns of any kind. Whatever happened last period tells you nothing about this one.

You have met white noise before: the disturbance of a regression model is assumed to be white noise of one sort or another. The difference is that regression disturbances are unobservable, whereas here we are modeling an observed series.

Moments of white noise

Unconditional mean and variance: E(y_t) = 0 and \operatorname{var}(y_t) = \sigma^2, both constant, as they must be for any covariance stationary process.

Because the shocks are uncorrelated, every autocovariance beyond displacement 0 is zero:

\gamma(\tau) = \begin{cases} \sigma^2, & \tau = 0 \\ 0, & \tau \geq 1 \end{cases} \qquad \rho(\tau) = \begin{cases} 1, & \tau = 0 \\ 0, & \tau \geq 1 \end{cases} \qquad p(\tau) = \begin{cases} 1, & \tau = 0 \\ 0, & \tau \geq 1. \end{cases}

The partial autocorrelations vanish for the same reason: a population regression of y_t on y_{t-1}, or on y_{t-1} and y_{t-2}, or on any set of lags, produces nothing but zero coefficients.

Degenerate, yes. Also the reference point: every diagnostic we build asks how far is this series from white noise, and in what direction.

Conditional and unconditional moments

A second way to characterize dynamics: the mean and variance of y_t conditional on its past, \Omega_{t-1} = \{y_{t-1}, y_{t-2}, \ldots\}. For independent white noise,

E(y_t \mid \Omega_{t-1}) = 0, \qquad \operatorname{var}(y_t \mid \Omega_{t-1}) = E\big[(y_t - E(y_t \mid \Omega_{t-1}))^2 \mid \Omega_{t-1}\big] = \sigma^2 .

Conditional and unconditional moments coincide: there are no dynamics.

For a process with dynamics they differ. Unconditional moments must be constant, by stationarity. Conditional moments move with the information set: expected laptop sales growth next quarter may be ten percent unconditionally, but much higher given that sales grew twenty percent this quarter.

The conditional mean is exactly the object Lecture 4 called the optimal forecast under quadratic loss. Time series modeling is the business of computing it.

Why white noise matters

  1. It is the building block. Processes with much richer dynamics are simple transformations of white noise. The next slide makes that precise.
  1. It is the target. The goal of time series modeling, and of one-step-ahead forecasting, is to reduce the data to white noise. If the one-step forecast errors are not white noise, they are serially correlated, hence forecastable, hence the forecast can be improved.

A good model leaves behind residuals you cannot forecast.

So we need to recognize white noise when we see it, and to test for it.

The Wold representation (a preview)

Wold (1938). Let y_t be covariance stationary with any deterministic part d_t (a constant, a trend, seasonals) removed. Then

y_t = d_t + \sum_{j=0}^{\infty} b_j\, \varepsilon_{t-j}, \qquad b_0 = 1, \qquad \sum_{j=0}^{\infty} b_j^2 < \infty,

where \varepsilon_t is the innovation, the part of y_t that the linear past cannot predict, and \varepsilon_t \sim WN(0, \sigma^2).

Read it as: every stationary process is white noise passed through a linear filter. Infinitely many coefficients look hopeless for estimation with finite data. They are not, because parsimonious models (autoregressions, coming up) imply particular sequences b_j with only a few free parameters.

Summable coefficients keep the process stable

Suppose the coefficients decay fast enough to be absolutely summable, \sum_j |b_j| < \infty (exponential decay is the leading case). Then, with d_t = 0:

  • The autocovariances are \gamma(\tau) = \operatorname{cov}\Big(\sum_j b_j \varepsilon_{t-j}, \sum_k b_k \varepsilon_{t-\tau-k}\Big) = \sigma^2 \sum_{j=0}^{\infty} b_j\, b_{j+\tau}, because E(\varepsilon_{t-j}\varepsilon_{t-\tau-k}) = \sigma^2 only when j = k + \tau and is 0 otherwise.
  • They are absolutely summable too: \sum_{\tau=0}^{\infty} |\gamma(\tau)| \leq \sigma^2 \sum_{\tau} \sum_{j} |b_j|\,|b_{j+\tau}| \leq \sigma^2 \Big(\sum_j |b_j|\Big)^2 < \infty, so \rho(\tau) \to 0: the process forgets. This is the decay we asked for.
  • The long-run variance, \lim_{T\to\infty} \operatorname{var}\big(\sqrt{T}\,\bar y\big) = \sum_{\tau=-\infty}^{\infty} \gamma(\tau), is finite. It is what replaces \sigma^2 in the standard error of a time series mean.

The sample correlogram and Q tests


The analog principle

Now we have data, and here is how to do model-free chracterizatino of the dynamics of the observed time series. The analog principle: estimate population moments by replacing expectations with sample averages.

\hat\mu = \bar y = \frac{1}{T}\sum_{t=1}^T y_t, \qquad \hat\gamma(\tau) = \frac{1}{T}\sum_{t=\tau+1}^{T} (y_t - \bar y)(y_{t-\tau} - \bar y), \qquad \hat\rho(\tau) = \frac{\hat\gamma(\tau)}{\hat\gamma(0)} .

  • The sum starts at t = \tau + 1 because y_{t-\tau} must exist, yet we divide by T, not T - \tau. When T is large relative to \tau it hardly matters, and dividing by T has a technical advantage.
  • \hat\rho(\tau) as a function of \tau is the sample autocorrelation function, or correlogram.

The sample partial autocorrelation replaces the population regression by the feasible one: fit \hat y_t = \hat c + \hat\beta_1 y_{t-1} + \cdots + \hat\beta_\tau y_{t-\tau} by OLS and set \hat p(\tau) = \hat\beta_\tau. Again \hat p(1) = \hat\rho(1).

Dividing by T makes the sequence \hat\gamma(0), \hat\gamma(1), \ldots positive semidefinite, like every true autocovariance function. Dividing by T - \tau does not guarantee that.

Sampling distribution under white noise

A key result, which we simply assert: if y is white noise, then in large samples

\hat\rho(\tau) \;\sim\; N\!\Big(0, \frac{1}{T}\Big), \qquad \tau = 1, 2, \ldots,

and the sample autocorrelations at different displacements are approximately independent.

  • Mean zero: \hat\rho(\tau) is unbiased for the true value, which is zero.
  • Standard deviation 1/\sqrt{T}: easy to construct and to remember.
  • So about 95% of the sample autocorrelations of a white noise series fall within 0 \pm 2/\sqrt{T}. These are the two-standard-error bands drawn on every correlogram. The same result and the same bands hold for \hat p(\tau).

The bands judge one displacement at a time. Usually the question is joint: is the whole autocorrelation function zero?

From bands to a joint test

Rewrite the result as \sqrt{T}\,\hat\rho(\tau) \sim N(0,1) and square it: T\hat\rho^2(\tau) \sim \chi^2_1. Squaring stops positive and negative values from cancelling when we add them up.

Sum m approximately independent \chi^2_1 variables and you get a \chi^2_m. Hence the Box-Pierce Q statistic

Q_{BP} = T \sum_{\tau=1}^{m} \hat\rho^2(\tau) \;\overset{d}{\sim}\; \chi^2_m, \quad \text{ under } H_0: \rho(1) = \cdots = \rho(m) = 0 in large samples.

Its finite-sample behavior is poor. A reweighting that follows the \chi^2_m more closely in small samples is the Ljung-Box Q statistic

Q_{LB} = T(T+2) \sum_{\tau=1}^{m} \frac{\hat\rho^2(\tau)}{T - \tau} \;\overset{d}{\sim}\; \chi^2_m \quad \text{ under } H_0 .

The weights (T+2)/(T-\tau) are near 1 for large T, so the two rarely disagree.

Choosing m. Too small and the test ignores most of the autocorrelation function; too large relative to T and the \chi^2 approximation deteriorates. m near \sqrt{T} is a reasonable rule of thumb.

The correlogram in a few lines of R

Base R already computes each piece: acf(), pacf(), and Box.test(). Assembling them into the table a textbook prints takes one small function, which we will reuse all day.

correlogram <- function(x, m = 12, dof = 0) {
  T <- length(x)
  a <- acf(x, lag.max = m, plot = FALSE)$acf[-1]          # rho_hat(1), ..., rho_hat(m)
  p <- pacf(x, lag.max = m, plot = FALSE)$acf[, 1, 1]     # p_hat(1), ..., p_hat(m)
  Q <- T * (T + 2) * cumsum(a^2 / (T - 1:m))               # Ljung-Box, for m = 1, 2, ...
  pv <- pchisq(Q, df = pmax(1:m - dof, 1), lower.tail = FALSE)
  pv[1:m <= dof] <- NA                                     # no p-value until m > dof
  data.frame(lag = 1:m, acf = round(a, 3), pacf = round(p, 3), Q = round(Q, 2), p = round(pv, 4))
}

dof is for later: when x is a residual from a model with dof estimated parameters, the null distribution of Q is better approximated by \chi^2_{m - \text{dof}}.

acf() divides by T, exactly as on the previous slide. corr_plot(), the bar-chart helper used below, is defined in the source of these slides.

A process whose truth we know

Simulate a series with dynamics, an autoregression of order two (the model is explained later), and look at its correlogram.

set.seed(123)
y <- arima.sim(n = 1000, list(ar = c(0.5, 0.3)))    # y_t = 0.5 y_{t-1} + 0.3 y_{t-2} + e_t
corr_plot(y, lag_max = 12)

The dashed lines are \pm 2/\sqrt{1000} = \pm 0.063. The sample autocorrelations decay gradually and stay far outside the bands for many displacements; the partial autocorrelations are large at 1 and 2 and negligible beyond. Remember that shape.

Q tests on the simulated series

Box.test(y, lag = 10, type = "Box-Pierce")
## 
##  Box-Pierce test
## 
## data:  y
## X-squared = 1795.5, df = 10, p-value < 2.2e-16
Box.test(y, lag = 10, type = "Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  y
## X-squared = 1805.3, df = 10, p-value < 2.2e-16

Both reject white noise beyond any doubt, and they barely differ: T = 1000 is large. For contrast, a fresh draw of pure noise:

set.seed(321); Box.test(rnorm(1000), lag = 10, type = "Ljung-Box")$p.value
## [1] 0.173089

Application: Canadian employment I


The Canadian employment data

A quarterly, seasonally adjusted index of Canadian employment, 1962Q1 to 1993Q4 (T = 128). The file also holds 1961 and 1994, which we keep aside: 1961 supplies pre-sample lags, 1994 is the realization we will forecast.

emp <- read.csv("data/caemp.csv") |> mutate(Quarter = yearquarter(Quarter)) |> as_tsibble(index = Quarter)
samp <- emp |> filter(Quarter >= yearquarter("1962 Q1"), Quarter <= yearquarter("1993 Q4"))
autoplot(samp, Employment, colour = smu_blue) + labs(x = NULL, y = "employment index")

No trend, and no seasonality because the series is seasonally adjusted. But it is highly serially correlated: it evolves slowly, high in booms and low in the recessions of the early 1980s and early 1990s.

Correlogram analysis

correlogram(samp$Employment, m = 12)
##    lag    acf   pacf      Q p
## 1    1  0.949  0.949 118.05 0
## 2    2  0.877 -0.244 219.60 0
## 3    3  0.795 -0.100 303.65 0
## 4    4  0.707 -0.070 370.75 0
## 5    5  0.617 -0.066 422.20 0
## 6    6  0.526 -0.047 459.91 0
## 7    7  0.437 -0.031 486.23 0
## 8    8  0.351 -0.049 503.32 0
## 9    9  0.258 -0.151 512.62 0
## 10  10  0.163 -0.071 516.36 0
## 11  11  0.073 -0.010 517.12 0
## 12  12 -0.005  0.016 517.13 0

The two-standard-error band is 2/\sqrt{128} = 0.18. Each row’s Q uses the autocorrelations up to that displacement.

Reading the table

  • Q statistics. For every m from 1 to 12 the p-value is zero to four decimals: the white noise hypothesis is decisively rejected. Employment has a cyclical component.
  • Sample autocorrelations. Very large relative to the 0.18 standard error, and they display slow, one-sided decay: 0.95, 0.88, 0.80, 0.71, \ldots
  • Sample partial autocorrelations. Large at displacement 1 (equal to the autocorrelation, necessarily) and clearly negative at displacement 2 (-0.24), then statistically negligible.

Gradual autocorrelation decay together with a partial autocorrelation function that cuts off at displacement 2 is a particular shape. Such shapes suggest candidate models, and

The correlogram, plotted

corr_plot(samp$Employment, lag_max = 12)

Diebold’s Figure 6.10. Dashed lines: \pm 2/\sqrt{T}.

The same with fpp3

feasts computes the same objects from a tsibble; gg_tsdisplay() draws series and correlogram in one call.

samp |> gg_tsdisplay(Employment, plot_type = "partial", lag_max = 12)

samp |> features(Employment, ljung_box, lag = 12)
## # A tibble: 1 × 2
##   lb_stat lb_pvalue
##     <dbl>     <dbl>
## 1    517.         0

Autoregressive models


The lag operator

Many time series models can be easily written in the language of the lag operator L, which lags a series: L y_t = y_{t-1}, L^2 y_t = L(L y_t) = y_{t-2}, and L^m y_t = y_{t-m}.

Usually we operate with a polynomial in L,

B(L) = b_0 + b_1 L + b_2 L^2 + \cdots + b_m L^m ,

so that B(L) y_t = b_0 y_t + b_1 y_{t-1} + \cdots + b_m y_{t-m}, a weighted sum of current and past values called a distributed lag.

  • The first-difference operator is a first-order lag polynomial: \Delta y_t = (1 - L) y_t = y_t - y_{t-1}.
  • (1 + 0.9L + 0.6L^2)\, y_t = y_t + 0.9\, y_{t-1} + 0.6\, y_{t-2}.
  • Infinite order is allowed: B(L)\varepsilon_t = \sum_{i=0}^{\infty} b_i \varepsilon_{t-i}. The Wold representation is exactly B(L)\varepsilon_t with b_0 = 1.

Most time series models contain distributed lags, because they say how the past evolves into the present. The notation is shorthand for stating and manipulating them.

Where you have already met the AR(1)

The Durbin-Watson setting was a regression with serially correlated disturbances. Strip it to an intercept only:

y_t = \mu + \varepsilon_t, \qquad \varepsilon_t = \phi\, \varepsilon_{t-1} + v_t, \qquad v_t \sim \text{iid}(0, \sigma^2). \tag{1}

Lag equation (1) one period and multiply by \phi: \;\phi\, y_{t-1} = \phi\mu + \phi\, \varepsilon_{t-1}. Subtract from (1):

y_t - \phi\, y_{t-1} = \mu(1 - \phi) + (\varepsilon_t - \phi\, \varepsilon_{t-1}) \quad\Longleftrightarrow\quad y_t = \mu(1-\phi) + \phi\, y_{t-1} + v_t .

A regression with serially correlated disturbances and no lagged dependent variable is mathematically identical to one with a lagged dependent variable and iid disturbances. Each device mops up the serial correlation the other regressors leave behind; here there are no other regressors at all.

The AR(1) process

The first-order autoregressive process, AR(1), is

y_t = \phi\, y_{t-1} + \varepsilon_t, \qquad \varepsilon_t \sim WN(0, \sigma^2), \qquad\text{or}\qquad (1 - \phi L)\, y_t = \varepsilon_t .

A stochastic difference equation: the current value is a linear function of the previous value plus a shock.

set.seed(2); e <- rnorm(150)                                     # one shock sequence for both
ar1 <- function(phi) as.numeric(stats::filter(e, phi, method = "recursive"))
d <- data.frame(t = rep(1:150, 2), phi = rep(c("phi = 0.4", "phi = 0.95"), each = 150),
                y = c(ar1(0.4), ar1(0.95)))
ggplot(d, aes(t, y)) + geom_hline(yintercept = 0, colour = "grey40") + geom_line(colour = smu_blue) +
  facet_wrap(~ phi, scales = "free_y") + labs(x = NULL, y = NULL)

Same shocks, different \phi. With \phi = 0.95 the fluctuations are far more persistent: the AR(1) can capture highly persistent dynamics with a single parameter.

When is the AR(1) covariance stationary?

The condition, for any autoregression: all roots of the autoregressive lag polynomial lie outside the unit circle. For the AR(1) the polynomial is 1 - \phi L, its root is L = 1/\phi, and |1/\phi| > 1 if and only if |\phi| < 1.

To see why, substitute backward for the lagged y:

y_t = \varepsilon_t + \phi\, y_{t-1} = \varepsilon_t + \phi\,\varepsilon_{t-1} + \phi^2 y_{t-2} = \cdots = \sum_{i=0}^{k-1} \phi^i \varepsilon_{t-i} + \phi^k y_{t-k} .

If |\phi| < 1 the last term vanishes as k \to \infty and we obtain the moving-average representation

y_t = \varepsilon_t + \phi\, \varepsilon_{t-1} + \phi^2 \varepsilon_{t-2} + \cdots = \sum_{i=0}^{\infty} \phi^i \varepsilon_{t-i} .

This is the Wold representation with b_i = \phi^i, absolutely summable. Ultimately the shocks are the only things that move y, so y can be written as a weighted history of shocks, with geometrically fading weights. If |\phi| \geq 1 the weights do not fade and no such representation exists.

Unconditional and conditional moments

From the moving-average representation, with \varepsilon uncorrelated across dates,

E(y_t) = \sum_{i=0}^{\infty} \phi^i E(\varepsilon_{t-i}) = 0, \qquad \operatorname{var}(y_t) = \sigma^2 + \phi^2\sigma^2 + \phi^4\sigma^2 + \cdots = \sigma^2 \sum_{i=0}^{\infty}\phi^{2i} = \frac{\sigma^2}{1 - \phi^2} .

Conditional on the past, from the process itself,

E(y_t \mid y_{t-1}) = \phi\, E(y_{t-1} \mid y_{t-1}) + E(\varepsilon_t \mid y_{t-1}) = \phi\, y_{t-1}, \qquad \operatorname{var}(y_t \mid y_{t-1}) = \phi^2 \cdot 0 + \sigma^2 = \sigma^2 .

  • The conditional mean adapts to the information set as the process evolves. That is the forecast.
  • The conditional variance \sigma^2 is smaller than the unconditional \sigma^2/(1-\phi^2): knowing the past reduces uncertainty, by a factor that grows with |\phi|.

With an intercept, y_t = c + \phi\, y_{t-1} + \varepsilon_t, the mean is \mu = c/(1-\phi) and everything else goes through for y_t - \mu.

Autocovariances: the Yule-Walker equation

Multiply the process by y_{t-\tau} and take expectations:

y_t\, y_{t-\tau} = \phi\, y_{t-1}\, y_{t-\tau} + \varepsilon_t\, y_{t-\tau} \quad\Longrightarrow\quad \gamma(\tau) = \phi\, \gamma(\tau - 1), \qquad \tau \geq 1,

because \varepsilon_t is uncorrelated with everything before t, so E(\varepsilon_t y_{t-\tau}) = 0 for \tau \geq 1.

A recursion: given \gamma(\tau) it delivers \gamma(\tau + 1). The initial condition is the variance we just computed, \gamma(0) = \sigma^2/(1-\phi^2), so

\gamma(\tau) = \phi^\tau \frac{\sigma^2}{1 - \phi^2}, \qquad \rho(\tau) = \phi^\tau, \qquad \tau = 0, 1, 2, \ldots

  • Gradual decay, one-sided if \phi > 0 and oscillating if \phi < 0. Positive \phi is the relevant case in economics.
  • Sharp cutoff in the PACF: p(1) = \phi and p(\tau) = 0 for \tau > 1. The partial autocorrelations are the last coefficients of ever longer population autoregressions; if the truth is an AR(1), the first is \phi and every later one is zero.

Population ACF and PACF of two AR(1) processes

Diebold’s Figures 6.12 to 6.15. Persistence is far stronger at \phi = 0.95; both PACFs cut off after displacement 1.

The AR(p) process

The p-th order autoregressive process is

y_t = \phi_1 y_{t-1} + \phi_2 y_{t-2} + \cdots + \phi_p y_{t-p} + \varepsilon_t, \qquad \varepsilon_t \sim WN(0, \sigma^2),

or \Phi(L)\, y_t = (1 - \phi_1 L - \phi_2 L^2 - \cdots - \phi_p L^p)\, y_t = \varepsilon_t.

Its properties parallel the AR(1) case, and we state them without derivation:

  • Stationarity: covariance stationary if and only if all roots of \Phi(L) lie outside the unit circle. A quick necessary check is \sum_i \phi_i < 1: if it fails, the process cannot be stationary.
  • Autocorrelations decay gradually, as for the AR(1), but the patterns are richer.
  • Partial autocorrelations cut off sharply at displacement p, for the same reason as before.

The Canadian employment correlogram, gradual decay with a PACF cutoff at 2, is therefore the fingerprint of an AR(2).

Yule-Walker for the AR(2)

Multiply y_t = \phi_1 y_{t-1} + \phi_2 y_{t-2} + \varepsilon_t by y_{t-\tau} and take expectations:

\gamma(\tau) - \phi_1\gamma(\tau-1) - \phi_2\gamma(\tau-2) = \begin{cases} \sigma^2, & \tau = 0 \\ 0, & \tau \geq 1 . \end{cases}

Dividing by \gamma(0) gives the whole autocorrelation function recursively:

\rho(1) = \frac{\phi_1}{1 - \phi_2}, \qquad \rho(\tau) = \phi_1 \rho(\tau-1) + \phi_2 \rho(\tau-2), \quad \tau = 2, 3, \ldots

The equations for \tau = 1, 2 can also be solved the other way, for the parameters given the autocovariances:

\phi_1 = \frac{\gamma(0)\gamma(1) - \gamma(1)\gamma(2)}{\gamma(0)^2 - \gamma(1)^2}, \qquad \phi_2 = \frac{\gamma(0)\gamma(2) - \gamma(1)^2}{\gamma(0)^2 - \gamma(1)^2} .

Replacing \gamma by \hat\gamma gives the Yule-Walker estimator. We will use OLS instead, but the idea that autocovariances identify the parameters is worth keeping.

Complex roots: genuine cycles

In the AR(1), oscillation needs \phi < 0 and flips sign every period. Higher-order autoregressions can oscillate with longer, smoother periods, reminiscent of cycles in the traditional sense. That happens when some roots of \Phi(L) are complex. Take

y_t = 1.5\, y_{t-1} - 0.9\, y_{t-2} + \varepsilon_t, \qquad \Phi(L) = 1 - 1.5L + 0.9L^2 .

r <- polyroot(c(1, -1.5, 0.9)); r                      # the two roots, a conjugate pair
## [1] 0.8333333+0.6454972i 0.8333333-0.6454972i
Mod(1 / r)                                             # inverse roots: inside the unit circle
## [1] 0.9486833 0.9486833
2 * pi / acos(1.5 / (2 * sqrt(0.9)))                   # period of the implied cycle
## [1] 9.533584

The inverse roots 0.75 \pm 0.58i have modulus 0.95: stationary, but close to the boundary, so the oscillation damps slowly, with a period of about nine and a half quarters.

An AR(2) with complex roots, seen

Diebold’s Figure 6.16. The autocorrelation function oscillates with the period computed on the previous slide, and the PACF still cuts off at 2.

Estimating autoregressions

The sum of squares of an AR(p) is linear in the parameters, so estimation is an ordinary least squares regression of y_t on y_{t-1}, \ldots, y_{t-p} (and a constant). Nothing new to learn.

  • With lagged dependent variables OLS is consistent, though not unbiased, under stationarity; the usual t and F statistics are valid in large samples.
  • Order selection. The correlogram suggests candidates. AIC and SIC, choose among them, provided every candidate is fit to the same observations. We keep the pre-sample values as lags so that all orders use all T observations.
fit_stats <- function(m) {
  e <- residuals(m); y <- fitted(m) + residuals(m)
  T <- length(e); k <- length(coef(m)); ssr <- sum(e^2)
  c(R2 = 1 - ssr / sum((y - mean(y))^2), SER = sqrt(ssr / (T - k)),
    DW = sum(diff(e)^2) / ssr,
    AIC = log(ssr / T) + 2 * k / T, SIC = log(ssr / T) + k * log(T) / T)
}

Application: Canadian employment II


AR(1) to AR(4) by OLS

Build the lags on the full file, then restrict to 1962Q1 to 1993Q4. The lags of the first observations are the 1961 values, so every model below has T = 128.

est <- emp |>
  mutate(L1 = lag(Employment), L2 = lag(Employment, 2), L3 = lag(Employment, 3), L4 = lag(Employment, 4)) |>
  filter(Quarter >= yearquarter("1962 Q1"), Quarter <= yearquarter("1993 Q4"))
ar <- list(`AR(1)` = lm(Employment ~ L1, data = est),
           `AR(2)` = lm(Employment ~ L1 + L2, data = est),
           `AR(3)` = lm(Employment ~ L1 + L2 + L3, data = est),
           `AR(4)` = lm(Employment ~ L1 + L2 + L3 + L4, data = est))
round(t(sapply(ar, fit_stats)), 4)
##           R2    SER     DW    AIC    SIC
## AR(1) 0.9524 1.6424 1.0615 1.0078 1.0524
## AR(2) 0.9634 1.4467 2.0670 0.7617 0.8285
## AR(3) 0.9636 1.4487 2.0017 0.7721 0.8613
## AR(4) 0.9636 1.4542 2.0011 0.7872 0.8987

Both AIC and SIC pick the AR(2), in agreement with the correlogram. The third and fourth lags lower the sum of squares by almost nothing and pay a penalty for it.

The AR(2) model

ar2 <- ar[["AR(2)"]]
round(summary(ar2)$coefficients, 4)
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   3.8108     1.7281  2.2051   0.0293
## L1            1.4388     0.0785 18.3319   0.0000
## L2           -0.4765     0.0779 -6.1160   0.0000
c(mean = unname(coef(ar2)[1] / (1 - sum(coef(ar2)[-1]))),        # c / (1 - phi_1 - phi_2)
  inverse_roots = Mod(1 / polyroot(c(1, -coef(ar2)[-1]))))
##           mean inverse_roots1 inverse_roots2 
##    101.2412730      0.9221189      0.5166914
  • Both lags are highly significant: \hat\phi_1 = 1.44, \hat\phi_2 = -0.48. The implied mean \hat c/(1 - \hat\phi_1 - \hat\phi_2) = 101.24 is close to the sample mean of 101.02.
  • The inverse roots are real, 0.92 and 0.52, inside the unit circle: stationary, no oscillation, and the root at 0.92 is the source of the persistence.
  • R^2 = 0.96, SER = 1.45, DW = 2.07.

Actual, fitted and residuals

Diebold’s Figure 6.17b. The residuals look like white noise: no runs, no drift, one large positive shock in 1987.

Residual correlogram

Is what is left over white noise? Two parameters were estimated, so the Q statistics are compared with \chi^2_{m-2} and there is no p-value until m > 2.

correlogram(residuals(ar2), m = 12, dof = 2)
##    lag    acf   pacf    Q      p
## 1    1 -0.035 -0.035 0.16     NA
## 2    2  0.044  0.042 0.41     NA
## 3    3  0.011  0.014 0.43 0.5124
## 4    4  0.051  0.050 0.78 0.6775
## 5    5  0.002  0.004 0.78 0.8545
## 6    6  0.019  0.015 0.83 0.9348
## 7    7 -0.024 -0.024 0.90 0.9700
## 8    8  0.078  0.072 1.74 0.9421
## 9    9  0.080  0.087 2.62 0.9175
## 10  10  0.050  0.050 2.97 0.9361
## 11  11 -0.023 -0.027 3.05 0.9623
## 12  12 -0.129 -0.148 5.44 0.8600

Every autocorrelation is inside \pm 0.18 and every p-value is large. The AR(2) has extracted all the linear dynamics.

Residual correlogram, plotted

corr_plot(residuals(ar2), lag_max = 12)

The same in fable

AR() in fable fits the same OLS regression. It drops the first p observations of whatever data it is given, so hand it the two 1961Q3 to 1961Q4 quarters as well to reproduce the estimates above exactly.

fit <- emp |> filter(Quarter >= yearquarter("1961 Q3"), Quarter <= yearquarter("1993 Q4")) |>
  model(ar2 = AR(Employment ~ order(2)))
tidy(fit)
## # A tibble: 3 × 6
##   .model term     estimate std.error statistic  p.value
##   <chr>  <chr>       <dbl>     <dbl>     <dbl>    <dbl>
## 1 ar2    constant    3.81     1.71        2.23 2.74e- 2
## 2 ar2    ar1         1.44     0.0776     18.6  5.80e-38
## 3 ar2    ar2        -0.476    0.0770     -6.19 7.70e- 9

order(1:4) with ic = "bic" (or "aic") performs the selection of the previous slides:

emp |> filter(Quarter >= yearquarter("1961 Q3"), Quarter <= yearquarter("1993 Q4")) |>
  model(AR(Employment ~ order(1:4), ic = "bic"))
## # A mable: 1 x 1
##   `AR(Employment ~ order(1:4), ic = "bic")`
##                                     <model>
## 1                           <AR(2) w/ mean>

Forecasting with autoregressions: Wold’s chain rule


The FRV problem, revisited

Recall four ways out of the forecasting-the-right-hand-side-variables problem. Deterministic regressors were the fourth. The third was lagged regressors:

y_t = \beta_1 + \beta_2\, x_{t-1} + \varepsilon_t \tag{2}

is immediately usable one step ahead, because the regressor for y_{T+1} is x_T, already observed. More lags are fine; the key is that everything on the right is lagged at least one period.

For h steps ahead, model (2) seems to bring the problem back: we would need x_{T+h-1}, so everything on the right would have to be lagged by h periods, not one.

For autoregressions the problem dissolves. A model with y_t on y_{t-1} can be turned into a model with y_t on y_{t-h}, mechanically, for any h. That is Wold’s chain rule.

Information sets, conditional expectations, linear projections

The time-T information set is the observed history, \Omega_T = \{y_T, y_{T-1}, y_{T-2}, \ldots\}, imagined for theory as extending into the infinite past.

Under quadratic loss the optimal forecast of y_{T+h} is the conditional mean E(y_{T+h} \mid \Omega_T). In general it need not be a linear function of the elements of \Omega_T.

Linear functions are tractable, so we work with the best linear approximation to the conditional mean, the linear projection P(y_{T+h} \mid \Omega_T): the “linear least squares forecast”. Often it is very close to the conditional mean, and in the Gaussian case the two coincide exactly:

E(y_{T+h} \mid \Omega_T) = P(y_{T+h} \mid \Omega_T).

Notation for what follows: y_{T+h,T} is the h-step-ahead forecast made at T, what Lecture 4 wrote as \hat y_{T+h \mid T}.

Wold’s chain rule for the AR(1)

Take y_t = \phi\, y_{t-1} + \varepsilon_t and build the forecasts one horizon at a time.

One step. Write the process at T+1 and project the right-hand side on \Omega_T:

y_{T+1} = \phi\, y_T + \varepsilon_{T+1} \quad\Longrightarrow\quad y_{T+1,T} = \phi\, y_T .

The future shock is replaced by its projection, 0; y_T is known.

Two steps. Write the process at T+2 and project on \Omega_T:

y_{T+2} = \phi\, y_{T+1} + \varepsilon_{T+2} \quad\Longrightarrow\quad y_{T+2,T} = \phi\, y_{T+1,T} = \phi^2 y_T .

The unknown y_{T+1} is replaced by the forecast we have just constructed.

Three steps likewise gives y_{T+3,T} = \phi\, y_{T+2,T} = \phi^3 y_T, and in general

y_{T+h,T} = \phi^h\, y_T \;\longrightarrow\; 0 \quad \text{as } h \to \infty .

The forecast reverts geometrically to the unconditional mean. With an intercept, y_{T+h,T} = c + \phi\, y_{T+h-1,T} \to \mu = c/(1-\phi).

The chain rule for the AR(p)

The same recursion works for any order: write the process at T+h, replace future shocks by 0 and future y’s by their already-computed forecasts,

y_{T+h,T} = c + \phi_1\, y_{T+h-1,T} + \cdots + \phi_p\, y_{T+h-p,T}, \qquad y_{s,T} = y_s \text{ for } s \leq T .

Only the p most recent observations are ever needed, at any horizon. The FRV problem is solved for autoregressions, as it was for cross sections, trends and seasonals.

In truth the parameters are unknown, so we insert the OLS estimates to obtain operational forecasts. The recursion is six lines of R:

# coef = c(c, phi_1, ..., phi_p); y_last = the last p observations, oldest first
chain_rule <- function(coef, y_last, h) {
  p <- length(coef) - 1; path <- y_last; f <- numeric(h)
  for (i in 1:h) {
    f[i] <- coef[1] + sum(coef[-1] * rev(tail(path, p)))   # phi_1 * most recent, phi_2 * the one before, ...
    path <- c(path, f[i])                                  # the forecast joins the history
  }
  f
}

Forecast errors and their variances

The chain rule delivers point forecasts. For interval and density forecasts we need the h-step forecast error variance \sigma_h^2 = \operatorname{var}(y_{T+h} \mid \Omega_T). For the AR(1):

Errors. Subtract the forecast from the outcome and use the moving-average representation:

e_{T+1,T} = \varepsilon_{T+1}, \qquad e_{T+2,T} = \varepsilon_{T+2} + \phi\, \varepsilon_{T+1}, \qquad e_{T+h,T} = \varepsilon_{T+h} + \phi\, \varepsilon_{T+h-1} + \cdots + \phi^{h-1} \varepsilon_{T+1} .

Variances. The shocks are uncorrelated, so

\sigma_1^2 = \sigma^2, \qquad \sigma_2^2 = \sigma^2(1 + \phi^2), \qquad \sigma_h^2 = \sigma^2 \sum_{i=0}^{h-1} \phi^{2i} \;\longrightarrow\; \frac{\sigma^2}{1 - \phi^2} \quad \text{as } h \to \infty .

The limit is the unconditional variance of the process: conditioning information loses its value as the horizon grows, until the forecast is no better than the unconditional mean.

Under normality, y_{T+h} \mid \Omega_T \sim N(y_{T+h,T}, \sigma_h^2) is the density forecast, and y_{T+h,T} \pm 1.96\, \sigma_h the 95% interval.

Higher orders: the moving-average weights

For an AR(p) the error is again a weighted sum of the future shocks, e_{T+h,T} = \sum_{i=0}^{h-1} \psi_i\, \varepsilon_{T+h-i}, where the \psi_i are the coefficients of the process’s moving-average representation y_t = \mu + \sum_i \psi_i \varepsilon_{t-i}. They follow from the AR coefficients by the recursion

\psi_0 = 1, \qquad \psi_j = \sum_{i=1}^{\min(j, p)} \phi_i\, \psi_{j-i}, \qquad \sigma_h^2 = \sigma^2 \sum_{i=0}^{h-1} \psi_i^2 .

For p = 1 this gives \psi_i = \phi^i, as before.

psi_weights <- function(phi, h) {
  psi <- c(1, numeric(h - 1)); p <- length(phi)
  if (h > 1) for (j in 2:h) for (i in 1:min(j - 1, p)) psi[j] <- psi[j] + phi[i] * psi[j - i]
  psi
}

Two things the formula ignores. Parameter estimation error, which can make \sigma_h^2 grow without bound rather than converge. And non-normality, which simulation handles without any variance calculation.

Application: Canadian employment III


Four quarters ahead

The best autoregression was the AR(2). Its last two observations are 1993Q3 and 1993Q4; feed them to the chain rule and scale the \psi weights by the SER.

b <- coef(ar2); s <- sigma(ar2)
fc4 <- chain_rule(b, tail(est$Employment, 2), h = 4)
se4 <- s * sqrt(cumsum(psi_weights(b[-1], 4)^2))
f4 <- data.frame(Quarter = yearquarter("1994 Q1") + 0:3, point = fc4, se = se4,
                 lower = fc4 - 1.96 * se4, upper = fc4 + 1.96 * se4)
round(f4[, -1], 2)
##   point   se lower upper
## 1 88.83 1.45 85.99 91.66
## 2 89.52 2.53 84.55 94.49
## 3 90.29 3.43 83.57 97.00
## 4 91.07 4.14 82.95 99.18

The point forecast climbs slowly from the last observation (88.4) toward the mean (101.2) and is still far below it after four quarters. The standard error grows from the SER to nearly three times the SER, and the bands are nowhere near their long-run width. Both reflect the persistence the AR(2) captured.

History and forecast

Diebold’s Figure 6.20. History 1990Q1 to 1993Q4, then the four-quarter forecast (blue) with its 95% interval.

Forecast and realization

real <- emp |> filter(year(Quarter) == 1994) |> as_tibble() |> transmute(t = dec_q(Quarter), y = Employment)
fc_plot(recent, f4, actual = real, ylab = "employment")

mean((real$y - f4$point)^2)                              # mean squared forecast error
## [1] 1.279815

The forecast tracks the recovery well: the realization (red) sits close to the point forecast and well inside the band, with a mean squared error of 1.3, less than the SER squared.

Diebold’s Figure 6.21.

Longer horizons

Eventually the forecast reaches the unconditional mean (dotted) and the bands go flat at \pm 1.96 \times 7.3, the standard deviation the model implies (the sample standard deviation is 7.5). But only after many years: high persistence means a long memory.

Diebold’s Figures 6.22 and 6.23.

The same in fable

fit |> forecast(h = 4) |> hilo(95) |> select(Quarter, .mean, `95%`)
## # A tsibble: 4 x 3 [1Q]
##   Quarter .mean                  `95%`
##     <qtr> <dbl>                 <hilo>
## 1 1994 Q1  88.8 [86.02621, 91.63018]95
## 2 1994 Q2  89.5 [84.60804, 94.42726]95
## 3 1994 Q3  90.3 [83.65073, 96.92412]95
## 4 1994 Q4  91.1 [83.04561, 99.08737]95
fit |> forecast(h = 12) |> autoplot(emp |> filter(year(Quarter) >= 1990), level = 95) +
  labs(x = NULL, y = "employment")

fable estimates \sigma^2 by SSR/T rather than SSR/(T-k), so its intervals are about one percent narrower.

What to take away

  1. Covariance stationarity (constant mean, autocovariances that depend only on the displacement, finite variance) is what makes one realization informative about the process. Model the trend and seasonal first, or transform; then treat the cycle as stationary.
  2. White noise has no dynamics. It is the building block of every process (Wold) and the target for every model’s residuals.
  3. The correlogram (sample ACF, PACF, Q statistics with \pm 2/\sqrt{T} bands) is model-free evidence about dynamics. Gradual ACF decay with a PACF cutoff at p points to an AR(p); AIC and SIC settle the order.
  4. An AR(p) is OLS on p lags. It is stationary when the roots of \Phi(L) lie outside the unit circle; for the AR(1), \rho(\tau) = \phi^\tau.
  5. Wold’s chain rule produces forecasts at any horizon by recursion. They revert to the mean, and the forecast-error variance rises from \sigma^2 to the unconditional variance.

R cheat sheet

library(fpp3)
# ---- correlogram ----------------------------------------------------------------
acf(y, lag.max = 12); pacf(y, lag.max = 12)                    # base R (divide-by-T estimator)
Box.test(y, lag = 12, type = "Ljung-Box")                       # Q test; fitdf = k for residuals
correlogram(y, m = 12, dof = 0)                                 # table of acf, pacf, Q, p (defined in these slides)
tsb |> gg_tsdisplay(y, plot_type = "partial")                   # series + ACF + PACF, fpp3
tsb |> features(y, ljung_box, lag = 12, dof = 0)                # Ljung-Box, fpp3
# ---- autoregressions ------------------------------------------------------------
tsb <- tsb |> mutate(L1 = lag(y), L2 = lag(y, 2))               # build lags, then filter to the sample
lm(y ~ L1 + L2, data = tsb); fit_stats(fit)                     # OLS; R2, SER, DW, AIC, SIC
Mod(1 / polyroot(c(1, -coef(fit)[-1])))                         # inverse roots: < 1 means stationary
tsb |> model(AR(y ~ order(2)))                                  # fable; order(1:4), ic = "bic" to select
lmtest::bgtest(fit, order = 4)                                  # Breusch-Godfrey residual test
# ---- forecasts ------------------------------------------------------------------
chain_rule(coef(fit), tail(y, p), h)                            # point forecasts by Wold's chain rule
sigma(fit) * sqrt(cumsum(psi_weights(coef(fit)[-1], h)^2))     # h-step standard errors
model(tsb, AR(y ~ order(2))) |> forecast(h = 4) |> hilo(95)    # the same in fable
arima.sim(n = 200, list(ar = c(0.5, 0.3)))                     # simulate an AR process

References


Additional resources

  • Textbooks
    • Diebold, F.X. Forecasting in Economics, Business, Finance and Beyond, Chapter 6. The Canadian employment application and its code come from the book’s companion files.
    • Hyndman, R.J. and Athanasopoulos, G. Forecasting: Principles and Practice (3rd ed.), Sections 2.8, 2.9, 5.4 and 9.3.
    • Pesaran, M.H. (2015), Time Series and Panel Data Econometrics, Oxford University Press, Chapter 14, for stationarity, the Wold decomposition and the long-run variance.
  • Original sources
    • Wold, H. (1938), A Study in the Analysis of Stationary Time Series, Almqvist and Wiksell.
    • Box, G.E.P. and Pierce, D.A. (1970), “Distribution of Residual Autocorrelations in Autoregressive-Integrated Moving Average Time Series Models,” Journal of the American Statistical Association, 65, 1509–1526.
    • Ljung, G.M. and Box, G.E.P. (1978), “On a Measure of Lack of Fit in Time Series Models,” Biometrika, 65, 297–303.
    • Breusch, T.S. (1978), “Testing for Autocorrelation in Dynamic Linear Models,” Australian Economic Papers, 17, 334–355; Godfrey, L.G. (1978), Econometrica, 46, 1293–1301.
  • Data
    • data/caemp.csv: seasonally adjusted Canadian employment index, 1961Q1 to 1994Q4, from the companion files. data/GDPC1.csv: US real GDP from FRED, as in Lecture 6.