Suppressing the confidence interval

noetsi

No cake for spunky
#1
I am running the R package forecast. Only part of the code I ran is shown, I can't send the data and I don't think that matters for my question.

Code:
modeltr<- Arima (mydatatr,order = c(0,1,1), seasonal= c(1,0,0))
> #forecast(modeltr, h=12)
> forecast(modeltr, h=12)
I only want the forecast not the confidence intervals this prints. I have to transfer the point forecast to excel - just that.

Does anyone know how to surpress the confidence intervals?
 

Dason

Ambassador to the humans
#2
Some general guidance for how to figure these things out. If you haven't already look at the help file for forecast to see if there is a way to suppress that.

Code:
?forecast
There is the limit parameter but it doesn't allow for removing the limits entirely. So it kind of looks like you can't disable which is fine. Let's take a look at how the object itself is stored. So first make sure you save the output

Code:
fc <- forecast(modeltr, h = 12)
Then from there check out the structure of the object

Code:
str(fc)
You didn't provide any sample data so I just used mtcars$mpg as my "series".

Code:
> str(fc)
List of 10
 $ method   : chr "ARIMA(0,1,1)"
 $ model    :List of 18
  ..$ coef     : Named num -0.0852
  .. ..- attr(*, "names")= chr "ma1"
  ..$ sigma2   : num 37.4
  ..$ var.coef : num [1, 1] 0.0309
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr "ma1"
  .. .. ..$ : chr "ma1"
  ..$ mask     : logi TRUE
  ..$ loglik   : num -99.6
  ..$ aic      : num 203
  ..$ arma     : int [1:7] 0 1 0 0 1 1 0
  ..$ residuals: Time-Series [1:32] from 1 to 32: 2.10e-02 1.78e-06 1.80 -1.25 -2.81 ...
  ..$ call     : language Arima(y = mtcars$mpg, order = c(0, 1, 1), seasonal = c(1, 0, 0))
  ..$ series   : chr "mtcars$mpg"
  ..$ code     : int 0
  ..$ n.cond   : int 0
  ..$ nobs     : int 31
  ..$ model    :List of 10
  .. ..$ phi  : num(0) 
  .. ..$ theta: num -0.0852
  .. ..$ Delta: num 1
  .. ..$ Z    : num [1:3] 1 0 1
  .. ..$ a    : num [1:3] 6.4 -0.513 15
  .. ..$ P    : num [1:3, 1:3] 0.00 0.00 5.01e-22 0.00 0.00 ...
  .. ..$ T    : num [1:3, 1:3] 0 0 1 1 0 0 0 0 1
  .. ..$ V    : num [1:3, 1:3] 1 -0.08519 0 -0.08519 0.00726 ...
  .. ..$ h    : num 0
  .. ..$ Pn   : num [1:3, 1:3] 1.00 -8.52e-02 3.94e-23 -8.52e-02 7.26e-03 ...
  ..$ aicc     : num 204
  ..$ bic      : num 206
  ..$ x        : Time-Series [1:32] from 1 to 32: 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
  ..$ fitted   : Time-Series [1:32] from 1 to 32: 21 21 21 22.6 21.5 ...
  ..- attr(*, "class")= chr [1:3] "forecast_ARIMA" "ARIMA" "Arima"
 $ level    : num [1:2] 80 95
 $ mean     : Time-Series [1:12] from 33 to 44: 20.9 20.9 20.9 20.9 20.9 ...
 $ lower    : Time-Series [1:12, 1:2] from 33 to 44: 13.05 10.27 8.07 6.2 4.55 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:2] "80%" "95%"
 $ upper    : Time-Series [1:12, 1:2] from 33 to 44: 28.7 31.5 33.7 35.6 37.2 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:2] "80%" "95%"
 $ x        : Time-Series [1:32] from 1 to 32: 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
 $ series   : chr "mtcars$mpg"
 $ fitted   : Time-Series [1:32] from 1 to 32: 21 21 21 22.6 21.5 ...
 $ residuals: Time-Series [1:32] from 1 to 32: 2.10e-02 1.78e-06 1.80 -1.25 -2.81 ...
 - attr(*, "class")= chr "forecast"
So it looks like the output is actually a list. So what we were seeing in the console is probably just a specialized print function for objects with a class of "forecast". But we can just get the predictions directly from this object.

Looking through the structure it looks like what we want is the "mean" values so

Code:
fc$mean
is the values you want. You can save that however you want and then write it out to a csv.