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

    %% Assess Trend Stationarity of a Series
% Reproduce the first row of the second half of Table 5 in Kwiatkowski et
% al., 1992.
%%
% Load the Nelson-Plosser Macroeconomic series data set.

% Copyright 2015 The MathWorks, Inc.

load Data_NelsonPlosser
%%
% Linearize the real gross national product series (RGNP).
logGNPR = log(DataTable.GNPR);
%%
% Assess the null hypothesis that the series is trend stationary over
% a range of lags.
lags = (0:8)';
[~,pValue,stats] = kpsstest(logGNPR,'Lags',lags,'Trend',true);
results = [lags pValue stats]
%%
% Warnings appear because the tests using 0 $\le$ |lags| $\le$ 2
% produce p-values that are less than 0.01.  For |lags| $<$ 7, the tests
% indicate sufficient evidence to suggest that log rGNP is unit root
% nonstationary (i.e., not trend stationary) at the default 5% level.