mif: Mutual Information Function

View source: R/mrn.R

mifR Documentation

Mutual Information Function

Description

Calculate the lagged mutual information fucntion within (auto-mif) or between (cross-mif) time series, or, conditional on another time series (conditional-cross-mif). Alternatively, calculate the total information of a multivariate dataset for different lags.

Usage

mif(
  y,
  lags = -10:10,
  nbins = ceiling(2 * NROW(y)^(1/3)),
  doPlot = FALSE,
  surTest = FALSE,
  alpha = 0.05
)

Arguments

y

A Nx1 matrix for auto-mif, a Nx2 matrix or data frame for cross-mif, a Nx3 matrix or data frame for mif between col 1 and 2 conditional on col 3; or a NxM matrix or data frame for the multi-information function. Mutual information for each lag will be calculated using functions in package infotheo::infotheo() for lags lagged versions of the time series.

lags

The lags to evaluate mutual information.

nbins

The number of bins passed to infotheo::discretize() if y is a matrix or ts_discrete()

doPlot

Produce a plot of the symbolic time series by calling plotRED_mif() (default = FALSE)

surTest

If TRUE, a surrogate will be conducted using simple surrogates. The surrogates will be created from the transition probabilities of the discretised time series, i.e. the probability of observing bin j when the current value is in bin j. The number of surrogates needed will be computed based on the value of the alpha parameter, conceived as a one-sided test: mi > 0.

alpha

The alpha level for the surrogate test (default = 0.05)

Value

The auto- or cross-mi function

See Also

Other Redundancy measures (mutual information): mi_interlayer(), mi_mat()

Examples


# Lags to evaluate mututal information
lags <- -10:30

# Auto-mutual information
y1 <- sin(seq(0, 100, by = 1/8)*pi)

(mif(data.frame(y1),lags = lags))

# Cross-mututal information, y2 is a lagged version y1
y2 <- y1[10:801]

y <- data.frame(ts_trimfill(y1, y2, action = "trim.cut"))
(mif(y,lags = lags))

# Conditional mutual information, add some noise to y2 and add it as a 3rd column
y$s <- y2+rnorm(NROW(y2))
(mif(y,lags = lags))

# Multi-information, the information of the entire multivariate series at each lag
y$y3 <- cumsum(rnorm(NROW(y)))
(mif(y,lags = lags))



FredHasselman/casnet documentation built on April 20, 2024, 3:05 p.m.