5.5 Selecting predictors
When there are many possible predictors, we need some strategy to select the best predictors to use in a regression model.
A common approach that is not recommended is to plot the forecast variable against a particular predictor and if it shows no noticeable relationship, drop it. This is invalid because it is not always possible to see the relationship from a scatterplot, especially when the effects of other predictors have not been accounted for.
Another common approach which is also invalid is to do a multiple linear regression on all the predictors and disregard all variables whose \(p\)-values are greater than 0.05. To start with, statistical significance does not always indicate predictive value. Even if forecasting is not the goal, this is not a good strategy because the \(p\)-values can be misleading when two or more predictors are correlated with each other (see Section 5.9).
Instead, we will use a measure of predictive accuracy. Five such measures are introduced in this section.
Adjusted R\(^2\)
Computer output for regression will always give the \(R^2\) value, discussed in Section 5.1. However, it is not a good measure of the predictive ability of a model. Imagine a model which produces forecasts that are exactly 20% of the actual values. In that case, the \(R^2\) value would be 1 (indicating perfect correlation), but the forecasts are not be very close to the actual values.
In addition, \(R^2\) does not allow for “degrees of freedom”. Adding any variable tends to increase the value of \(R^2\), even if that variable is irrelevant. For these reasons, forecasters should not use \(R^2\) to determine whether a model will give good predictions.
An equivalent idea is to select the model which gives the minimum sum of squared errors (SSE), given by \[\text{SSE} = \sum_{t=1}^T e_{t}^2.\]
Minimizing the SSE is equivalent to maximizing \(R^2\) and will always choose the model with the most variables, and so is not a valid way of selecting predictors.
An alternative, designed to overcome these problems, is the adjusted \(R^2\) (also called “R-bar-squared”): \[\bar{R}^2 = 1-(1-R^2)\frac{T-1}{T-k-1},\] where \(T\) is the number of observations and \(k\) is the number of predictors. This is an improvement on \(R^2\) as it will no longer increase with each added predictor. Using this measure, the best model will be the one with the largest value of \(\bar{R}^2\). Maximizing \(\bar{R}^2\) is equivalent to minimizing the standard error \(\hat{\sigma}_e\) given \tag{5.3}ref(#eq:Regr-se).
Maximizing \(\bar{R}^2\) works quite well as a method of selecting predictors, although it does tend to err on the side of selecting too many predictors.
Cross-validation
Section 3.4 introduced time series cross-validation as a general and useful tool for determining the predictive ability of a model. For regression models, it is also possible to use classical leave-one-out cross-validation to selection predictors (Bergmeir, Hyndman, and Koo 2018). This is faster and makes more efficient use of the data. The procedure uses the following steps:
- Remove observation \(t\) from the data set, and fit the model using the remaining data. Then compute the error (\(e_{t}^*=y_{t}-\hat{y}_{t}\)) for the omitted observation. (This is not the same as the residual because the \(t\)th observation was not used in estimating the value of \(\hat{y}_{t}\).)
- Repeat step 1 for \(t=1,\dots,T\).
- Compute the MSE from \(e_{1}^*,\dots,e_{T}^*\). We shall call this the CV.
Although this looks this looks like a time-consuming procedure there are very fast methods of calculating CV, so that it takes no longer than fitting one model to the full data set. The equation for computing CV efficiently is given in Section 5.7.
Under this criterion, the best model is the one with the smallest value of CV.
CV(fit.consMR)
#> CV AIC AICc BIC AdjR2
#> 0.116 -409.298 -408.831 -389.911 0.749
Akaike’s Information Criterion
A closely-related method is Akaike’s Information Criterion, which we define as \[\text{AIC} = T\log\left(\frac{\text{SSE}}{T}\right) + 2(k+2),\] where \(T\) is the number of observations used for estimation and \(k\) is the number of predictors in the model. Different computer packages use slightly different definitions for the AIC, although they should all lead to the same model being selected. The \(k+2\) part of the equation occurs because there are \(k+2\) parameters in the model: the \(k\) coefficients for the predictors, the intercept and the variance of the residuals. The idea here is to penalize the fit of the model (SSE) with the number of parameters that need to be estimated.
The model with the minimum value of the AIC is often the best model for forecasting. For large values of \(T\), minimizing the AIC is equivalent to minimizing the CV value.
Corrected Akaike’s Information Criterion
For small values of \(T\), the AIC tends to select too many predictors, and so a bias-corrected version of the AIC has been developed, \[ \text{AIC}_{\text{c}} = \text{AIC} + \frac{2(k+2)(k+3)}{T-k-3}. \] As with the AIC, the AICc should be minimized.
Schwarz Bayesian Information Criterion
A related measure is Schwarz’s Bayesian Information Criterion (known as SBIC, BIC or SC), \[ \text{BIC} = T\log\left(\frac{\text{SSE}}{T}\right) + (k+2)\log(T). \] As with the AIC, minimizing the BIC is intended to give the best model. The model chosen by BIC is either the same as that chosen by AIC, or one with fewer terms. This is because the BIC penalizes the number of parameters more heavily than the AIC. For large values of \(T\), minimizing BIC is similar to leave-\(v\)-out cross-validation when \(v = T[1-1/(\log(T)-1)]\).
Many statisticians like to use BIC because it has the feature that if there is a true underlying model, then with enough data the BIC will select that model. However, in reality there is rarely if ever a true underlying model, and even if there was a true underlying model, selecting that model will not necessarily give the best forecasts (because the parameter estimates may not be accurate). Consequently, we prefer to use the AICc, AIC, or CV statistics, which have forecasting as their objective (and which give equivalent models for large \(T\)).
Example: US consumption
To obtain all these measures in R, use CV(fit)
. In the multiple regression example for forecasting US consumption we considered four predictors. With four predictors, there are \(2^4=16\) possible models. Now we can check if all four predictors are actually useful, or whether we can drop one or more of them. All 16 models were fitted and the results are summarised below in Table 5.1. A “1” indicates that the predictor was included in the model, and a “0” means that the predictor was not included in the model. Hence the first row shows the measures of predictive accuracy for a model including all four predictors.
The results have been sorted according to the AICc and therefore the best models are given at the top of the table, and the worst at the bottom of the table.
Income | Production | Savings | Unemployment | CV | AIC | AICc | BIC | AdjR2 |
---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 0.116 | -409 | -409 | -390 | 0.749 |
1 | 0 | 1 | 1 | 0.116 | -408 | -408 | -392 | 0.746 |
1 | 1 | 1 | 0 | 0.118 | -407 | -407 | -391 | 0.745 |
1 | 0 | 1 | 0 | 0.129 | -389 | -389 | -376 | 0.716 |
1 | 1 | 0 | 1 | 0.278 | -243 | -243 | -227 | 0.386 |
1 | 0 | 0 | 1 | 0.283 | -238 | -238 | -225 | 0.365 |
1 | 1 | 0 | 0 | 0.289 | -236 | -236 | -223 | 0.359 |
0 | 1 | 1 | 1 | 0.293 | -234 | -234 | -218 | 0.356 |
0 | 1 | 1 | 0 | 0.300 | -229 | -229 | -216 | 0.334 |
0 | 1 | 0 | 1 | 0.303 | -226 | -226 | -213 | 0.324 |
0 | 0 | 1 | 1 | 0.306 | -225 | -224 | -212 | 0.318 |
0 | 1 | 0 | 0 | 0.314 | -220 | -219 | -210 | 0.296 |
0 | 0 | 0 | 1 | 0.314 | -218 | -218 | -208 | 0.288 |
1 | 0 | 0 | 0 | 0.372 | -185 | -185 | -176 | 0.154 |
0 | 0 | 1 | 0 | 0.414 | -164 | -164 | -154 | 0.052 |
0 | 0 | 0 | 0 | 0.432 | -155 | -155 | -149 | 0.000 |
The best model contains all four predictors. However, a closer look at the results reveals some interesting features. There is clear separation between the models in the first four rows and the ones below. This indicates that Income and Savings are both more important variables than Production and Unemployment. Also, the first two rows have almost identical values of CV, AIC and AICc. So we could possibly drop the Production variable and get very similar forecasts. Note that Production and Unemployment are highly (negatively) correlated, as shown in Figure 5.5, so most of the predictive information in Production is also contained in the Unemployment variable.
Best subset regression
Where possible, all potential regression models should be fitted (as was done in the above example) and the best model should be selected based on one of the measures discussed. This is known as “best subsets” regression or “all possible subsets” regression.
It is recommended that one of CV, AIC or AICc be used for this purpose. If the value of \(T\) is large enough, they will all lead to the same model.
While \(\bar{R}^2\) is very widely used, and has been around longer than the other measures, its tendency to select too many predictor variables makes it less suitable for forecasting than either CV, AIC or AICc. Also, the tendency of BIC to select too few variables makes it less suitable for forecasting than either CV, AIC or AICc.
Stepwise regression
If there are a large number of predictors, it is not possible to fit all possible models. For example, 40 predictors leads to \(2^{40} >\) 1 trillion possible models! Consequently, a strategy is required to limit the number of models to be explored.
An approach that works quite well is backwards stepwise regression:
- Start with the model containing all potential predictors.
- Remove one predictor at a time. Keep the model if it improves the measure of predictive accuracy.
- Iterate until no further improvement.
If the number of potential predictors is too large, then the backwards stepwise regression will not work and forward stepwise regression can be used instead. This procedure starts with a model that includes only the intercept. Predictors are added one at a time, and the one that most improves the measure of predictive accuracy is retained in the model. The procedure is repeated until no further improvement can be achieved.
Alternatively for either the backward or forward direction, a starting model can be one that includes a subset of potential predictors. In this case, an extra step needs to be included. For the backwards procedure we should also consider adding a predictor with each step, and for the forward procedure we should also consider dropping a predictor with each step. These are referred to as hybrid procedures.
It is important to realise that any stepwise approach is not guaranteed to lead to the best possible model, but it almost always leads to a good model. For further details see James et al. (2014).
Beware of inference after selecting predictors
We do not discuss statistical inference of the predictors in this book (e.g., looking at \(p\)-values associated with each predictor). If you do wish to look at the statistical significance of the predictors, beware that any procedure involving selecting predictors first will invalidate the assumptions behind the \(p\)-values. The procedures we recommend for selecting predictors are helpful when the model is used for forecasting; they are not helpful if you wish to study the effect of any predictor on the forecast variable.
References
Bergmeir, Christoph, Rob J Hyndman, and Bonsoo Koo. 2018. “A Note on the Validity of Cross-Validation for Evaluating Autoregressive Time Series Prediction.” Computational Statistics & Data Analysis 120: 70–83. robjhyndman.com/publications/cv-time-series/.
James, Gareth, Daniela Witten, Trevor Hastie, and Robert Tibshirani. 2014. An Introduction to Statistical Learning: With Applications in R. New York: Springer.