mutual_info: Mutual information MI(X;Y) = H(X) - H(X|Y) = H(Y) - H(Y|X)

Description Usage Arguments Value Examples

View source: R/inftheo.R

Description

This calculates the mutual information between two variables in a tibble. (if normalized). It's assumed these columns are character typed with no NAs.

Usage

1
mutual_info(.data, ..., normalized = FALSE, na.rm = FALSE)

Arguments

.data

A tibble with the column of interest

...

two columns (variables) selected

normalized

if TRUE, scale from 0 to 1

na.rm

remove all rows with NA values in at least one of the columns

Value

a double with the calculated value

Examples

1
2
3
4
5
6
# make an all-character version of mtchars
mt_tib <- as_tibble(mtcars) %>% mutate_all(as.character)
mutual_info(mt_tib, vs, am)
mutual_info(mt_tib, 'am', 'vs')
mutual_info(mt_tib, vs, am, normalized=TRUE)
mutual_info(mt_tib, starts_with('c'))

tidyinftheo documentation built on Dec. 1, 2017, 1:01 a.m.