O'Reilly logo

Mastering Machine Learning with R - Second Edition by Cory Lesmeister

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required