cmi: Compute the (conditional) mutual information between two...

View source: R/data-statistics.R

cmiR Documentation

Compute the (conditional) mutual information between two variables.

Description

Computes the (conditional) mutual information between two variables. If z is not NULL then returns the conditional mutual information, I(X;Y|Z). Otherwise, returns mutual information, I(X;Y).

Usage

cmi(x, y, dataset, z = NULL, unit = "log")

Arguments

x

A length one character.

y

A length one character.

dataset

A data frame. Must contain x, y and, optionally, z columns.

z

A character vector.

unit

A character. Logarithm base. See entropy package.

Details

I(X;Y|Z) = H(X|Z) + H(Y|Z) - H(X,Y,Z) - H(Z), where H() is Shannon's entropy.

Examples

data(car)
cmi('maint', 'class', car)

bmihaljevic/bnclassify documentation built on March 18, 2024, 8:34 a.m.