Examples of using runstats package

Marta Karas

2019-11-14

runstats

Package runstats provides methods for fast computation of running sample statistics for time series. The methods utilize Convolution Theorem to compute convolutions via Fast Fourier Transform (FFT). Implemented running statistics include:

  1. mean,
  2. standard deviation,
  3. variance,
  4. covariance,
  5. correlation,
  6. euclidean distance.

Installation

Usage

Running statistics

To better explain the details of running statistics, package’s function runstats.demo(func.name) allows to visualize how the output of each running statistics method is generated. To run the demo, use func.name being one of the methods’ names:

  1. "RunningMean",
  2. "RunningSd",
  3. "RunningVar",
  4. "RunningCov",
  5. "RunningCor",
  6. "RunningL2Norm".

Performance

We use rbenchmark to measure elapsed time of RunningCov execution, for different lengths of time-series x and fixed length of the shorter pattern y.

test replications elapsed relative user.self sys.self x_length pattern_length
runstats 10 0.005 1 0.004 0.001 1000 100
runstats 10 0.023 1 0.018 0.004 10000 100
runstats 10 0.194 1 0.158 0.037 100000 100
runstats 10 1.791 1 1.656 0.125 1000000 100
runstats 10 20.234 1 17.660 2.514 10000000 100
Compare with a conventional method

To compare RunStats performance with “conventional” loop-based way of computing running covariance in R, we use rbenchmark package to measure elapsed time of RunStats::RunningCov and running covariance implemented with sapply loop, for different lengths of time-series x and fixed length of the shorter time-series y.

Benchmark results

Platform information