O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

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

How it works...

Step 1 reads the data.

In step 2, the time series object ts is created. For more details, refer to the Using time series objects recipe earlier in this chapter.

In step 3, the auto.arima function in the forecast package is used to generate the ARIMA model. This function conducts an orderly search to generate the best ARIMA model according to the AIC, AICc, or the BIC value. The idea is to choose a model with minimum AIC and BIC values. We control the criterion used through the ic parameter (for example, ic = "aicc"). If we provide no value, the function uses AICc.

In step 4, the forecast for the specified time horizon (the h parameter) is generated.

Step 5 plots the results. The two bands show the 85 % and the 95 % confidence ...

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