R package forecast v7.2 now on CRAN

Hyndsight

I’ve pushed a minor update to the forecast package to CRAN. Some highlights are listed here.

Plotting time series with ggplot2

You can now facet a time series plot like this:

library(forecast)
library(ggplot2)
lungDeaths <- cbind(mdeaths, fdeaths)
autoplot(lungDeaths, facets=TRUE) So autoplot.mts now behaves similarly to plot.mts

Multi-step fitted values

The fitted function has a new argument h to allow computation of in-sample fitted values of more than one-step-ahead. In time series, fitted values are defined as the one-step-forecasts of the data used in training a model. Sometimes it is useful to have corresponding $h$-step forecasts, where $h>1$. This is now possible.

fit <- Arima(WWWusage,c(3,1,0))
tab <- cbind(data=WWWusage,
'h=1' = fitted(fit, h=1),
'h=2' = fitted(fit, h=2),
'h=3' = fitted(fit, h=3))
autoplot(tab) + ylab("Internet users") + xlab("Minute") Theta method now with seasonal adjustment

The Theta method was proposed by Assimakopoulos and Nikolopoulos (2000), and has been repeatedly shown to produce remarkably good forecasts. I included a non-seasonal form of the method (via thetaf) in the forecast package a long time ago, but I’ve now updated it to allow for seasonal time series as well. It is not quite identical to the A&N method, due to differences in optimization criteria, but it is close.

Tiny time series

With the forecast package being increasingly used for large scale automatic forecasting, it is important that it does not fail on edge cases such as time series consisting of 2 or 3 observations. I’ve made some new tweaks to allow ets() and auto.arima() to produce sensible results in these cases. I wouldn’t bet my house on forecasts using only 2 observations, but they aren’t too bad.