| test.bm | R Documentation |
This function performs two-sample and paired-sample (Permuted) Brunner-Munzel test (Brunner & Munzel, 2000) using either a t-distribution with a Satterthwaite-Welch degrees of freedom approximation, an exact permutation test, or a randomization test (Neubert & Brunner, 2007).
test.bm(...)
## Default S3 method:
test.bm(data = NULL, ..., x = NULL, y = NULL, paired = FALSE,
method = c("t", "logit", "perm"), alternative = c("two.sided", "less", "greater"),
scale = c("prob", "diff", "logodds", "odds"), hypo = FALSE, descript = TRUE,
conf.level = 0.95, nperm = 10000, seed = 42, digits = 3, p.digits = 3,
as.na = NULL, write = NULL, append = TRUE, check = TRUE, output = TRUE)
## S3 method for class 'formula'
test.bm(formula, data, method = c("t", "logit", "perm"),
alternative = c("two.sided", "less", "greater"),
scale = c("prob", "diff", "logodds", "odds"), hypo = FALSE, descript = TRUE,
conf.level = 0.95, p.adj = "none", nperm = 10000, seed = 42, na.omit = FALSE,
digits = 3, p.digits = 3, as.na = NULL, write = NULL, append = TRUE,
check = TRUE, output = TRUE, ...)
data |
a data frame. Note that data are specified either by using
the argument |
... |
an expression indicating the variable names in |
x |
a numeric vector of data values. |
y |
a numeric vector of data values. |
formula |
in case of two sample Brunner-Munzel test (i.e., |
paired |
logical: if |
method |
a character string indicating the method used for statistical
significance testing, i.e., |
alternative |
a character string specifying the alternative hypothesis,
must be one of |
scale |
a character string indicating the scale of the reported
estimated and confidence interval, i.e., |
hypo |
logical: if |
descript |
logical: if |
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
p.adj |
a character string indicating an adjustment method for multiple
testing based on |
nperm |
a numeric value (default: 10000) indicating the maximum
number of permutations used when |
seed |
a numeric value specifying the seed of the pseudo-random numbers used when drawing permutation samples. |
na.omit |
logical: if |
digits |
an integer value indicating the number of decimal .places to be used for displaying descriptive statistics and confidence interval. |
p.digits |
an integer value indicating the number of decimal .places to be used for displaying the p-value. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
Returns an object of class misty.object, which is a list with following
entries:
call |
function call |
type |
type of analysis |
sample |
type of sample, i.e., two- or paired sample |
formula |
formula |
data |
data frame with the outcome and grouping variable |
args |
specification of function arguments |
result |
result table |
This function is based on the brunner_munzel() and ses_calc()
function in the TOSTER package by Daniel Lakens and Aaron Caldwell.
Takuya Yanagida takuya.yanagida@univie.ac.at
Schüürhuis, S., Konietschke, F., & Brunner, E. (2025). A New Approach to the nonparametric Behrens-Fisher problem With compatible confidence iIntervals. Biometrical Journal, 67(6), e70096. https://doi.org/10.1002/bimj.70096
Karch, J. D. (2021). Psychologists should use Brunner-Munzel’s instead of Mann-Whitney’s U Test as the default nonparametric procedure. Advances in Methods and Practices in Psychological Science, 4(2). https://doi.org/10.1177/2515245921999
Neubert, K., & Brunner, E. (2007). A studentized permutation test for the non-parametric Behrens-Fisher problem. Computational Statistics & Data Analysis, 51(10), 5192–5204. https://doi.org/10.1016/j.csda.2006.05.024
test.t, test.welch, test.z
#————————————————————————————————————————————————————————————————————————————
# Two-Sample Design
# Example 1a: Two-sided two-sample Brunner-Munzel test
test.bm(mpg ~ vs, data = mtcars)
# Example 1b: Alternative specification without using the '...' argument
test.bm(x = df.subset(mtcars, mpg, subset = vs == 0),
y = df.subset(mtcars, mpg, subset = vs == 1))
# Example 1c: Two-sided two-sample Brunner-Munzel randomization test
# Sample of 10000 out of choose(32, 18) = 471435600 permutations
test.bm(mpg ~ vs, data = mtcars, method = "perm")
# Example 1d: Two-sided two-sample Brunner-Munzel permutation test
# Complete permutation of choose(13, 8) = 1287 permutations
test.bm(x = c(3, 1, 4, 2, 5, 3, 6, 7), y = c(5, 2, 4, 3, 1), method = "perm")
# Example 1e: One-sided two-sample Brunner-Munzel test
test.bm(mpg ~ vs, data = mtcars, alternative = "greater")
# Example 1f: Multiple two-sample Brunner-Munzel tests
test.bm(cbind(mpg, cyl, disp, hp, drat, wt) ~ vs, data = mtcars)
# Example 1g: Multiple two-sample Brunner-Munzel tests, bonferroni correction
test.bm(cbind(mpg, cyl, disp, hp, drat, wt) ~ vs, data = mtcars, p.adj = "bonferroni")
#————————————————————————————————————————————————————————————————————————————
# Paired-Sample Design
# Example 2a: Two-sided paired-sample Brunner-Munzel test
test.bm(mtcars, drat, wt, paired = TRUE)
# Example 2b: Alternative specification without using the '...' argument
test.bm(mtcars[, c("drat", "wt")], paired = TRUE)
# Example 2c: Alternative specification without using the '...' argument
test.bm(x = mtcars$drat, y = mtcars$wt, paired = TRUE)
# Example 2d: Two-sided paired-sample Brunner-Munzel test with logit transformation
test.bm(mtcars, drat, wt, paired = TRUE, method = "logit")
## Not run:
#————————————————————————————————————————————————————————————————————————————
# Write Results
# Example 3a: Write results into a text file
test.bm(mpg ~ vs, data = mtcars, write = "BM-Test.txt")
# Example 3b: Write results into an Excel file
test.bm(mpg ~ vs, data = mtcars, write = "BM-Test.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.