Vector autoregression

We've seen in the preceding section that temperature and CO2 require a first order difference. Another simple way to show this is with the forecast package's ndiffs() function. It provides an output that spells out the minimum number of differences needed to make the data stationary. In the function, you can specify which test out of the three available ones you would like to use: Kwiatkowski, Philips, Schmidt & Shin (KPSS), Augmented Dickey-Fuller (ADF), or Philips-Peron (PP). I'll use ADF in the following code, which has a null hypothesis that the data isn't stationary:

> climate49 <- window(climate_ts, start = 1949)   > forecast::ndiffs(climate49[, 1], test = "adf")    [1] 1> forecast::ndiffs(climate49[, 2], test = "adf") ...

Get Mastering Machine Learning with R - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.