Learn R Programming

Fast Mutual Information based independence Test (fastmit)

Introduction

The fundamental problem for data mining and statistical analysis is:

  • Whether two random variables are dependent?

fastmit package provides solutions for this issue. It implements the kNN method described by Kraskov, et. al (2004) to estimate the empirical mutual information and furthermore uses permutation test to detect whether two random variables are independent. The core functions in fastmit package are mi and mi.test.

These functions based on mutual information have two main advantages:

  • It's applicable to complex data in metric spaces.

  • It is faster than other statistics (e.g., distance covariance and ball covariance), which makes it advantageous in large sample situations.

Installation

CRAN version

You can install the released version of fastmit from CRAN with:

install.packages("fastmit")

Github version

You can install the released version of fastmit from GitHub with:

library(devtools)
install_github("Mamba413/fastmit/R-package")

Windows user will need to install Rtools first.

Example

  • mi function
## simulate data
set.seed(1)
x <- rnorm(100)
y <- x + rnorm(100)
## estimate the empirical mutual information
mi(x, y)

In this example, the result is:

# [1] 0.3320034
  • mi.test function
## simulate data
set.seed(1)
error <- runif(50, min = -0.3, max = 0.3)
x <- runif(50, 0, 4*pi)
y <- cos(x) + error

## perform independence test via mutual information
mi.test(x, y)

In this example, the result is:

	Mutual Information test of independence

data:  x and y
number of observations = 50
replicates = 99
p-value = 0.01
alternative hypothesis: random variables are dependent
sample estimates:
       MI 
0.6953105 

If you find any bugs, or if you experience any crashes, please report to us. Also, if you have any questions, feel free to ask.

License

GPL-3

Reference

  • Alexander Kraskov; Harald Stögbauer; Peter Grassberger

Phys. Estimating Mutual Information Rev. E 69, 066138

Copy Link

Version

Install

install.packages('fastmit')

Monthly Downloads

179

Version

0.1.1

License

GPL (>= 2)

Maintainer

Shiyun Lin

Last Published

December 30th, 2019

Functions in fastmit (0.1.1)

mi

kNN Mutual Information Estimators
mi.test

Mutual Information Test