Test a time series for a unit root against
trend-stationary alternatives augmented with different numbers of
lagged difference terms. Look at the regression statistics corresponding
to each of the alternative models to choose how many lagged difference
terms to include in the augmented model.

Load a time series of GDP data, and calculate its log.

load Data_GDP;
Y = log(Data);

Test for a unit root using three different choices for
the number of lagged difference terms. Return the regression statistics
for each alternative model.

[h,~,~,~,reg] = adftest(Y,'model','TS','lags',0:2);

`adftest` treats each of the three lag choices
as separate tests, and returns results for each test. `reg` is
an array of three data structures, corresponding to each alternative
model.

Display the names of the coefficients included in each
of the three alternatives.

reg.names

ans =
'c'
'd'
'a'
ans =
'c'
'd'
'a'
'b1'
ans =
'c'
'd'
'a'
'b1'
'b2'

The output shows which terms are included in the three alternative
models. The first model has no added difference terms, the second
model has one difference term (`b1`), and the third
model has two difference terms (`b1` and `b2`).

Display the *t*-statistics and corresponding
p-values for each coefficient in the three alternative models.

[reg(1).tStats.t reg(1).tStats.pVal]
[reg(2).tStats.t reg(2).tStats.pVal]
[reg(3).tStats.t reg(3).tStats.pVal]

ans =
2.0533 0.0412
1.8842 0.0608
61.4717 0.0000
ans =
2.9026 0.0041
2.7681 0.0061
64.1396 0.0000
5.6514 0.0000
ans =
3.2568 0.0013
3.1249 0.0020
62.7825 0.0000
4.7586 0.0000
1.7615 0.0795

The returned *t*-statistics and p-values correspond
to the coefficients in `reg.names`. These results
indicate that the coefficient on the first difference term is significantly
different from zero in both the second and third models, but the coefficient
on the second term in the third model is not. This suggests augmenting
the model with one lagged difference term is adequate.

Compare the BIC for each of the three alternatives.

reg.BIC

ans =
-1.4774e+03
ans =
-1.4966e+03
ans =
-1.4878e+03

Based on the BIC values, choose the model augmented with one
lagged difference term because it has the best (that is, the smallest)
BIC value.