www.gusucode.com > econ 案例源码程序 matlab代码 > econ/ConductanAugmentedDickeyFullerTestAgainstaTrendStationarExample.m

    %% Conduct an Augmented Dickey-Fuller Test Against a Trend-Stationary Alternative  
% Test a time series for a unit root against a trend-stationary alternative
% augmented with lagged difference terms.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Load a time series of GDP data, and calculate its log. 
load Data_GDP;
Y = log(Data);

%% 
% Test for a unit root against a trend-stationary alternative, augmenting
% the model with 0, 1, and 2 lagged difference terms. 
h = adftest(Y,'model','TS','lags',0:2) 

%%
% |adftest| treats the three lag choices as three separate tests, and returns
% a vector with rejection decisions for each test. The values |h = 0| indicate
% that all three tests fail to reject the null hypothesis of a unit root
% against the trend-stationary alternative.