https://github.com/business-science/sweep

Extending broom for time series forecasting

https://github.com/business-science/sweep

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.8%) to scientific vocabulary

Keywords

broom forecast forecasting-models prediction r-package tidy tidyverse time time-series timeseries

Keywords from Contributors

tidymodeling xts stock-symbol stock-prices stock-performance stock-lists stock-indexes stock-exchanges stock quantmod
Last synced: 5 months ago · JSON representation

Repository

Extending broom for time series forecasting

Basic Info
Statistics
  • Stars: 155
  • Watchers: 8
  • Forks: 31
  • Open Issues: 6
  • Releases: 0
Topics
broom forecast forecasting-models prediction r-package tidy tidyverse time time-series timeseries
Created over 8 years ago · Last pushed about 2 years ago
Metadata Files
Readme

README.Rmd

---
output: github_document
---



```{r, echo = FALSE}
knitr::opts_chunk$set(
    message = F, 
    warning = F,
    collapse = TRUE,
    comment = "#>",
    fig.path = "README-"
)
```

```{r, echo=FALSE}
library(tidyquant)
library(sweep)
```


# sweep 


> Extending `broom` to time series forecasting

 
[![R-CMD-check](https://github.com/business-science/sweep/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/business-science/sweep/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/business-science/sweep/branch/master/graph/badge.svg)](https://app.codecov.io/gh/business-science/sweep)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/sweep)](https://cran.r-project.org/package=sweep)
![](http://cranlogs.r-pkg.org/badges/sweep?color=brightgreen)
![](http://cranlogs.r-pkg.org/badges/grand-total/sweep?color=brightgreen)


The `sweep` package extends the `broom` tools (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 `forecast` package. 

## Benefits

* __Designed for modeling and scaling forecasts using the the `tidyverse` tools in [_R for Data Science_](https://r4ds.hadley.nz/)__
* __Extends `broom` for model analysis (ARIMA, ETS, BATS, etc)__
* __Tidies the `forecast` objects for easy plotting and "tidy" data manipulation__
* __Integrates `timetk` to enable dates and datetimes (irregular time series) 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 extend `tidy`, `glance`, and `augment` from the `broom` package specifically for models (`ets()`, `Arima()`, `bats()`, etc) used for forecasting. 

2. __forecast tidier__: `sw_sweep` converts a `forecast` object to a tibble that can be easily manipulated in the "tidyverse".


## Making forecasts in the tidyverse

`sweep` enables converting a `forecast` object to `tibble`. The result is ability to use `dplyr`, `tidyr`, and `ggplot` natively to manipulate, analyze and visualize forecasts.

```{r echo=FALSE, out.width='100%'}
knitr::include_graphics("man/figures/forecast.png")
```

## Forecasting multiple time series groups at scale

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 `dplyr` and `purrr`.

```{r echo=FALSE, out.width='100%'}
knitr::include_graphics("man/figures/time_series_groups.png")
```

## Forecasting multiple models for accuracy

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


```{r echo=FALSE, out.width='100%'}
knitr::include_graphics("man/figures/multiple_models.png")
```

## broom extensions for forecasting

If you are familiar with `broom`, you know how useful it is for retrieving "tidy" format model components. `sweep` extends this benefit to the `forecast` 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.

```{r, echo = F}
tibble::tribble(
    ~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"
) %>%
    knitr::kable(caption = "Function Compatibility",
                 align = c("l", "c", "c", "c", "c", "c"))
```


## Installation

Here's how to get started.

Development version with latest features:

``` {r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("business-science/sweep")
```









## Further Information

The `sweep` package includes several vignettes to help users get up to speed quickly:

* SW00 - Introduction to `sweep`
* SW01 - Forecasting Time Series Groups in the tidyverse
* SW02 - Forecasting Using Multiple Models


Owner

  • Name: Business Science
  • Login: business-science
  • Kind: organization
  • Email: info@business-science.io
  • Location: United States of America

Applying data science to business & financial analysis, tw: @bizScienc

GitHub Events

Total
  • Watch event: 1
  • Push event: 5
Last Year
  • Watch event: 1
  • Push event: 5

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 107
  • Total Committers: 5
  • Avg Commits per committer: 21.4
  • Development Distribution Score (DDS): 0.215
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Matt Dancho m****o@g****m 84
olivroy o****1@h****m 14
Joel Gombin j****n@g****m 6
DavisVaughan m****5@u****u 2
Rob J Hyndman r****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 17
  • Total pull requests: 6
  • Average time to close issues: 10 months
  • Average time to close pull requests: 4 months
  • Total issue authors: 14
  • Total pull request authors: 4
  • Average comments per issue: 1.18
  • Average comments per pull request: 1.0
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • mdancho84 (3)
  • ghost (2)
  • simonpcouch (1)
  • Someone894 (1)
  • edgBR (1)
  • JasonAizkalns (1)
  • tmerrittsmith (1)
  • vspinu (1)
  • amrrs (1)
  • DSLmsft (1)
  • olivroy (1)
  • rosseji (1)
  • djmason199 (1)
  • willshelley404 (1)
Pull Request Authors
  • olivroy (3)
  • MichaelChirico (2)
  • joelgombin (1)
  • robjhyndman (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 2,005 last-month
  • Total docker downloads: 43,426
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 8
    (may contain duplicates)
  • Total versions: 10
  • Total maintainers: 1
cran.r-project.org: sweep

Tidy Tools for Forecasting

  • Versions: 8
  • Dependent Packages: 1
  • Dependent Repositories: 8
  • Downloads: 2,005 Last month
  • Docker Downloads: 43,426
Rankings
Forks count: 2.5%
Stargazers count: 2.7%
Downloads: 8.7%
Average: 8.8%
Dependent repos count: 10.6%
Docker downloads count: 10.9%
Dependent packages count: 17.6%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-sweep
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 26.5%
Forks count: 27.9%
Dependent repos count: 34.0%
Average: 34.9%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.3.0 depends
  • broom >= 0.5.6 imports
  • dplyr >= 1.0.0 imports
  • forecast >= 8.0 imports
  • lubridate >= 1.6.0 imports
  • rlang * imports
  • tibble >= 1.2 imports
  • tidyr >= 1.0.0 imports
  • timetk >= 2.1.0 imports
  • forcats * suggests
  • fracdiff * suggests
  • knitr * suggests
  • purrr * suggests
  • readr * suggests
  • rmarkdown * suggests
  • robets * suggests
  • scales * suggests
  • stringr * suggests
  • testthat * suggests
  • tidyquant * suggests
  • tidyverse * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite