Choosing the Lag Order
Today let's work out how far back a VAR should look, that is, how many past quarters each of its equations should use.
Take a labour-market analyst who wants to model four Canadian series together. They are employment (e), labour productivity (prod), the real wage (rw) and the unemployment rate (U, in percent), measured every quarter from 1980Q1 to 2000Q4. That is 84 quarters of OECD data, and it ships with the vars package as the data set Canada.
A vector autoregression, or VAR, gives each of the four series its own equation, and each equation predicts that series from the past values of all four. The number of past quarters an equation looks back over is called the lag order, written p. The analyst has to pick p before the VAR can be fitted.
The chart plots the unemployment rate for all 84 quarters, one point per quarter. It is one of the four series the VAR has to look back over.
What the lag order p sets in a VAR
Let's start by loading the data and looking at its first three quarters.
Each row is one quarter and each column is one series. The series e, prod and rw are stored as 100 times the natural log of the original level, which is why they sit in the hundreds. U is the unemployment rate in percent.
Now let's write down the VAR itself. With p = 2, the equation for U uses the two most recent quarters of all four series, plus a constant and a linear trend. The trend is there because the levels of these series climb and fall over the years.
Here is that equation written out.
\[ U_t = c + \delta\, t + a_1 e_{t-1} + a_2 \mathrm{prod}_{t-1} + a_3 \mathrm{rw}_{t-1} + a_4 U_{t-1} + b_1 e_{t-2} + b_2 \mathrm{prod}_{t-2} + b_3 \mathrm{rw}_{t-2} + b_4 U_{t-2} + \varepsilon_t \]
The constant is c, and \(\delta\) multiplies the time index t. The a's multiply the four series one quarter back, the b's multiply them two quarters back, and \(\varepsilon_t\) is the error.
So this one equation has 10 coefficients. In general, an equation of a VAR(p) has 4p + 2 of them: four series times p lags, plus the constant and the trend. The system has four equations, so 4(4p + 2) coefficients in all.
Let's count them for a few orders, by fitting the VAR and counting the coefficients of the U equation.
type = "both" adds the constant and the trend. coef(fit$varresult$U) returns the coefficients of the U equation, and length() counts them. At p = 2 that count is 10, the same as the equation above.
Each extra lag adds 4 coefficients to every equation, so 16 to the system. Going from p = 1 to p = 8 takes the system from 24 coefficients to 136, all estimated from the same 84 quarters.
The analyst sets p before fitting. The data do not estimate it. A p that is too small leaves useful information from the past out of the equations, and a p that is too large spends coefficients on noise.