The function entropy
of package infotheo
takes the dataset as input and computes the entropy according to the entropy estimator method. For example:
data(USArrests)
H <- entropy(discretize(USArrests),method="shrink")
returns, for H, a value of 3.433987. But in this case data(USArrests)
is formed by 4 columns (variables), hence I think that it is not an entropy (which usually refers to a single variable) but a joint entropy. It is not explained in the package documentation. I tried to check the content of function entropy
but I obtained:
> infotheo::entropy
function (X, method = "emp")
{
X <- data.frame(X)
X <- data.matrix(X)
n <- NCOL(X)
N <- NROW(X)
Z <- na.omit(X)
if (!(all(Z == round(Z))))
stop("This method requires discrete values")
res <- NULL
if (method == "emp")
choi <- 0
else if (method == "mm")
choi <- 1
else if (method == "sg")
choi <- 2
else if (method == "shrink")
choi <- 3
else stop("unknown method")
res <- .Call("entropyR", X, N, n, choi, PACKAGE = "infotheo")
res
}
<bytecode: 0x000000000ae40c50>
<environment: namespace:infotheo>
From this code I can't understand how the result H has been computed.