5日開催だったTokyo.Rの復習メモです。
minerva最新版は下記のコードで導入可能です。

library(devtools)
devtools::install_github("rsamantha/minerva")

パッケージ読み込み

library(minerva)
library(ggplot2)
library(dplyr)

データ作成

簡単のため一部のデータだけ抜き出します。

df_diamonds <- dplyr::select(diamonds, -c(cut, color, clarity, x, y ,z))

実行

MICなどを計算します。

mine(df_diamonds,n.cores=parallel::detectCores()-1)
## $MIC
##            carat      depth      table      price
## carat 0.99996344 0.03748058 0.04985743 0.85573707
## depth 0.03748058 0.99998111 0.09757874 0.03167688
## table 0.04985743 0.09757874 0.99588681 0.05550905
## price 0.85573707 0.03167688 0.05550905 0.99999994
## 
## $MAS
##            carat      depth      table      price
## carat 0.00000000 0.01333696 0.01570493 0.04133001
## depth 0.01333696 0.00000000 0.01045188 0.01625877
## table 0.01570493 0.01045188 0.00000000 0.02927883
## price 0.04133001 0.01625877 0.02927883 0.00000000
## 
## $MEV
##            carat      depth      table      price
## carat 0.99996344 0.03748058 0.04985743 0.85573707
## depth 0.03748058 0.99998111 0.09757874 0.03167688
## table 0.04985743 0.09757874 0.99242685 0.05550905
## price 0.85573707 0.03167688 0.05550905 0.99999988
## 
## $MCN
##          carat depth table    price
## carat 2.000000     2     2 2.584963
## depth 2.000000     2     2 2.000000
## table 2.000000     2     2 2.000000
## price 2.584963     2     2 2.000000
## 
## $MICR2
##               carat         depth        table         price
## carat -3.655853e-05  3.668397e-02  0.016872499  6.406542e-03
## depth  3.668397e-02 -1.888612e-05  0.010093808  3.156352e-02
## table  1.687250e-02  1.009381e-02 -0.004113188  3.934602e-02
## price  6.406542e-03  3.156352e-02  0.039346020 -6.405629e-08
## 
## $GMIC
##            carat      depth      table      price
## carat 0.99996344 0.03475929 0.04901089 0.85443084
## depth 0.03475929 0.99998111 0.09740849 0.02015813
## table 0.04901089 0.09740849 0.99588147 0.04154139
## price 0.85443084 0.02015813 0.04154139 0.99999994
## 
## $TIC
##            carat      depth      table      price
## carat 3244.72474   72.43284   90.95673 2204.06457
## depth   72.43284 3243.37417  208.39646   40.88738
## table   90.95673  208.39646 3075.12729   66.32348
## price 2204.06457   40.88738   66.32348 3246.99871

GMICやTICも合わせて計算されていることがわかります。 MICR2はMICとPearsonの相関係数との差分ですが、
数字の大きさからみるに、あまり大きな違いはなさそうです。

Diamonds dataにはあまり非線形っぽいデータが入っていないようなので、
もうちょっと面白いデータセットを使って試してみたいところです。