Learn R Programming

reproducer (version 0.6.0)

pairedRankTest: pairedRankTest

Description

Computes the exact paired rank test of Munzel and Brunner (2002) for two dependent (paired) samples. The test is based on the overall mid-ranks of all \(2n\) observations: for each pair it forms the rank difference \(D_k = 2 (R_{x,k} - R_{y,k})\) and derives the exact conditional null distribution of \(D^+ = \sum_{k: D_k > 0} D_k\) given the absolute differences \(|D_k|\) via the shift algorithm given in the appendix of the paper. The test is exact for small samples, robust to arbitrary ties, applicable to ordinal as well as metric data, and invariant under monotone transformations - precisely the situations in which the Wilcoxon signed rank test loses power. For larger samples method = "asymptotic" returns the t-distribution approximation of the standardized statistic (Conover and Iman 1981; Munzel 1999). The complementary unpaired relative effect is available via calculatePhat; the exact sign test for paired data is available via pairedSignTest.

Usage

pairedRankTest(
  x,
  y,
  alternative = c("two.sided", "greater", "less"),
  method = c("exact", "asymptotic")
)

Value

a list with components: T_R (the rank statistic \(T_R = \sum D_k\); a negative value indicates a decrease from y to x), Dplus

(\(D^+\)), Ds (\(D_s = \sum |D_k|\)), n (the number of non-missing pairs), phat (the paired relative effect \(P(X > Y) + 0.5 P(X = Y)\)), statistic (the standardized statistic for method = "asymptotic", else NA), p.value, method and alternative.

Arguments

x

a numeric vector of observations from the first condition (e.g., after).

y

a numeric vector of observations from the second condition (e.g., before), paired element-wise with x (so x[k] and y[k] belong to subject k).

alternative

a character string specifying the alternative hypothesis, one of "two.sided" (default), "greater" (x tends to exceed y) or "less".

method

a character string selecting "exact" (default; the exact conditional test via the shift algorithm) or "asymptotic" (the t-distribution approximation, useful for larger n).

Author

Lech Madeyski

References

Munzel, U. and Brunner, E. (2002). An Exact Paired Rank Test. Biometrical Journal 44(5), 558-569. doi:10.1002/1521-4036(200207)44:5<584::AID-BIMJ584>3.0.CO;2-9. Conover, W. J. and Iman, R. L. (1981). Rank transformations as a bridge between parametric and nonparametric statistics. The American Statistician 35, 124-129. Munzel, U. (1999). Nonparametric methods for paired samples. Statistica Neerlandica 53, 277-286.

Examples

Run this code
# Munzel and Brunner (2002) worked example: patient global impression (PGI) at
# baseline and after 4 weeks of physical exercise therapy for 15 patients.
res <- pairedRankTest(MunzelBrunner02.PGI$week4, MunzelBrunner02.PGI$baseline)
res$T_R      # -186 (PGI values decreased)
res$Dplus    # 29
res$p.value  # 0.010 (two-sided exact p-value reported in the paper)

Run the code above in your browser using DataLab