How to calculate p-value for Mutual Information in FNN package

215 Views Asked by At

I have two columns data where I want to calculate the correlation from mutinfo() in FNN package in R (https://www.rdocumentation.org/packages/FNN/versions/1.1.3.1/topics/mutinfo) and then calculate the p-value. How can I calculate the p-value after using mutinfo() in R? Thanks for your help in advance.

1

There are 1 best solutions below

4
Quinten On

You could use the bootstrapMI function from the maigesPack packages:

This function takes a numerical matrix (or two vectors) and calculates bootstrapped (by permutation) p-values to test if the mutual information value is equal to zero. If the first argument is a matrix, the p-values are calculated between all pairs of rows of the matrix.

Here a reproducible example:

#BiocManager::install("maigesPack")
library(maigesPack)
library(FNN)
set.seed(1) # for reproducibility 
x <- runif(50, 0, 1)
y <- rbeta(50, 1, 2)
mutinfo(x, y, k = 2)  
#> [1] 0.04406588
bootstrapMI(x, y, bRep=100, ret="p-value")
#> [1] 0.31

Created on 2022-07-28 by the reprex package (v2.0.1)