Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Extending broom for time series forecasting

NotificationsYou must be signed in to change notification settings

business-science/sweep

Repository files navigation

Extendingbroom to time series forecasting

R-CMD-checkcodecovCRAN_Status_Badge

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.

Benefits

  • Designed for modeling and scaling forecasts using the thetidyverse tools inR for Data Science
  • Extendsbroom for model analysis (ARIMA, ETS, BATS, etc)
  • Tidies theforecast objects for easy plotting and “tidy” datamanipulation
  • Integratestimetk to enable dates and datetimes (irregular timeseries) in the tidied forecast output

Tools

The package contains the following elements:

  1. model tidiers:sw_tidy,sw_glance,sw_augment,sw_tidy_decomp functions extendtidy,glance, andaugmentfrom thebroom package specifically for models (ets(),Arima(),bats(), etc) used for forecasting.

  2. forecast tidier:sw_sweep converts aforecast object to atibble that can be easily manipulated in the “tidyverse”.

Making forecasts in the tidyverse

sweep enables converting aforecast object totibble. The resultis ability to usedplyr,tidyr, andggplot natively to manipulate,analyze and visualize forecasts.

Forecasting multiple time series groups at scale

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.

Forecasting multiple models for accuracy

A common goal in forecasting is to compare different forecast modelsagainst each other.sweep helps in this area as well.

broom extensions for forecasting

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 residuals
  • sw_tidy_decomp: Returns seasonal decompositions
  • sw_sweep: Returns tidy forecast outputs.

The compatibility chart is listed below.

Objectsw_tidy()sw_glance()sw_augment()sw_tidy_decomp()sw_sweep()
ar
arimaXXX
ArimaXXX
etsXXXX
baggedETS
batsXXXX
tbatsXXXX
nnetarXXX
stlX
HoltWintersXXXX
StructTSXXXX
tslmXXX
decomposeX
adf.testXX
Box.testXX
kpss.testXX
forecastX

Function Compatibility

Installation

Here’s how to get started.

Development version with latest features:

# install.packages("remotes")remotes::install_github("business-science/sweep")

Further Information

Thesweep package includes several vignettes to help users get up tospeed quickly:

  • SW00 - Introduction tosweep
  • SW01 - Forecasting Time Series Groups in the tidyverse
  • SW02 - Forecasting Using Multiple Models

[8]ページ先頭

©2009-2025 Movatter.jp