MyNixOS website logo
Description

Computes Values for the 1-Sample Wilcoxon Sign Rank Test for Medians.

An implementation of the 1-Sample Wilcoxon Sign rank test for medians. It includes 2 functions, W_stat(), which computes the exact probabilities of the Wilcoxon Sign Rank Test Statistic, W. The second function, Wilcox.m.test() allows the user to conduct the 1-Sample Wilcoxon Sign Rank hypothesis test for medians, this also allows the user to conduct the hypothesis test for the normal approximation, based on the techniques of Bickel and Doksum (1973, ISBN:013850363X).

wilcoxmed

The Implementation of the 1-Sample Wilcoxon Signed Rank Hypothesis Test for medians - allows breaking of ties, computation of the Wilcoxon Test Statistic with normal approximations.

We refer to the Wilcoxon Sign Ranked hypothesis test for medians for the one-sample problem.

Given that X1, X2, …, Xn ∼ F. Assume that F is unknown except that it is continuous and symmetric. We wish to test H0 : m = m0 against H1 : m > m0 at the significance level α

Let Ri = (signed rank of Xi − m0) The test statistic is ∑Ri , or equivalently W = ∑Ri/2 + n(n + 1)/4

We reject H0 iff p-value = P(W ≥ wobs|H0) < α

For this problem, there could be ties in the data, however the algorithm is able to break the ties by assigning the average absolute rank to each tied value. The exact distribution of W is taken from Bickel and Doksum (1973).

The normal approximations to W can be found via the following theorem:

Theorem: If X1, X2, …, Xn ∼ F, F is continuous, then as n → ∞, we have:

W ∼ N(n(n + 1)/4n(n + 1)(2n + 1)/24)

Example

Given some data: X ∈ {3, 4, 7, 10, 12, 1, 9, 2, 15}: We wish to test H0 : m = 5 against H1 : m > 5 at the significance level α = 0.05 without using normal approximation:

vec = c(3, 4, 7, 10, 4, 12, 1, 9, 2, 15)

res = wilcoxmed::Wilcox.m.test(dat = vec, m_h0 = 5, alternative = 'greater',
                               normal_approx = F)
#> 
#>                      1-Sample Median Wilcoxon Sign-Rank Test 
#>  
#>                                     Ties Broken = 3 
#>  
#>            Null hypothesis H_0: m = 5      Alternative Hypothesis H_1: m > 5 
#>  
#>            Test Statistic W = 37      p-value =  0.1875      alpha = 0.05 
#>  
#>                          Test Result: Do not Reject H_0 
#> 

If we want to apply the normal approximation(Z-test), with the same hypotheses:

res = wilcoxmed::Wilcox.m.test(dat = vec, m_h0 = 5, alternative = 'greater',
                               normal_approx = T)
#> 
#>             1-Sample Median Wilcoxon Sign-Rank Test - Normal Approximation 
#>  
#>                                     Ties Broken = 3 
#>  
#>            Null hypothesis H_0: m = 5      Alternative Hypothesis H_1: m > 5 
#>  
#>            Test Statistic Z = 0.9683297      p-value =  0.1664399      alpha = 0.05 
#>  
#>                          Test Result: Do not Reject H_0 
#> 

To find the exact probabilities of the Wilcoxon sign distribution:

To find P(W ≤ 3) for n = 5:

wilcoxmed::W_stat(n=5, test_stat = 3, side = 'leq')
#> [1] 0.15625
Metadata

Version

0.0.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows