| Title: | Incremental Moment Windows |
|---|---|
| Description: | 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. |
| Authors: | Søren B. Vilsen [aut, cre] |
| Maintainer: | Søren B. Vilsen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1 |
| Built: | 2026-11-05 01:27:02 UTC |
| Source: | https://github.com/cran/IMW |
Converts an object of imw-object to a matrix.
## S3 method for class 'imw' as.matrix(x, ...)## S3 method for class 'imw' as.matrix(x, ...)
x |
An imw-object. |
... |
Additional arguments; not used in this instance. |
A numeric matrix of rolling statistics.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) as.matrix(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) as.matrix(mw)
Rolling estimates of moments given a fixed window size.
imw(x, k)imw(x, k)
x |
Vector, or column matrix: The data used to estimate the moments. |
k |
Numeric: The window size. |
An imw-object.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 imw(x, k)N <- 100 x <- cumsum(rnorm(N)) k <- 10 imw(x, k)
An imw-object is a list of class imw containing the following:
statsMatrix: The rolling mean, variance, skewness, and kurtosis of data.
laggedVector: A vector of the incremental moments, as well as the number of observations used to calculate these moments, at the beginning of the last window.
totalVector: A vector of the incremental moments, as well as the number of observations used to calculate these moments, at the end of the last window.
xMatrix: The data used to estimate the moments.
kNumeric: The size of the window used to calculate the four moments.
Returns the rolling kurtosis of an imw-object.
kurtosis(x, ...)kurtosis(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1, 2, 3, corresponding to the three methods discussed by Joanes and Gill (1998).
The estimated rolling kurtosis.
D. N. Joanes and C. A. Gill (1998), Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) kurtosis(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) kurtosis(mw)
Returns the rolling kurtosis of an imw-object.
## S3 method for class 'imw' kurtosis(x, ...)## S3 method for class 'imw' kurtosis(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1, 2, 3, corresponding to the three methods discussed by Joanes and Gill (1998).
The estimated rolling kurtosis.
D. N. Joanes and C. A. Gill (1998), Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) kurtosis(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) kurtosis(mw)
Returns the rolling mean of an imw-object.
## S3 method for class 'imw' mean(x, ...)## S3 method for class 'imw' mean(x, ...)
x |
An imw-object. |
... |
Additional arguments; not used in this instance. |
The estimated rolling mean.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) mean(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) mean(mw)
Shows the four rolling statistics of an imw-object.
## S3 method for class 'imw' plot(x, ...)## S3 method for class 'imw' plot(x, ...)
x |
An imw-object. |
... |
Additional arguments passed to the internal plot functions. |
An invisible NULL.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) plot(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) plot(mw)
Returns the rolling skewness of an imw-object.
skewness(x, ...)skewness(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1, 2, 3, corresponding to the three methods discussed by Joanes and Gill (1998).
The estimated rolling skewness.
D. N. Joanes and C. A. Gill (1998), Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) skewness(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) skewness(mw)
Returns the rolling skewness of an imw-object.
## S3 method for class 'imw' skewness(x, ...)## S3 method for class 'imw' skewness(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1, 2, 3, corresponding to the three methods discussed by Joanes and Gill (1998).
The estimated rolling skewness.
D. N. Joanes and C. A. Gill (1998), Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) skewness(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) skewness(mw)
Update an imw-object with new data.
uimw(object, xnew)uimw(object, xnew)
object |
An imw-object. |
xnew |
Vector, or column matrix: The new data used to update the estimated moments. |
An imw-object.
# Initial data N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) # Additional data M <- 20 y <- cumsum(c(tail(x, 1), rnorm(M)))[-1] uimw(mw, y)# Initial data N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) # Additional data M <- 20 y <- cumsum(c(tail(x, 1), rnorm(M)))[-1] uimw(mw, y)
Returns the rolling variance of an imw-object.
variance(x, ...)variance(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1 and 2 corresponding to the population and sample variance, respectively.
The estimated rolling variance.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) variance(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) variance(mw)
Returns the rolling variance of an imw-object.
## S3 method for class 'imw' variance(x, ...)## S3 method for class 'imw' variance(x, ...)
x |
An imw-object. |
... |
Additional arguments, see details. |
The only additional argument is type which takes the values 1 and 2 corresponding to the population and sample variance, respectively.
The estimated rolling variance.
N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) variance(mw)N <- 100 x <- cumsum(rnorm(N)) k <- 10 mw <- imw(x, k) variance(mw)