Function to calculate the mutual information of 2 random variables, or
between all pairs of rows of a numerical matrix.
Usage
MI(x, y=NULL, k=1)
Arguments
x
numerical matrix to calculate the MI between all pairs of
rows from x. Also, x must be a numerical vector and
y must be specified as another numerical vector of same
lenght as x and the MI value between both them are calculated.
y
optional numerical vector that must be specified if x
is a vector. Defaults to NULL.
k
integer specifying the number of the neighbours to be used in the
calculation of the MI value.
Details
This function implements an algorithm proposed by Kraskov et
al. (2004) that don't use estimator of the entropy.
Value
If x is a matrix, the function return a square matrix with
lenght equal to the number of rows of x with MI values between
all pairs of rows from x. If x is a numerical vector,
y must be specified and the function returns a positive real
number with the MI value between the two vectors.
x <- runif(50, 0, 1)
y <- rbeta(50, 1, 2)
MI(x, y)
z <- matrix(rnorm(100, 0, 1), 4, 25)
MI(z)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(maigesPack)
Loading required package: convert
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: limma
Attaching package: 'limma'
The following object is masked from 'package:BiocGenerics':
plotMA
Loading required package: marray
Loading required package: graph
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/maigesPack/MI.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MI
> ### Title: Calculate Mutual Information
> ### Aliases: MI
> ### Keywords: methods
>
> ### ** Examples
>
> x <- runif(50, 0, 1)
> y <- rbeta(50, 1, 2)
> MI(x, y)
[1] 1.65604
>
> z <- matrix(rnorm(100, 0, 1), 4, 25)
> MI(z)
[,1] [,2] [,3] [,4]
[1,] 3.198743 1.440810 1.290481 1.379366
[2,] 1.440810 3.198743 1.228886 1.433725
[3,] 1.290481 1.228886 3.198743 1.308517
[4,] 1.379366 1.433725 1.308517 3.198743
>
>
>
>
>
> dev.off()
null device
1
>