Extending broom for time series forecasting
Extendingbroomto time series forecasting
sweeppackage extends the
broomtools (tidy, glance, and augment) for performing forecasts and time series analysis in the “tidyverse”. The package is geared towards “tidying” the forecast workflow used with Rob Hyndman’s
tidyversetools in R for Data Science
broomfor model analysis (ARIMA, ETS, BATS, etc)
forecastobjects for easy plotting and “tidy” data manipulation
timetkto enable dates and datetimes (irregular time series) in the tidied forecast output
The package contains the following elements:
broompackage specifically for models (
bats(), etc) used for forecasting.
forecastobject to a tibble that can be easily manipulated in the “tidyverse”.
sweepenables converting a
tibble. The result is ability to use
ggplotnatively to manipulate, analyze and visualize forecasts.
Often forecasts are required on grouped data to analyse trends in sub-categories. The good news is scaling from one time series to many is easy with the various
sw_functions in combination with
A common goal in forecasting is to compare different forecast models against each other.
sweephelps in this area as well.
If you are familiar with
broom, you know how useful it is for retrieving “tidy” format model components.
sweepextends this benefit to the
forecastpackage workflow with the following functions:
sw_tidy: Returns model coefficients (single column)
sw_glance: Returns accuracy statistics (single row)
sw_augment: Returns residuals
sw_tidy_decomp: Returns seasonal decompositions
sw_sweep: Returns tidy forecast outputs.
The compatibility chart is listed below.
| Object | sw_tidy() | sw_glance() | sw_augment() | sw_tidy_decomp() | sw_sweep() | | :---------- | :--------: | :----------: | :-----------: | :----------------: | :---------: | | ar | | | | | | | arima | X | X | X | | | | Arima | X | X | X | | | | ets | X | X | X | X | | | robets | X | X | X | X | | | baggedETS | | | | | | | bats | X | X | X | X | | | tbats | X | X | X | X | | | nnetar | X | X | X | | | | stl | | | | X | | | HoltWinters | X | X | X | X | | | StructTS | X | X | X | X | | | tslm | X | X | X | | | | decompose | | | | X | | | adf.test | X | X | | | | | Box.test | X | X | | | | | kpss.test | X | X | | | | | forecast | | | | | X |
Here’s how to get started.
Development version with latest features:
# install.packages("devtools") devtools::install_github("business-science/sweep")
sweeppackage includes several vignettes to help users get up to speed quickly: