library(forecast)
= forecast(auto.arima(Nile, lambda=0), h=20, level=95)
f1 = forecast(ets(Nile), h=20, level=95)
f2
plot(f1, shadecol=rgb(0,0,1,.4), flwd=1,
main="Forecasts of Nile River flow",
xlab="Year", ylab="Billions of cubic metres")
polygon(c(time(f2$mean),rev(time(f2$mean))),
c(f2$lower,rev(f2$upper)),
col=rgb(1,0,0,.4),
border=FALSE)
lines(f2$mean, col=rgb(.7,0,0))
legend("bottomleft",
fill=c(rgb(0,0,1,.4),rgb(1,0,0,.4)),
col=c("blue","red"), lty=1,
legend=c("ARIMA","ETS"))
Plotting overlapping prediction intervals
I often see figures with two sets of prediction intervals plotted on the same graph using different line types to distinguish them. The results are almost always unreadable. A better way to do this is to use semi-transparent shaded regions. Here is an example showing two sets of forecasts for the Nile River flow.
The blue region shows 95% prediction intervals for the ARIMA forecasts, while the red region shows 95% prediction intervals for the ETS forecasts. Where they overlap, the colors blend to make purple. In this case, the point forecasts are quite close, but the prediction intervals are relatively different.