Learn R Programming

codyna (version 0.1.0)

complexity: Calculate Dynamic Complexity Measures for Time-Series Data

Description

Computes dynamic complexity and other rolling window measures for univariate time series data.

Usage

complexity(data, measures = "complexity", window = 7L, align = "center")

Value

A tibble with the time index, the original time-series data, and the calculated measures.

Arguments

data

[ts, numeric()]
Univariate time series data.

measures

[character()]
A vector of measures to calculate. See 'Details' for more information on the available measures.

window

[integer(1)]
A positive integer specifying the rolling window size. Must be at least 2 (default: 7).

align

[character(1)]
Alignment of the window. The available options are: "center" (default), "right", and "left". The calculated measure is assigned to the center, rightmost, or leftmost point of the window, respectively.

Details

The following measures can be calculated:

  • "complexity": Product of fluctuation and distribution measures.

  • "fluctuation": Root mean square of successive differences.

  • "distribution": Deviation from uniform distribution.

  • "autocorrelation": Lag-1 autocorrelation coefficient.

  • "max": Rolling maximum.

  • "min": Rolling minimum.

  • "variance": Rolling variance.

The option "all" computes all of the above.

Examples

Run this code
set.seed(123)
ts_data <- stats::arima.sim(list(order = c(1, 1, 0), ar = 0.6), n = 200)

# Single measure
comp_single <- complexity(ts_data, measures = "complexity")

# Multiple measures
comp_multi <- complexity(ts_data, measures = c("complexity", "variance"))

Run the code above in your browser using DataLab