简体   繁体   中英

How to test if trend is stochastic or deterministic in R

I have some difficulties while trying to understand if my data has stochastic or deterministic trend. As I understand in RI need to use adf.test, but how should I interpretate the results?

If adf.test accepts null hypothesis so that means that there's unit root. Later I use function diff() and check adf.test results again. If after making differences adf.test rejects null hypothesis Does it mean that my data has stochastic trend?

Any help would be very useful, thank you!

Augmented Dickey Fuller Test (ADF) is used to check if a process is stationary or not. The Null Hypothesis is that the process is stationary so it has no trend. The Alternative Hypothesis is that the process is not stationary, so it may follow a deterministic or stochastic trend. eg it's an upward slope

In R the command is the following:

adf.test(data$variable)

So if you find that the p-value is lower than a given threshold, usually 0.05, then you reject the null of stationarity. If it is larger than 0.05 the series is stationary.

In case your series is not stationary you may want to "stationarize" it. The usual way to proceed is by differentiating the log of the series. In R it would look like:

diff1 <- diff(log(data$variable))

Then you perform another ADF test, if you reject the null of stationarity again then you'll have to differenciate again:

diff2 <- diff(diff1)

Time series usually are stationary when doing the first difference, very rarely you need to differenciate more than once.

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM