5
$\begingroup$

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?

$\endgroup$

1 Answer 1

6
$\begingroup$

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
$\endgroup$
4
  • $\begingroup$ Thanks a lot for your help. It is appreciated. However, these packages did not count for conditional (the strength between x and y given z. $\endgroup$
    – Maryam
    Jun 21, 2021 at 9:55
  • 4
    $\begingroup$ You could condition x and y simultaneously given set of z values, before passing to these implementations. Meaning we use the subset of x and y given z 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$
    – Maryam
    Jun 21, 2021 at 11:26
  • $\begingroup$ @Maryam One dummy example is added using minepy but using mictools is recommended for production. $\endgroup$ Jun 21, 2021 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.