32
$\begingroup$

I am using R, I searched on Google and learnt that kpss.test(), PP.test(), and adf.test() are used to know about stationarity of time series.

But I am not a statistician, who can interpret their results

> PP.test(x)

     Phillips-Perron Unit Root Test
data:  x 
Dickey-Fuller = -30.649, Truncation lag parameter = 7, p-value = 0.01

> kpss.test(b$V1)

  KPSS Test for Level Stationarity
  data:  b$V1 
  KPSS Level = 0.0333, Truncation lag parameter = 3, p-value = 0.1

Warning message:
In kpss.test(b$V1) : p-value greater than printed p-value
> adf.test(x)

    Augmented Dickey-Fuller Test

data:  x 
Dickey-Fuller = -9.6825, Lag order = 9, p-value = 0.01
alternative hypothesis: stationary

Warning message:
In adf.test(x) : p-value smaller than printed p-value

I am dealing with thousands of time series, kindly me tell how to check quantitatively about stationarity of time series.

$\endgroup$

3 Answers 3

25
$\begingroup$

Testing if a series is stationary versus non-stationary requires that you consider a sequence of alternative hypotheses, one for each listable Gaussian Assumption. One has to understand that the Gaussian Assumptions are all about the error process and have nothing to do with the observed series under evaluation. As correctly summarized by StasK this could include violations of stationarity, like mean change, variance change, changes in the parameters of the model over time.

For example an upward trending set of values would be a prima facie example of a series that in Y was not constant while the residuals from a suitable model might be described as having a constant mean. Thus the original series is non-stationary in the mean but the residual series is stationary in its mean. If there are unmitigated mean violations in the residual series like Pulses, Level Shifts, Seasonal Pulses and/or Local Time Trends then the residual series (untreated) can be characterized as being non-stationary in the mean while a series of indicator variables could be easily detected and incorporated into the model to render the model residuals stationary in the mean.

Now if the variance of the original series exhibits non-stationary variance it is quite reasonable to construct a filter/model to render an error process that has constant variance. Similarly the residuals from a model might have non-constant variance requiring one of three possible remedies -

  1. Weighted Least Squares (broadly overlooked by some analysts)
  2. A power transformation to decouple the expected value from the variance of the errors identifiable via a Box-Cox test and/or
  3. A need for a GARCH model to account for an ARIMA structure evident in the squared residuals. Continuing if parameters change over time OR the form of the model changes over time then one is faced with the need for detecting this characteristic and remedying it with either data segmentation or the utilization of a TAR approach à la Tong.
$\endgroup$
36
$\begingroup$

Stationarity means that the marginal distribution of the process does not change with time. A weaker forms states that the mean and the variance stay the same over time. So anything that violates it will be deemed non-stationary, for whatever silly reasons. For instance, a deterministic $y_t = \sin t$ is non-stationary, as its mean keeps changing, although at the face of it, this is a pretty simple and predictable process.

All the tests you are considering have a specific alternative in mind: a random walk process $$ y_t = y_{t-1} + \epsilon_t $$ or some easy modification of it (e.g., include additional lags $y_{t-2}$, $y_{t-3}$ with small coefficients). This is a simple model of an efficient financial market, where no information whatsoever can be used to predict the future changes in prices. Most economists think about their time series as coming from ARIMA models; these time series have well defined periods when stuff happens (month, quarter, or year), so it rarely gets worse than an integrated time series for them. So these tests are not designed for more complex violations of stationarity, like mean change, variance change, change in the autoregressive coefficients, etc., although tests for these effects have obviously been developed, too.

In engineering or natural sciences, you are more likely to encounter time series with more complicated issues, like long range dependence, fractional integration, pink noise, etc. With the lack of clear guidance from the description of the process regarding the typical time scales (how often does the climate change?), it usually makes more sense to analyze the data in the frequency domain (while for economists, the frequency domain is quite clear: there are annual seasonal cycles, plus longer 3-4-5 year business cycles; few surprises can occur otherwise).

So basically I told you why you don't want to do what you set out to do. If you don't understand time series, you would be better off finding somebody who does and paying consultancy fee, rather than having your project screwed up because you've done something silly. Having said that, the formal solution to your problem would be to reject the null hypothesis of a stationary series when, for a given series, at least one test has a $p$-value below $0.05/(3M)$ where $M$ is the total number of series, $3$ is the number of tests you perform on them, $0.05$ is the favorite 5% significance level, and the whole expression is known as Bonferroni correction for multiple testing. The output does not show the $p$-values with sufficient accuracy, so you would need to pull them as the returned class members, such as pp.test(x)$p.value. You'll be doing this in cycle, anyway, so it would probably suffice if you suppress all of the output, and only produce the name(s) of the variable(s) that fail stationarity.

$\endgroup$
0
4
$\begingroup$

Time series is stationary if its mean level and variance stay steady over time. You can read more on this topic (with specification of relevant tests in R), in our post.. http://www.statosphere.com.au/check-time-series-stationary-r/

$\endgroup$
2
  • 1
    $\begingroup$ Late comment, but what do you mean that mean and variance stay steady over time? For a given set of data the mean and variance are what they are, right? Or do you mean that the mean/var of all subsets of the data must be equal? $\endgroup$ Commented Jul 27, 2015 at 5:49
  • 2
    $\begingroup$ I took a look on the linked page. It is stated that "The Ljung-Box test examines whether there is significant evidence for non-zero correlations at lags 1-20. Small p-values (i.e., less than 0.05) suggest that the series is stationary." The conclusion is plain wrong. The null is that the observations are iid. Rejecting the null based on a small p-value indicates only that there is at least one significant lag. The conclusion on the website would mean, that stationarity requires significant autocorrelation for at least one lag. And that is not true. $\endgroup$
    – random_guy
    Commented Mar 21, 2017 at 17:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.