- Notifications
You must be signed in to change notification settings - Fork31
Extending broom for time series forecasting
business-science/sweep
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Extending
broom
to time series forecasting
Thesweep
package extends thebroom
tools (tidy, glance, andaugment) for performing forecasts and time series analysis in the“tidyverse”. The package is geared towards “tidying” the forecastworkflow used with Rob Hyndman’sforecast
package.
- Designed for modeling and scaling forecasts using the the
tidyverse
tools inR for Data Science - Extends
broom
for model analysis (ARIMA, ETS, BATS, etc) - Tidies the
forecast
objects for easy plotting and “tidy” datamanipulation - Integrates
timetk
to enable dates and datetimes (irregular timeseries) in the tidied forecast output
The package contains the following elements:
model tidiers:
sw_tidy
,sw_glance
,sw_augment
,sw_tidy_decomp
functions extendtidy
,glance
, andaugment
from thebroom
package specifically for models (ets()
,Arima()
,bats()
, etc) used for forecasting.forecast tidier:
sw_sweep
converts aforecast
object to atibble that can be easily manipulated in the “tidyverse”.
sweep
enables converting aforecast
object totibble
. The resultis ability to usedplyr
,tidyr
, andggplot
natively to manipulate,analyze and visualize forecasts.
Often forecasts are required on grouped data to analyse trends insub-categories. The good news is scaling from one time series to many iseasy with the varioussw_
functions in combination withdplyr
andpurrr
.
A common goal in forecasting is to compare different forecast modelsagainst each other.sweep
helps in this area as well.
If you are familiar withbroom
, you know how useful it is forretrieving “tidy” format model components.sweep
extends this benefitto theforecast
package workflow with the following functions:
sw_tidy
: Returns model coefficients (single column)sw_glance
: Returns accuracy statistics (single row)sw_augment
: Returns residualssw_tidy_decomp
: Returns seasonal decompositionssw_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 | |
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 |
Function Compatibility
Here’s how to get started.
Development version with latest features:
# install.packages("remotes")remotes::install_github("business-science/sweep")
Thesweep
package includes several vignettes to help users get up tospeed quickly:
- SW00 - Introduction to
sweep
- SW01 - Forecasting Time Series Groups in the tidyverse
- SW02 - Forecasting Using Multiple Models