robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.13k stars 342 forks source link

Adjusted Dickey Fuller test #966

Closed Mkranj closed 1 month ago

Mkranj commented 1 month ago

Hi, I'm interested in performing an ADF test to confirm that my transformations ended up with a stationary time series. I couldn't find a function to let me perform the test by itself, so I was wondering if this approach is appropriate:

library(forecast)
wineind |> ndiffs(test = "adf")

Basically I'm trying to get the answer to "how many times should this series be differenced to be considered stationary" and expecting the answer to be 0 to consider this stationary per ADF test. So if I already differenced a non-stationary series and used that inside ndiffs(), the result should be 0.

Am I correct in this interpretation? Is there another way to conduct an ADF test I missed?

mitchelloharawild commented 1 month ago

Yes, your interpretation is correct. This function uses urca::ur.df, so if you want to perform the test directly you can use that function.

Mkranj commented 1 month ago

Thank you! I didn't really get how to interpret ur.df() results (mainly how to get p value) and parameters, guess I'll stick to the originally proposed method

mitchelloharawild commented 1 month ago

No worries.