mv | R Documentation |
Compute the statistics of mean variance (MV) index, which can measure the dependence between a univariate continuous variable and a categorical variable. See Cui, Li and Zhong (2015); Cui and Zhong (2019) for details.
mv(x, y, return_mat = FALSE)
x |
Data of univariate continuous variables, which should be a vector of
length |
y |
Data of categorical variables, which should be a factor of length
|
return_mat |
A boolean. If |
The value of the corresponding sample statistic.
If the argument return_mat
of mv()
is set as TRUE
, a list with
elements
mv
: the MV index statistic;
mat_x
: the matrices of the distances of the indicator for x <= x_i;
will be returned.
mv_test()
for implementing independence test via MV index;
mv_sis()
for implementing feature screening via MV index.
x <- mtcars[, "mpg"]
y <- factor(mtcars[, "am"])
print(mv(x, y))
# Man-made independent data -------------------------------------------------
n <- 30; R <- 5; prob <- rep(1/R, R)
x <- rnorm(n)
y <- factor(sample(1:R, size = n, replace = TRUE, prob = prob), levels = 1:R)
print(mv(x, y))
# Man-made functionally dependent data --------------------------------------
n <- 30; R <- 3
x <- rep(0, n)
x[1:10] <- 0.3; x[11:20] <- 0.2; x[21:30] <- -0.1
y <- factor(rep(1:3, each = 10))
print(mv(x, y))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.