Description Usage Arguments Details Value Author(s) References See Also Examples
Calculates mutual information for k categorical variables.
1 |
variables |
Vector of variable names. |
data |
Data frame or matrix with the variables. |
smooth |
Additional cell counts for bayesian estimation of probabilities. |
log_base |
The base of the logarithmic function to be used. |
The mutual information for variables V1,…,Vk is calculated by the formula
MI(V1,…,Vk) = ∑ P(V1,…,Vk) log(P (V1,…,Vk) / (P(V1)… P(Vk)))
where the sum is over all possible values of V1,…,Vk.
If the function is used for two variables it corresponds to using
MI2
and for three variables it corresponds to MI3
.
The mutual information given by a single numeric value.
Katrine Kirkeby, enir_tak@hotmail.com
Maria Knudsen, mariaknudsen@hotmail.dk
Ninna Vihrs, ninnavihrs@hotmail.dk
EKTShyptcherry
MI2
and MI3
for mutual infomation for two
or three variables respectively.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | set.seed(43)
var1 <- c(sample(c(1, 2), 100, replace = TRUE))
var2 <- var1 + c(sample(c(1, 2), 100, replace = TRUE))
var3 <- var1 + c(sample(c(0, 1), 100, replace = TRUE,
prob = c(0.9, 0.1)))
var4 <- c(sample(c(1, 2), 100, replace = TRUE))
var5 <- var2 + var3
var6 <- var1 - var4 + c(sample(c(1, 2), 100, replace = TRUE))
var7 <- c(sample(c(1, 2), 100, replace = TRUE))
data <- data.frame("var1" = as.character(var1),
"var2" = as.character(var2),
"var3" = as.character(var3),
"var4" = as.character(var4),
"var5" = as.character(var5),
"var6" = as.character(var6),
"var7" = as.character(var7))
MIk(c("var1", "var2", "var7"), data, smooth = 0.001)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.