R/statistical_tests_and_estimates.R
two_samp_cont_test.Rd
Either Wilcox or T-Test Performed, for unpaired or paired data
two_samp_cont_test(x, y, method = c("wilcox", "t.test"), paired = FALSE, verbose = FALSE, ...)
x | numeric vector (can include NA values). |
---|---|
y | vector with only 2 levels (can include NA values unless |
method | what test to run (wilcox or t-test). |
paired | a logical indicating whether you want a paired test. |
verbose | a logical variable indicating if warnings and messages should be displayed. |
... | parameters to pass to wilcox_test or t.test functions. For example the testing direction ( |
p-value for comparing x at the different levels of y.
Runs wilcox_test()
in the coin package, with "exact" distribution and mid-ranks ties method.
For one sided tests if y
is a factor variable the level order is respected, otherwise the levels will set to alphabetical order (i.e. if alternative = less
then testing a < b ).
If paired = TRUE
assumes the first observations of the first group matches the first observation of the second group, and so on. Also if paired = TRUE
then y
must have the same number of samples for each level.
set.seed(5432322) x <- c(rnorm(10,0,3), rnorm(10,3,3)) y <- c(rep('a', 10), rep('b', 10)) two_samp_cont_test(x = x, y = y, method = 'wilcox', paired = FALSE)#> [1] 0.01854338two_samp_cont_test(x = x, y = y, method = 'wilcox', paired = TRUE)#> [1] 0.06445312two_samp_cont_test(x = x, y = y, method = 't', paired = FALSE)#> [1] 0.01890551two_samp_cont_test(x = x, y = y, method = 't', paired = TRUE)#> [1] 0.03394079