Abhijit Kaware
Abhijit Kaware

Reputation: 43

How should I get the forecasted values in R using Arima Model?

I am new to R so doesn't know how exactly the forecasting works in R using Arima Model. I have a dataset is like: 92 Aug-17 9533 93 Sep-17 8718 94 Oct-17 2035 95 Nov-17 2539 96 Dec-17 1333 97 Jan-18 2444 98 Feb-18 9371 99 Mar-18 9697 100 Apr-18 3989 101 May-18 4061 102 Jun-18 2797 103 Jul-18 2949

I want see the forecasted values for next 12 months by using arima model in R. So how should I achieve this.

Thanks in Advance. this is a dataset

Upvotes: 0

Views: 3426

Answers (3)

KasperGL
KasperGL

Reputation: 607

library(forecast)
forecast_horizon <- 12 # because you said 12 months
model <- auto.arima(data)
forecasts <- forecast(model, forecast_horizon)
y_pred <- forecasts$mean

Upvotes: 0

Econ_matrix
Econ_matrix

Reputation: 405

You can use forecast package in R to forecast. However, your question is very broad, an example would be:

library(forecast)

data("airmiles")

auto.arima(airmiles, stepwise = F,approximation = F)->arima_fit # fit an arima model with autoarima 

forecast(arima_fit, h= 12 )->fc # forcast next 12 months 

accuracy(fc) #check accuracy of your forecast

for more details check this book

Upvotes: 2

girijesh96
girijesh96

Reputation: 455

Suppose you have fitted your ARIMA model in fit

so you can use the following method for predicting values. Here n is the number of values you want to predict. In your case, n will be 12.

pred = predict(fit,n.ahead = 1*n)

If you are taking log of values during ARIMA modeling so you use the following method for actual output.

values = 2.718^pred$pred

Upvotes: 3

Related Questions