roll

Fast and efficient computation of rolling and expanding statistics for time-series data.

https://github.com/jasonjfoster/roll

Science Score: 26.0%

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

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.5%) to scientific vocabulary

Keywords

algorithms package r rcpp statistics
Last synced: 6 months ago · JSON representation

Repository

Fast and efficient computation of rolling and expanding statistics for time-series data.

Basic Info
Statistics
  • Stars: 117
  • Watchers: 10
  • Forks: 6
  • Open Issues: 4
  • Releases: 0
Topics
algorithms package r rcpp statistics
Created almost 10 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog

README.md

roll

Overview

roll is a package that provides fast and efficient computation of rolling and expanding statistics for time-series data.

The default algorithm in the roll package, and suitable for most applications, is an online algorithm. Based on the speed requirements and sequential nature of many problems in practice, online algorithms are a natural fit for computing rolling and expanding statistics of time-series data. That is, as observations are added and removed from a window, online algorithms update statistics and discard observations from memory (Welford, 1962; West, 1979); as a result, the amount of time to evaluate each function is significantly faster as the computation is independent of the window. In contrast, an offline algorithm requires all observations in memory to calculate the statistic for each window. Note that online algorithms are prone to loss of precision due to round-off error; hence, users can trade speed for accuracy and select the offline algorithm by setting the online argument to FALSE. Also, the RcppParallel package is used to parallelize the online algorithms across columns and across windows for the offline algorithms.

As mentioned above, the numerical calculations use the RcppParallel package to parallelize rolling and expanding statistics of time-series data. The RcppParallel package provides a complete toolkit for creating safe, portable, high-performance parallel algorithms, built on top of the Intel Threading Building Blocks (TBB) and TinyThread libraries. By default, all the available cores on a machine are used for parallel algorithms. If users are either already taking advantage of parallelism or instead want to use a fixed number or proportion of threads, then set the number of threads in the RcppParallel package with the RcppParallel::setThreadOptions function.

Installation

Install the released version from CRAN:

r install.packages("roll")

Or the development version from GitHub:

``` r

install.packages("devtools")

devtools::install_github("jasonjfoster/roll") ```

Usage

Load the package and supply a dataset:

``` r library(roll)

n <- 15 x <- rnorm(n) y <- rnorm(n) weights <- 0.9 ^ (n:1) ```

Then, to compute rolling and expanding means, use the roll_mean function:

``` r

rolling means with complete windows

roll_mean(x, width = 5)

rolling means with partial windows

rollmean(x, width = 5, minobs = 1)

expanding means with partial windows

rollmean(x, width = n, minobs = 1)

expanding means with weights and partial windows

rollmean(x, width = n, minobs = 1, weights = weights) ```

Or use the roll_lm function to compute rolling and expanding regressions:

``` r

rolling regressions with complete windows

roll_lm(x, y, width = 5)

rolling regressions with partial windows

rolllm(x, y, width = 5, minobs = 1)

expanding regressions with partial windows

rolllm(x, y, width = n, minobs = 1)

expanding regressions with weights and partial windows

rolllm(x, y, width = n, minobs = 1, weights = weights) ```

Note that handling of missing values is supported as well (see the min_obs, complete_obs, and na_restore arguments).

References

Welford, B.P. (1962). "Note on a Method for Calculating Corrected Sums of Squares and Products." Technometrics, 4(3), 419-420.

West, D.H.D. (1979). "Updating Mean and Variance Estimates: An Improved Method." Communications of the ACM, 22(9), 532-535.

Owner

  • Name: Jason Foster
  • Login: jasonjfoster
  • Kind: user
  • Location: New York, NY

GitHub Events

Total
  • Issues event: 5
  • Watch event: 4
  • Issue comment event: 3
  • Push event: 30
Last Year
  • Issues event: 5
  • Watch event: 4
  • Issue comment event: 3
  • Push event: 30

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 246
  • Total Committers: 2
  • Avg Commits per committer: 123.0
  • Development Distribution Score (DDS): 0.004
Past Year
  • Commits: 37
  • Committers: 1
  • Avg Commits per committer: 37.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Jason Foster j****r@g****m 245
Hiroaki Yutani y****i@g****m 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: 9 days
  • Average time to close pull requests: N/A
  • Total issue authors: 2
  • Total pull request authors: 0
  • Average comments per issue: 1.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: 9 days
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 1.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • roaldarbol (2)
  • ethanbsmith (2)
  • pessinafederico (1)
  • Beliavsky (1)
  • waynelapierre (1)
  • iwelch (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 4,827 last-month
  • Total docker downloads: 43,390
  • Total dependent packages: 9
  • Total dependent repositories: 12
  • Total versions: 16
  • Total maintainers: 1
cran.r-project.org: roll

Rolling and Expanding Statistics

  • Versions: 16
  • Dependent Packages: 9
  • Dependent Repositories: 12
  • Downloads: 4,827 Last month
  • Docker Downloads: 43,390
Rankings
Docker downloads count: 0.6%
Stargazers count: 3.7%
Dependent packages count: 5.7%
Average: 6.0%
Downloads: 6.8%
Dependent repos count: 8.4%
Forks count: 10.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • Rcpp * imports
  • RcppParallel * imports
  • covr * suggests
  • testthat * suggests
  • zoo * suggests
.github/workflows/check-standard.yaml actions
  • actions/checkout v2 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/test-coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite