Learn R Programming

TTR (version 0.14-0)

runFun: Analysis of Running/Rolling/Moving Windows

Description

Various functions to analyze data over a moving window of periods.

Usage

runSum(x, n=10)
  runMin(x, n=10)
  runMax(x, n=10)
  runMean(x, n=10)
  runMedian(x, n=10, low=FALSE, high=FALSE)
  runCov(x, y, n=10, use="all.obs", sample=TRUE)
  runCor(x, y, n=10, use="all.obs", sample=TRUE)
  runVar(x, n=10, sample=TRUE)
  runSD(x, n=10, sample=TRUE)
  runMAD(x, n=10, center=runMedian(x, n), stat="median",
         constant=1.4826, low=FALSE, high=FALSE)

Arguments

x
Object able to be coerced to a matrix.
y
Object able to be coerced to a matrix.
n
Number of periods to use in the window.
sample
Logical, sample covariance if TRUE (denominator of n-1)
use
Only "all.obs" currently implemented.
low
Logical, if TRUE, compute the 'low-median'; i.e., take the smaller of the two middle values for even sample sizes.
high
Logical, if TRUE, compute the 'high-median'; i.e., take the larger of the two middle values for even sample sizes.
center
The values to use as the measure of central tendency, around which to calculate deviations.
stat
Statistic to calculate, one of 'median' or 'mean' (e.g. median absolute deviation or mean absolute deviation, respectively.)
constant
Scale factor applied to approximate the standard deviation.

Value

  • runSum
  • returns sums over a n-period moving window.
  • runMin
  • returns minimums over a n-period moving window.
  • runMax
  • returns maximums over a n-period moving window.
  • runMean
  • returns means over a n-period moving window.
  • runMedian
  • returns medians over a n-period moving window.
  • runCov
  • returns covariances over a n-period moving window.
  • runCor
  • returns correlations over a n-period moving window.
  • runVar
  • returns variances over a n-period moving window.
  • runSD
  • returns standard deviations over a n-period moving window.
  • runMAD
  • returns median/mean absolute deviations over a n-period moving window.