Rolling Skewness

Computes the rolling adjusted Fisher-Pearson skewness over a numeric vector. Requires at least 3 non-NA observations per window.

Usage

rolling_skewness(x, window_size, min_periods = window_size, method = "stable")

Parameters

Parameter

Description

x

A numeric vector of type double.

window_size

Positive integer window length.

min_periods

Minimum number of non-NA observations required in a window to return a result. Defaults to window_size.

method

"stable" (default) uses Terriberry’s online algorithm. "fast" uses a prefix-sum approach (faster, but susceptible to catastrophic cancellation when values are large and variance is small).

Returns

A numeric vector with rolling skewness values.

Examples

x <- as.double(c(1, 2, 3, 4, 5))
rolling_skewness(x, 3L)