Vector autoregression

We've seen in the preceding section that temperature is stationary and CO2 requires 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 will use ADF in the following code, which has a null hypothesis that the data is not stationary:

    > ndiffs(climate[, 1], test = "adf")    [1] 1    > ndiffs(climate[, 2], test = "adf")    [1] 1

We see that both require a first order ...

Get Mastering Machine Learning with R - Second 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.