# How to check if a timeseries is stationary?

I'm using KPSS Method to check if the series is stationary, but I would also like to use another test to confirm if the series is stationary or not, what method coudl I use?

-
did you already do some operations on the time series? – SRKX Nov 13 '11 at 16:45
@SRKX what operations are you talking to? – Dail Nov 14 '11 at 7:23
detrending for example. – SRKX Nov 14 '11 at 8:20
@SRKX why do I have to detrend the series? I think unit root test already do that, no? – Dail Nov 14 '11 at 15:45
indeed, I was just wondering looking at your graph – SRKX Nov 14 '11 at 15:56

To be a stationarity is when the roots of charateristic equation lies outside of the unit circle.

-

Divide the time series into two sections (e.g. 1st half and 2nd half) and construct the CDF for each part. The CDFs should be the same if the series is stationary. Since the CDFs will never be exactly the same you can apply Pearson's $\chi^{2}$ test comparing the value of the CDFs through several waypoints. I believe this test was created by the late Cliff Sherry.

-

Yet another alternative are wavelet based tests. With comparable size, they often have higher power, especially for very near unit root alternatives. An example is here (free pre-print versions of this paper are available, too).

-
Should it be the R package to do the tests you told me? cran.r-project.org/web/packages/wavelets/index.html – Dail Nov 14 '11 at 7:02
You can use the DWT and MODWT functions in that package to construct the test. I doubt the test itself is implemented. Maybe you can find the code at the authors' webpages. – Ryogi Nov 14 '11 at 16:45

There are many different methods for this. Most people rely on a unit root test. Rmetrics has collected the most common unit root tests into the fUnitRoots package, which primarily provides a wrapper for Bernhard Pfaff's urca package. These include:

• Elliott–Rothenberg–Stock test
• KPSS unit root test
• Phillips–Perron test
• Schmidt–Phillips test
• Zivot–Andrews

If you want to understand these functions in more detail, I recommend Pfaff's book on "Analysis of Integrated and Cointegrated Time Series with R". "Applied Econometrics with R" also provides a nice short introduction.

Chapter 4 of Eric Zivot's book on time series analysis covers unit root tests and is available on his website. He uses S-Plus, but the urca functions are almost identical.

-
thank you for the answer, but as I mentioned The series above have passed the following unit root tests: ADF, PP, ERS, KPSS... So I think is not a unit root problem, maybe I have to use some test to check if the "volatility" is constant, what do you think about that? – Dail Nov 14 '11 at 7:25

The tseries package has GARCH models. Here is some simple code:

library(quantmod)
library(tseries)
getSymbols("MSFT")
ret <- diff.xts(log(MSFT$MSFT.Adjusted))[-1] arch_model <- garch(ret, order=c(0, 3)) garch_model <- garch(ret, order=c(3, 3)) plot(arch_model) plot(garch_model)  Also, Eric Zivot has good notes on time-series and R. - (I'm Dam, I registered an username on quant)... thank you for that example...but after plotting those example, how I solve my problem of different volatility? As far I have understand garch return an autoregressive model, so obviously there is not a kind of "pvalue" to test if the series "pass" or not. How could i do? thank you! – Dail Nov 14 '11 at 7:00 @ricardh: you imply fitting a GARCH, computing the local volatilities$\sigma_t$and checking whether they are the same$\forall t\$ right? – SRKX Nov 14 '11 at 13:15
@SKRX -- Yes, thanks. I should have included more commentary. He asked how to fit a GARCH model in R, so I gave some code. Once he determines the best-fitting GARCH model with ll, ic, and ssr, he can perform joint tests on the GARCH model coefficients. – Richard Herron Nov 14 '11 at 14:32
@richardh what tests are you referring to? (about coefficients testing) – Dail Nov 14 '11 at 15:46
@Dail -- There are a variety of tests, but Wald tests that all coefficients are jointly zero is probably the easiest. I searched for how to do this in R, but wasn't too successful. You will likely have to grab a text book and code the tests yourself. (I switched to Stata for most analyses because hypothesis testing is so much easier). – Richard Herron Nov 14 '11 at 16:26

You can use the (Adjusted) Dickey Fuller Test: http://en.wikipedia.org/wiki/Dickey%E2%80%93Fuller_test

I'm pretty sure your software package has a library or routine you can use to do it.

-
yes I found it on URCA package (ur.df) I need a level stationary, what parameters should I use? because I see "none" "drift" and "trend" on the type parameter. – Dam Nov 13 '11 at 11:41
It's hard to be sure without seeing the data but I would go for 'none'. I advise you read the documentation at cran.r-project.org/web/packages/urca/urca.pdf , page 43 for more information about the type parameter and the lag selection. – Bob Jansen Nov 13 '11 at 12:06
About the data you can image that I need to use this test in a timeseries like rnorm(800) (obviously the data is not so perfect) I need a test to understand if my data is similar to it or not – Dam Nov 13 '11 at 12:08
Can you give us a plot? – Bob Jansen Nov 13 '11 at 12:41
Have you looked at this: staff.bath.ac.uk/hssjrh/Phillips%20Perron.pdf – Bob Jansen Nov 13 '11 at 17:29