Usage of brunnermunzel package

Toshiaki Ara

2019-05-31

Introduction

This brunnermunzel package is to perform (permuted) Brunner-Munzel test for stochastic equality of two samples, which is also known as the Generalized Wilcoxon test.

For Brunner-Munzel test (Brunner and Munzel 2000), brunner.munzel.test function in lawstat package is very famous. This function is extended to enable to use formula, matrix, and table as an argument.

Also, the function brunnermunzel.permutation.test for permuted Brunner-Munzel test (Neubert and Brunner 2007) was provided.

Usage of functions in brunnermunzel package

Default and Formula class

Sample data

In this section, we will use sample data from Hollander & Wolfe (1973), 29f. – Hamilton depression scale factor measurements in 9 patients with mixed anxiety and depression, taken at the first (x) and second (y) visit after initiation of a therapy (administration of a tranquilizer)".

For formula interface, data was converted to data.frame.

#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang

Analysis

analysis with permuted Brunner-Munzel test

To perform permuted Brunner-Munzel test, use brunnermunzel.test with “perm = TRUE” option, or brunnermunzel.permutation.test function. This “perm” option is used in also formula interface, matrix, and table.

When perm is TRUE, brunnermunzel.test calls brunnermunzel.permutation.test in internal.

Because statistics in all combinations are calculated in permuted Brunner-Munzel test (\({}_{n_{x}+n_{y}}C_{n_{x}}\) where \(n_{x}\) and \(n_{y}\) are sample size of \(x\) and \(y\), respectively), it takes a long time to obtain results.

Therefore, when sample size is too large [the number of combination is more than 40116600 (\(=\) choose(28, 14))], it switches to Brunner-Munzel test automatically.

using force option

When you want to perform permuted Brunner-Munzel test regardless sample size, you add “force = TRUE” option to brunnermunzel.permutation test.

using alternative option

brunnermunzel.test also can use “alternative” option as well as t.test and wilcox.test functions.

To test whether the average rank of group \(x\) is greater than that of group \(y\), alternative = "greater" option is added. In contrast, to test whether the average rank of group \(x\) is lesser than that of group \(y\), alternative = "less" option is added.

The results of Brunner-Munzel test and Wilcoxon sum-rank test (Mann-Whitney test) with alternative = "greater" option are shown. In this case, median of \(x\) is 1.68, and median of \(y\) is 1.06.

When using formula, brunnermunzel.test with alternative = "greater" option tests an alternative hypothesis “1st level is greater than 2nd level”.

In contrast, brunnermunzel.test with alternative = "less" option tests an alternative hypothesis “1st level is lesser than 2nd level”.

Matrix and Table class

In some case, data is provided as aggregated table. Both brunnermunzel.test and brunnermunzel.permutation.test accept data of matirix and table class.

Fictional data
Normal Moderate Severe
A 5 3 2
B 1 3 6

About program

brunnermunzel.test function

brunnermunzel.test function is derived from brunner.munzel.test function in lawstat package (Maintainer of this package is Vyacheslav Lyubchich; License is GPL-2 or GPL-3) with modification. The authors of this function are Wallace Hui, Yulia R. Gel, Joseph L. Gastwirth and Weiwen Miao.

combination subroutine by FORTRAN77

FORTRAN subroutine combination in combination.f is derived from the program by shikino (http://slpr.sakura.ne.jp/qp/combination)(CC-BY-4.0) with slight modification.

Without this subroutine, I could not make brunnermunzel.permutation.test. Thanks to shikono for your useful subroutine.

References

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

Neubert, K, and E Brunner. 2007. “A Studentized Permutation Test for the Non-Parametric Behrens-Fisher Problem.” Computational Statistics and Data Analysis 51 (10): 5192–5204.