Description Usage Arguments Details Value Examples
This function calculates MI and BCMI between a set of discrete variables held as columns in a matrix. It also performs jackknife bias correction and provides a z-score for the hypothesis of no association. Also included are the *.pw functions that calculate MI between two vectors only. The *njk functions do not perform the jackknife and are therefore faster.
1 2 3 4 |
dmat |
The data matrix. Each row is an observation and each column is a variable of interest. Should contain categorical data, all types of data will be coerced via factors to integers. |
disc1 |
A vector for the pairwise version |
disc2 |
A vector for the pairwise version |
The results of dmi() are in many ways similar to a correlation matrix, with each row and column index corresponding to a given variable. dminjk() and dminjk.pw() just returns the MI values without performing the jackknife. The number of processor cores used can be changed by setting the environment variable "OMP_NUM_THREADS" before starting R.
Returns a list of 3 matrices each of size ncol(dmat)
by
ncol(dmat)
mi |
The raw MI estimates. |
bcmi |
Jackknife bias corrected MI estimates (BCMI). These are each MI value minus the corresponding jackknife estimate of bias. |
zvalues |
Z-scores for each hypothesis that the corresponding bcmi value is zero. These have poor statistical properties but can be useful as a rough measure of the strength of association. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | data(cars)
# Discretise the data first
d <- cut(cars$dist, breaks = 10)
s <- cut(cars$speed, breaks = 10)
# Discrete MI values
dmi.pw(s, d)
# For comparison, analysed as continuous data:
cmi.pw(cars$dist, cars$speed)
# Exploring a group of categorical variables
dat <- mtcars[, c("cyl","vs","am","gear","carb")]
discresults <- dmi(dat)
discresults
# Plot the relative magnitude of the BCMI values
diag(discresults$bcmi) <- NA
mp(discresults$bcmi)
|
Loading required package: KernSmooth
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
$mi
[1] 0.9364109
$bcmi
[1] 0.6903589
$zvalue
[1] 4.949755
$mi
[1] 0.4390146
$bcmi
[1] 0.424862
$zvalue
[1] 4.923533
$mi
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0612040 0.43120940 0.14523133 0.3634430 0.5097002
[2,] 0.4312094 0.68531421 0.01417347 0.2036022 0.3123300
[3,] 0.1452313 0.01417347 0.67546458 0.4367718 0.1248672
[4,] 0.3634430 0.20360224 0.43677177 1.0130227 0.2391776
[5,] 0.5097002 0.31232996 0.12486719 0.2391776 1.4979575
$bcmi
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0939730 0.397633050 0.105802510 0.2755075 0.48789448
[2,] 0.3976330 0.701457431 -0.003241008 0.1510687 0.29175135
[3,] 0.1058025 -0.003241008 0.691622603 0.4355686 0.08710974
[4,] 0.2755075 0.151068658 0.435568574 1.0460800 0.16759348
[5,] 0.4878945 0.291751354 0.087109744 0.1675935 1.61116674
$zvalues
[,1] [,2] [,3] [,4] [,5]
[1,] 21.798246 3.3933783 1.0582216 2.244308 7.474051
[2,] 3.393378 30.3263950 -0.1011464 1.223818 3.409049
[3,] 1.058222 -0.1011464 19.9920905 5.522984 1.381430
[4,] 2.244308 1.2238177 5.5229835 14.478527 1.583226
[5,] 7.474051 3.4090490 1.3814296 1.583226 10.791836
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.