Incremental Moment Windows

Computes rolling statistics, including the mean, variance, skewness, and kurtosis, over moving windows. The package uses incremental algorithms to efficiently update statistics as new observations arrive, supporting both online computation and batch processing for time-series analysis and streaming data applications. Implemented in C++, the package provides a high-performance, header-only implementation that facilitates direct integration into other packages.


IMW

The IMW-package implements a method for calculating the rolling statistics mean, variance, skewness, and kurtosis. Furthermore, it provides a function for updating these statistics as new information is received, allowing for online/batch calculation of these statistics.

Installation

The IMW-package depends on R (>= 4.0.1) and Rcpp (>= 1.0.4.6). As the package is not available on CRAN, remotes is needed to install the package from github.

From R, run the following commands:

install.packages("Rcpp")

if (!requireNamespace("remotes", quietly = TRUE)) {
    install.packages("remotes")
}

remotes::install_github("svilsen/IMW")

Usage

A series of 100 observations is generated randomly, and the rolling mean, variance, skewness, and kurtosis are calculated using a window size of 10.

## Initial set-up
# 
set.seed(1234)

# Observed data
N <- 100
x <- cumsum(rnorm(N))

# Window size
k <- 10

# Calculating rolling statistics using window size 'k'
mw <- imw(x, k)

#
plot(mw, xlim = c(1, 150))
Rplot01

Subsequently, a new batch of 50 observations are observed, and the rolling statistics are updated given this additional information.

## Updating moments
# Additional data
M <- 50
y <- cumsum(c(tail(x, 1), rnorm(M)))[-1]

# Update the moments using new information
umw <- uimw(mw, y)

#
plot(umw, xlim = c(1, 150))
Rplot02

License

This project is licensed under the MIT License.

Reference manual

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

install.packages("IMW")

1.1 by Søren B. Vilsen, 12 hours ago


Browse source code at https://github.com/cran/IMW


Authors: Søren B. Vilsen [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp

Linking to Rcpp


See at CRAN