I am interested in calculating the strength between random variables. I found that the maximal information coefficient is one of the good methods to use and it is robust to the mutual information method. However, I need to calculate the conditional maximal information coefficient. However, based on my search, I found nothing regarding the maximal information coefficient. Is there is an R package that can do this calculation? or any published article regarding this point?
1 Answer
$\begingroup$
$\endgroup$
4
Mutual information is well known, sklearn has a good implementation here and in R package entropy.
Regarding MIC, MICtools and minerva are Python/R good implementations. See references given in MICtools repo description for further papers.
Edit
: This is a dummy example how to compute MIC score for $x$ and $y$ conditionally given that $z=1$.
from minepy import MINE
import numpy as np
mine = MINE(alpha=0.6, c=15)
np.random.seed(42)
x = np.random.random(100)
y = np.random.random(100)
z = np.random.binomial(1, 0.5, 100)
condition_z_is_one = np.where(z > 0)[0]
mine.compute_score(x[condition_z_is_one],
y[condition_z_is_one])
mic_score = mine.mic() # 0.21421355042023246
-
$\begingroup$ Thanks a lot for your help. It is appreciated. However, these packages did not count for conditional (the strength between
x
andy
givenz
. $\endgroup$– MaryamJun 21, 2021 at 9:55 -
4$\begingroup$ You could condition
x
andy
simultaneously given set ofz
values, before passing to these implementations. Meaning we use the subset ofx
andy
givenz
condition. $\endgroup$ Jun 21, 2021 at 9:59 -
2$\begingroup$ Could you please show me an example to do so and update your answer in order to accept it? As my problem is within the conditional case. $\endgroup$– MaryamJun 21, 2021 at 11:26
-
$\begingroup$ @Maryam One dummy example is added using
minepy
but usingmictools
is recommended for production. $\endgroup$ Jun 21, 2021 at 15:33