Forecasting in R
Rob J. Hyndman
Professor of Statistics at Monash University
A fitted value is the forecast of an observation using all previous observations
That is, they are one-step forecasts
Often not true forecasts since parameters are estimated on all data
A residual is the difference between an observation and its fitted value
fc <- naive(oil)
autoplot(oil, series = "Data") + xlab("Year") +
autolayer(fitted(fc), series = "Fitted") +
ggtitle("Oil production in Saudi Arabia")
autoplot(residuals(fc))
Essential assumptions
They should be uncorrelated
They should have mean zero
Useful properties (for computing prediction intervals)
They should have constant variance
They should be normally distributed
We can test these assumptions using the checkresiduals()
function.
checkresiduals(fc)
Ljung-Box test
data: residuals
Q* = 12.59, df = 10, p-value = 0.2475
Model df: 0. Total lags used: 10
Forecasting in R