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?

    enter image description here

    did you already do some operations on the time series?

    @SRKX what operations are you talking to?

    detrending for example.

    @SRKX why do I have to detrend the series? I think unit root test already do that, no?

    indeed, I was just wondering looking at your graph

  • 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:

    • Augmented Dickey–Fuller (ADF) test
    • 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?

  • You can use the (Adjusted) Dickey Fuller 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.

    It's hard to be sure without seeing the data but I would go for 'none'. I advise you read the documentation at , page 43 for more information about the type parameter and the lag selection.

    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

    Can you give us a plot?

    I have added the timeseries. The series you see passed ADF and KPSS tests, but as you can see is not very good because the "volatility" is not constant

    I agree with the Phillips-Perron test. The Augmented Dickey-Fuller test is not robust to the selection of the number of lags. The KPSS test differs from these two tests in its null hypothesis, which is trend stationarity.

    Bootvis & @richardh the problem is that the above series have passed (ADF, PP, KPSS and ERS unit root tests)

    @Dam -- You can reject the unit root and still have time-varying volatility. Maybe you want to fit an ARCH model?

    @richardh could you give me an example in R? I never used ARCH before...thank you very much

    @Dam -- I will post some code in an answer.

    @richardh I just replied to your answer, please let me know. Thank you!

  • 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?

    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.

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

    ret <- diff.xts(log(MSFT$MSFT.Adjusted))[-1]
    arch_model <- garch(ret, order=c(0, 3))
    garch_model <- garch(ret, order=c(3, 3))

    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!

    @ricardh: you imply fitting a GARCH, computing the local volatilities $\sigma_t$ and checking whether they are the same $\forall t$ right?

    @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.

    @richardh what tests are you referring to? (about coefficients testing)

    @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).

  • 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.

  • If your theory/common sense indicates that your series is stationary the KPSS test is appropriate. It is a test of your theory/common sense.

    If your theory/common sense indicates that your series is I(1) then you should use one of the unit root tests already mentioned. I would prefer the Elliott–Rothenberg–Stock test.

    I would not recommend doing both tests. If they both confirm your original ideas then you are OK. If you are assuming stationarity and your series passes the KPSS test but the unit root test indicates non stationarity I would still accept that my theory has been confirmed by the KPSS and proceed accordingly. If the KPSS indicates non-stationarity and this is confirmed by the unit root test then my theory/common sense is subject to query. In any of the three cases there is no benefit to be gained from doing both kinds of tests.

    Without a knowledge of what you are testing it is not possible to give more specific advice.

    If you are estimating an ARMA or GARCH process the estimated coefficients must satisfy certain conditions if the series is to be stationary

  • You can use ADF test as implemented in R in different packages However, accuracy and power of these implementations would differ, since, these tests refer different papers to generate the p-values. The table below contains the packages, name of the functions and the referenced papers. You can go through the papers to keep an eye on the differences in the implementations. enter image description here

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

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM