varLagSelect#
Purpose#
Select VAR lag order by information criteria.
Format#
- ls = varLagSelect(y, max_p)#
- ls = varLagSelect(y, max_p, ic="bic")
- Parameters:
y (TxM matrix or dataframe) – endogenous variables.
max_p (scalar) – maximum lag order to test.
ic (string) – Optional keyword, selection criterion.
"aic"(default),"bic", or"hq".xreg (TxK matrix) – Optional keyword, exogenous regressors.
include_const (scalar) – Optional keyword, 1 to include constant (default), 0 to exclude.
quiet (scalar) – Optional keyword, set to 1 to suppress the IC table. Default = 0.
- Returns:
ls (struct) –
An instance of a
lagSelectResultstructure containing:ls.best_p
Scalar, selected lag order (argmin of chosen criterion).
ls.criterion
String, criterion used for selection (
"aic","bic", or"hq").ls.ic_table
max_p x 3 matrix, information criterion values for each lag order. Columns: AIC, BIC, HQ.
ls.max_p
Scalar, maximum lag tested.
ls.ic_names
3x1 string array,
{"AIC", "BIC", "HQ"}.
Examples#
Basic Lag Selection#
new;
library timeseries;
data = loadd(getGAUSSHome("pkgs/timeseries/examples/macro.dat"));
// Test lags 1 through 8, select by AIC
ls = varLagSelect(data, 8);
================================================================================
VAR Lag Selection (M=3, T=200)
================================================================================
Lag AIC BIC HQ
----------------------------------------
1 -12.384 -11.927* -12.198*
2 -12.401* -11.689 -12.115
3 -12.378 -11.410 -11.993
4 -12.356 -11.133 -11.871
5 -12.331 -10.853 -11.746
6 -12.312 -10.578 -11.627
7 -12.289 -10.300 -11.504
8 -12.270 -10.026 -11.385
================================================================================
Selected: p=2 (AIC)
================================================================================
Pipe into Estimation#
new;
library timeseries;
data = loadd(getGAUSSHome("pkgs/timeseries/examples/macro.dat"));
// Select lag order, then estimate
ls = varLagSelect(data, 8, ic="bic", quiet=1);
result = varFit(data, ls.best_p);
Remarks#
The full IC table (ls.ic_table) reports all three criteria (AIC, BIC, HQ) regardless of which criterion was used for selection. This allows comparison when the criteria disagree — AIC tends to select more lags than BIC.
Model#
For each candidate lag order \(p = 1, \ldots, p_{\max}\), the VAR(p) is estimated by OLS and the information criteria are computed:
where \(K_p = mp + 1\) and \(T_p = T - p\) (sample shrinks with more lags).
The selected \(p^*\) minimizes the chosen criterion. AIC tends to select larger models; BIC tends to select smaller models (Lutkepohl 2005, Section 4.3).
Troubleshooting#
AIC and BIC disagree: This is common. AIC optimizes forecast accuracy; BIC optimizes model consistency (converges to the true order as T → ∞). For forecasting, prefer AIC. For structural analysis, prefer BIC. When in doubt, report both.
References#
Lutkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer. Section 4.3.
Library#
timeseries
Source#
var.src
See also
Functions varFit(), bvarFit(), bvarHyperopt()