The forecast package for R, created and maintained by Professor Rob Hyndman of Monash University, is one of the more useful R packages available available on CRAN . Statistical forecasting — the process of predicting the future value of a time series — is used in just about every realm of data analysis, whether it’s trying to predict a future stock price or trying to anticipate changes in the weather. If you’re looking to learn about forecasting, a great place to start is the online book Forecasting: Principles and Practice (by Hyndman and George Athanasopoulos) which walks you through the theory and practice, with many examples in R based on the forecast package. Topics covered include multiple regression , Time series decomposition , exponential smoothing , and ARIMA models .
The forecast package itself recently received a major update, to version 7. One major new capability is the ability to easily chart forecasts using the ggplot2 package with the new autoplot function. For example:
You can also add forecasts to any ggplot using the new geom_forecasts geom provided by the forecast package:
autoplot(mdeaths) + geom_forecast(h=36, level=c(50,80,95))
There have been several updates to the forecasting functions as well. The function for fitting linear models to time series data, tslm , has been rewritten to be more compatible with the standard lm function. It’s now possible to forecast means (as well as medians) when using Box-Cox transformations. And you can now apply neural networks to time series data by building a nonlinear autoregressive model with the new nnetar function.
Those are just some of the highlights of the updates to the forecast package in version 7. For complete details, follow the links to Rob Hyndman’s blog, below.