View source: R/wilcoxon_test_b.R
| wilcoxon_test_b | R Documentation |
Bayesian Wilcoxon Rank Sum (aka Mann-Whitney U) and Signed Rank Analyses
wilcoxon_test_b(
x,
y,
paired = FALSE,
p = 0.5,
ROPE,
prior = "centered",
prior_shapes,
CI_level = 0.95,
plot = TRUE,
seed = 1
)
x |
numeric vector of data values. Non-finite (e.g., infinite or missing) values will be omitted. |
y |
an optional numeric vector of data values: as with x non-finite values will be omitted. |
paired |
if |
p |
numeric.
|
ROPE |
If a single number, ROPE will be |
prior |
Prior used on the probability that x > y. Either "uniform" (Beta(1,1)), or "centered" (Beta(2,2)). This is ignored if prior_shapes is provided. |
prior_shapes |
Vector of length two, giving the shape parameters for the beta distribution that will act as the prior on the population proportions. |
CI_level |
The posterior probability to be contained in the credible interval. |
plot |
logical. Should a plot be shown? |
seed |
Always set your seed! (Unused for |
Bayesian Wilcoxon signed rank analysis For a single input vector or paired data, the Bayesian signed rank analysis will be performed. The estimand is the proportion of (differenced) values that are positive. For more information, see dfba_wilcoxon and vignette("dfba_wilcoxon",package = "DFBA").
Bayesian Wilcoxon rank sum/Mann-Whitney analysis
For unpaired x and y inputs, the Bayesian rank sum analysis will be performed.
The estimand is \Omega_x:=\lim_{n\to\infty} \frac{U_x}{U_x + U_y}, where
U_x is the number of pairs (i,j) such that x_i > y_j, and
vice versa for U_y. That is, it is the population proportion of all
untied pairs for which x > y. Larger values imply that x is
stochastically larger than y. For more information, see dfba_mann_whitney
and vignette("dfba_mann_whitney",package = "DFBA").
(returned invisible) If signed rank analysis is implemented, a list with the following:
posterior_mean: Posterior mean of the proportion of differences that are positive
CI: Credible interval of the proportion of differences that
are positive
Pr_less_than_p: Probability proportion of differences that are
positive is less than the argument p
Pr_in_ROPE: Probability proportion of differences that are
positive is in the ROPE
prob_plot: Prior and posterior plot of differences that are
positive
posterior_parameters: Posterior beta shape parameters for the
proportion of differences that are positive
BF_for_phi_gr_onehalf_vs_phi_less_onehalf: Bayes factor giving
evidence in favor of the proportion of differences that are positive being
greater than one half vs. less than one half
dfba_wilcoxon_object: Underlying DFBA object
If rank sum analysis is implemented, a list with the following:
posterior_mean: Posterior mean of \Omega_x (see details)
CI: Credible interval for \Omega_x
Pr_less_than_p: Posterior probability \Omega_x is less
than the argument p
Pr_in_ROPE: Probability \Omega_x is in the ROPE
prob_plot: Prior and posterior plot of \Omega_x
posterior_parameters: Posterior beta shape parameters for
\Omega_x
BF_for_Omegax_gr_onehalf_vs_Omegax_less_onehalf: Bayes factor
in favor of \Omega_x being greater than one half vs. less than one
half
dfba_wilcoxon_object: Underlying DFBA object
Chechile, R.A. (2020). Bayesian Statistics for Experimental Scientists: A General Introduction to Distribution-Free Methods. Cambridge: MIT Press.
Chechile, R. A. (2018) A Bayesian analysis for the Wilcoxon signed-rank statistic. Communications in Statistics - Theory and Methods, https://doi.org/10.1080/03610926.2017.1388402
Chechile, R.A. (2020). A Bayesian analysis for the Mann-Whitney statistic. Communications in Statistics – Theory and Methods 49(3): 670-696. https://doi.org/10.1080/03610926.2018.1549247.
Barch DH, Chechile RA (2023). DFBA: Distribution-Free Bayesian Analysis. doi:10.32614/CRAN.package.DFBA
# Signed rank analysis
## Generate data
N = 150
set.seed(2025)
test_data =
data.frame(x = rbeta(N,2,10),
y = rbeta(N,5,10))
## input differenced data
wilcoxon_test_b(test_data$x - test_data$y)
## input paired data vectors individually
wilcoxon_test_b(test_data$x,
test_data$y,
paired = TRUE)
## Use different priors
wilcoxon_test_b(test_data$x - test_data$y,
prior = "uniform")
wilcoxon_test_b(test_data$x - test_data$y,
prior_shapes = c(5,5))
## Change ROPE bounds
wilcoxon_test_b(test_data$x - test_data$y,
ROPE = 0.1)
# Rank sum analysis
## Generate data
set.seed(2025)
N = 150
x = rbeta(N,2,10)
y = rbeta(N + 1,5,10)
## Perform analysis
wilcoxon_test_b(x,y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.