BookmarkSubscribeRSS Feed
Obsidian | Level 7


Hi community,

based on the following paper, I wanted to apply these tests to my series. Is the procedure for calculating the ideal number of lags correct? How do I define the maximum number on which to complete the cycle?

data tstats;
set _null_;
%macro np(indata, testvar);
%do i=1 %to &&nmax;
%if (&i<2) %then %do;
ods output ParameterEstimates=parms_&i.a;
proc reg
data = &indata;
model d1&testvar= lag1&testvar lag&i.d1&testvar;
%if (&i>1) %then %do;
ods output ParameterEstimates=parms_&i.a;
proc reg
data = &indata;
model d1&testvar = lag1&testvar lag1d1&testvar --
data parms_&i (keep=tvalue lag);
set parms_&i.a (where=(variable="lag&i.d1&testvar"));
data tstats;
set tstats parms_&i;
if abs(tvalue)>1.6 then flag=1;
proc sort data=tstats;
by descending lag;

Additionally, which metric should I use because the single mean and the trend give me two different pieces of information with the KPSS test. The single mean tells me that the series is stationary, while the trend does not reject the null hypothesis H0, so it is non-stationary.


proc autoreg
	data = data;
	model y = /stationarity=(kpss=(kernel=qs auto));



SAS Employee

Hello @harmonic 

It seems to me that the logic in the description of the testing procedure in your referenced paper is along the lines of the general-to-specific procedure of sequential tests for significance of coefficients on the lags discussed in Ng and Perron (1995):

Unit Root Tests in ARIMA Models with Data-Dependent Methods for the Selection of the Truncation Lag, Journal of the American Statistical Association , Mar., 1995, Vol. 90, No. 429 (Mar., 1995), pp. 268-281


There may be some specific choices you can make for yourself using this type of tests, for example, choosing the test as well as choosing the significance level to determine the significance of the lags coefficients, choosing the maximum number of lags to start the sequential testing process, etc.. I am not familiar with the literature in this area to make specific suggestions or point to a specific reference. You may want to do some research in the literature to help you make the decision. The Ng and Perron(1995) paper did mention a few references that used this type of sequential tests, you may want to look into those references.


Alternative to the sequential testing procedures, information based tests have also been proposed and used in the literature.  For example, Elliott, Rothenberg, and Stock (1996), suggest using the Schwarz Bayesian information criterion to select the optimal lag length in the augmented Dickey-Fuller regression; Ng and Perron(2001) suggest using modified AIC to select optimal lag length in the ADF regression. PROC AUTOREG provides the ERS stationarity test which selects the lag length using SBC and NP stationarity test which selects the lag length using modified AIC. You can specify ERS  option, NP  option in the MODEL statement in PROC AUTOREG to requests these tests:


then scroll down to:




where 'value' is the maximum lag length to be considered in the lag order selection in the stationarity test.


Regarding conflicting results between the single mean model and trend model, in general, you choose the appropriate model for the data before performing the stationarity test. Inappropriate model choice can lead to misleading results. The choice between single mean and trend model depends on your data. For example, if data clearly shows deterministic trend, then the trend model is commonly used. You may want to examine your data and make the decision accordingly.


I hope this helps.





Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2 in conversation