Learn R Programming

rinform (version 1.0.2)

mutual_info: Mutual Information

Description

Compute the average or the local mutual information between two or more time series. Each variable can have a different base.

Usage

mutual_info(series, local = FALSE)

Arguments

series

Matrix specifying a set of time series.

local

Boolean specifying whether to compute the local mutual information.

Value

Numeric giving the average mutual information or a vector giving the local mutual information.

Examples

Run this code
# NOT RUN {
series      <- matrix(0, nrow = 20, ncol = 2)
series[, 1] <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1)
series[, 2] <- c(0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1)
mutual_info(series)    # 0.2141709

# [1] -1.0, -1.0, 0.2223924, 0.2223924, 0.2223924, 0.2223924, 0.2223924,
#     0.2223924, 0.2223924, 0.2223924, 0.2223924, 0.2223924, 0.2223924, 0.2223922,
#     0.2223924, 0.2223924, 1.5849625, 1.5849625, 1.5849625, -1.5849625
mutual_info(series, local = TRUE)
# }

Run the code above in your browser using DataLab