*! version 1.0.0 15mar2024

Title

bmtest -- Two-sample Brunner-Munzel test

Syntax

bmtest varname [if] [in] , by(groupvar)
[ direction(string)
reverse
level(#) ]

* by(groupvar) grouping variable

direction(string) directional hypothesis. "lt" indicates that the first level of by() should be tested as being "less-than" the second level, "gt"
indicates that the first level of by() should be tested as being "greater-than" the second level, or "" (or not specifying direction() at all)
indicates a two-sided hypothesis

reverse reverse group order for the bmtest computation

level(#) set confidence level; default is level(95)

Description

bmtest implements the Brunner–Munzel test for two independent samples (Brunner & Munzel 2000; Neubert & Brunner 2007; Karch 2023) featuring fewer assumptions than the Wilcoxon–Mann–Whitney test (Karch 2023).

The Brunner–Munzel (BM) test produces a relative effect estimate of group affiliation on the outcome. In words, the relative effect p represents the
probability that a randomly selected individual from the second group will have a larger outcome than a randomly selected individual from the first group (Karch 2023).

The relative effect is computed as p = P(X1 < X2) + 0.5P(X1 = X2), where the probability of a tie is assigned with equal weight = 0.5 to both possibilities
(X1 smaller, and X2 smaller). If the relative effect is p = 0.5, groups 1 and 2 are deemed (stochastically) comparable, which is the null hypothesis of the BM
test. For two-sided testing, the alternative hypothesis is that HA : p ≠ 0.5, indicating that the groups are not comparable. For one-sided testing, the alternative
hypothesis can be either HA : p > 0.5, indicating that X1 tends to take smaller values, or HA : p < 0.5, indicating that X1 tends to take greater values (Karch 2023).

See Karch (2023) for a comprehensive, yet accessible, discsussion of the BM test.

Options

by(groupvar) is required. It specifies the name of the grouping variable.

direction(string) specifies a directional hypothesis. direction("lt") indicates that the first level of by() should be tested
as being "less-than" the second level, direction("gt") indicates that the first level of by() should be tested as being "greater-than" the
second level, or "" (or not specifying direction() at all) indicates a two-sided hypothesis.

reverse reverses the order of the groups defined in by(). For example, if X1 is initially ordered lower than X2, then the relative effect estimate will
correspond to p = P(X1 < X2) + 0.5P(X1 = X2). Conversely, when reverse is specified, X2 will be ordered lower than X1, providing a relative
effect estimate corresponding to p = P(X2 < X1) + 0.5P(X2 = X1).

level(#) specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level.

Examples

Load example data

. webuse fuel2, clear

Perform standard BM test

. bmtest mpg, by(treat)

Reverse order of the grouping variable treat

. bmtest mpg, by(treat) reverse

Set CI level to 99%

. bmtest mpg, by(treat) level(99)

Specify directional hypothesis that group 1 is < group 2

. bmtest mpg, by(treat) dir(lt)

Specify directional hypothesis that group 1 is > group 2

. bmtest mpg, by(treat) dir(gt)

Saved results

bmtest saves the following in r():

Scalars

r(coef) relative effect estimate

r(df) BM degrees of freedom

r(t) BM t statistic

r(p) p-value

r(ul) upper confidence limit

r(ll) lower confidence limit

r(n1) sample size of group 1

r(n2) sample size of group 2

References

Brunner, E. and U. Munzel. 2000. The Nonparametric Behrens-Fisher Problem: Asymptotic Theory and a Small-Sample Approximation.Biometrical Journal 42: 17–25.

Karch, J. D. 2023. bmtest: A Jamovi module for Brunner–Munzel's test — A robust alternative to Wilcoxon–Mann–Whitney's test. Psych 5: 386-395.

Neubert, K. and E Brunner. 2007. A Studentized permutation test for the non-parametric Behrens-Fisher problem. Computational Statistics and Data Analysis 51: 5192–5204.

Citation of bmtest

bmtest is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden, Ariel. 2024. bmtest: Stata module for computing the independent two-sample Brunner-Munzel test.

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Online: ranksum