Last Update: May 13, 2022
My online video tutorials are hosted at YouTube channel.
For learning this concept, you can view my online video tutorial: Stationarity: Augmented Dickey-Fuller Test in R.
Video Code
1. Packages
library(forecast)
library(ggplot2)
library(tseries)
2. Data
mdata <- AirPassengers
head(mdata)
Ranges Delimiting
tdata <- window(x = mdata, end = c(1958, 12))
fdata <- window(x = mdata, start = c(1959, 1))
Chart
autoplot(object = tdata) + labs(y = "Air Passengers", x = "Year")
3. First Order Stationarity
Augmented Dickey-Fuller Test
adf.test(x = tdata, alternative = "stationary", k = 12)