Rolling and Expanding Statistics

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

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


Get the released version from CRAN:


Or the development version from GitHub:

# install.packages("devtools")


News for package 'roll'

Changes in roll version 1.1.2 (2019-02-06)

  • New roll_median, roll_min, roll_max, roll_any, and roll_all functions for computing rolling medians, minimums, maximums, any, and all, respectively, of time-series data (#4, #13, #14)
    • Note: roll_median, roll_min, and roll_max functions are not calculated using online algorithms

Changes in roll version 1.1.1 (2018-08-11)

  • Added online argument to process observations using online algorithms by default

  • roll_lm function now returns standard errors (#7)

  • Simplified checks for width and min_obs arguments (#3)

  • Added y argument to roll_cov and roll_cor functions (#2)

  • Updated src/Makevars and src/ files to what the RcppArmadillo skeleton default now uses to more fully utilize OpenMP

    • Note: if users take advantage of parallelism using multithreaded libraries, then limit the number of cores in the RcppParallel package to one with the setThreadOptions function
  • Deprecated less common functions (roll_eigen, roll_vif, and roll_pcr) and arguments (scale and center in the roll_lm function); also removed the parallel_for argument in favor of a new approach used internally

Changes in roll version 1.0.7 (2017-05-01)

  • New roll_sum and roll_prod functions for computing rolling sums and products, respectively, of time-series data

  • Added init.c file with calls to R_registerRoutines() and R_useDynamicSymbols(); also uses .registration = TRUE in useDynLib in NAMESPACE

Changes in roll version 1.0.6 (2016-09-19)

  • Added intercept argument to roll_lm and roll_pcr functions

  • Turned on CXXSTD = CXX11 to enforce adherence to the C++11 standard

Changes in roll version 1.0.5 (2016-08-29)

  • Added a section on examples to the README file

  • Fixed an issue in the src/Makevars and src/ files (#1)

Changes in roll version 1.0.4 (2016-07-05)

  • roll_lm and roll_pcr functions have been enhanced:

    • y can now be a matrix or xts object with multiple dependent variables

    • Added shorthand arguments for center and scale

  • New roll_scale function for computing rolling scaling and centering of time-series data

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1.6 by Jason Foster, 9 months ago

Report a bug at

Browse source code at

Authors: Jason Foster

Documentation:   PDF Manual  

Task views: Time Series Analysis

GPL (>= 2) license

Imports Rcpp, RcppParallel

Suggests covr, testthat, zoo

Linking to Rcpp, RcppArmadillo, RcppParallel

System requirements: GNU make, C++11

Imported by dLagM, dccmidas, rumidas.

Depended on by kcpRS.

Suggested by rollRegres.

See at CRAN