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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.