MWTest: Mann-Whitney U Test (Wilcoxon Rank-Sum, Manual Implementation)
Description
Performs the Mann-Whitney U test (Wilcoxon rank-sum) for two independent groups,
using a manual implementation. Suitable when the assumptions of parametric tests
(normality, homogeneity of variances) are not met.
An object of class "comparacion" and "mannwhitney", containing:
Resultados: A data frame with the comparison name, difference in means, p-value, and significance.
Promedios: A named numeric vector of group means.
Orden_Medias: A character vector of group names ordered from highest to lowest mean.
Metodo: A string describing the test and hypothesis direction.
Arguments
grupo1
Numeric vector for the first group.
grupo2
Numeric vector for the second group.
alpha
Significance level (default = 0.05).
alternative
Character string specifying the alternative hypothesis.
Options are "two.sided" (default), "less", or "greater".
continuity
Logical indicating whether to apply continuity correction (default = TRUE).
Details
Advantages:
- Does not assume normality.
- More powerful than t-test for skewed distributions.
Disadvantages:
- Only compares two groups at a time.
- Sensitive to unequal variances or shapes.
- It is only useful in completely random or single-factor designs.
This implementation allows one- or two-sided alternatives and optionally applies a continuity correction.
References
Mann, H. B., & Whitney, D. R. (1947). "On a Test of Whether One of Two Random Variables is Stochastically Larger than the Other." Annals of Mathematical Statistics, 18(1), 50–60.