问题
I'm new to forecasting and I'm trying to use the forecast package in r.
Can someone please explain the difference between mean and fitted in the forecast function?
For example,
fcast<-forecast(ts,h=30)
fcast$mean
fcast$fitted
The documentation says "mean is Point forecasts as a time series" and "fitted is Fitted values (one-step forecasts)".
An example to illustrate the difference would be great. Any help much appreciated.
回答1:
fcast$fitted
is the result of the fit (the model fitted to observation) and fcast$mean
is the result of the forecast (the application of the model to the future). You can compare length(ts)
and length(fcast$fitted)
. And length(fcast$mean)
and the h
you choose.
library(forecast)
fit <- Arima(WWWusage,order=c(3,1,0))
h <- 20
fcast <- forecast(fit, h = h)
length(WWWusage)
# [1] 100
length(fcast$fitted)
# [1] 100
h
# [1] 20
length(fcast$mean)
# [1] 20
来源:https://stackoverflow.com/questions/35448610/difference-between-mean-and-fitted-in-forecast-function