mv_test | R Documentation |
Implement the MV independence test via permutation test, or via the asymptotic approximation
mv_test(x, y, test_type = "perm", num_perm = 10000)
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. |
A list with class "indtest"
containing the following components
method
: name of the test;
name_data
: names of the x
and y
;
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 values crit_vals
for 90%, 95% and 99% confidence levels.)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.