mv_test {semidist} | R Documentation |
MV independence test
Description
Implement the MV independence test via permutation test, or via the asymptotic approximation
Usage
mv_test(x, y, test_type = "perm", num_perm = 10000)
Arguments
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
|
test_type |
Type of the test:
See the Reference for details. |
num_perm |
The number of replications in permutation test. |
Value
A list with class "indtest"
containing the following components
-
method
: name of the test; -
name_data
: names of thex
andy
; -
n
: sample size of the data; -
num_perm
: number of replications in permutation test; -
stat
: test statistic; -
pvalue
: computed p-value. (Notice: asymptotic test cannot return a p-value, but only the critical valuescrit_vals
for 90%, 95% and 99% confidence levels.)
Examples
x <- mtcars[, "mpg"]
y <- factor(mtcars[, "am"])
test <- mv_test(x, y)
print(test)
test_asym <- mv_test(x, y, test_type = "asym")
print(test_asym)
# 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)
test <- mv_test(x, y)
print(test)
test_asym <- mv_test(x, y, test_type = "asym")
print(test_asym)
# 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))
test <- mv_test(x, y)
print(test)
test_asym <- mv_test(x, y, test_type = "asym")
print(test_asym)