Suppose I'm using the ets
function from the forecast
package in R and I've fit the model to a single time series t
with something like
ets_model = ets(t)
fcast = forecast(ets_model, h=1)
I can see the forecast if I type fcast
in the console, but how do I actually extract this value so I can use it as part of a program? I've been searching through the contents of str(fcast)
and can't find the actual forecast anywhere.
It is fcast$mean
:
fcast <- forecast(ets(rnorm(20)), h = 1)
fcast
# Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
# 21 -0.06945796 -0.9153854 0.7764694 -1.363192 1.224276
fcast$mean
# Time Series:
# Start = 21
# End = 21
# Frequency = 1
# [1] -0.06945796