Difference between mean and fitted in forecast fun

2019-08-10 02:50发布

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.

标签: r forecasting
1条回答
倾城 Initia
2楼-- · 2019-08-10 03:28

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
查看更多
登录 后发表回答