www.gusucode.com > econ 案例源码程序 matlab代码 > econ/TestfortheDegreeofIntegrationExample.m
%% Test for the Degree of Integration % Conduct paired integration and stationarity tests on two time series and % their differences. % Copyright 2015 The MathWorks, Inc. %% % Load the Nelson-Plosser data, and extract the series of real GNP, |GNPR|, % and consumer price index, |CPI|. load Data_NelsonPlosser X = DataTable(:,{'GNPR','CPI'}); %% % |X| is a tabular array containing the variables |GNPR| and |CPI|. %% % Set the integration and stationarity test parameters. I.names = {'lags','model'}; I.vals = {1,'TS'}; S.names = {'trend'}; S.vals = {true}; %% % The integration test is the default (|adftest|), augmented with one lagged % difference term and a trend-stationary alternative. The stationarity test % is the default (|kpsstest|) with a trend. %% % Conduct the integration and stationarity tests on the variables and their % first differences, specified using |numDiffs|. i10test(X,'numDiffs',1,'itest','adf','iparams',I,... 'stest','kpss','sparams',S) %% % The warnings indicate that the p-values are very large or small for some % of the tests (that is, they are outside the Monte Carlo simulated tables). % For each original series, a unit root is not rejected (|H = 0| for |I(1)|), % and stationarity is rejected (|H = 1| for |I(0)|). For the differenced % series, a unit root is rejected and stationarity is not rejected. %% % At the given parameter settings, the tests suggest that both series have % one degree of integration.