Chapter 4 Sign Test

4.1 Usage

4.2 Procedure

4.2.1 Hypothesis

\(H_{o}: F(x)=1-F(-x)\) \(H_{a}: F(x) \leq 1-F(-x)\) or \(H_{a}: F(x) \geq 1-F(-x)\)

4.2.2 Test statistic

  • \(\mathrm{SN}_{+}\) is the number of observations greater than 0
  • If \(\mathrm{H}_{\mathrm{o}}\) is true, then the distribution of \(\mathrm{SN}_{+}\) is:
    • \(SN_+ \sim \text{Binom}(n, 0.5)\) or
    • \(SN_+ \sim N(0.5 n, \sqrt{0.25 n})\) for large enough samples

4.2.3 p value

\[ P_{\text {upper tail}}=P(SN_+ \geq SN_{+,obs})\\ P_{\text {lower tail}}=P(SN_+ \leq SN_{+,obs}) \]

4.3 Code

4.3 R

library(stats)

before  <- c(1180, 1210, 1300, 1080, 1120, 1240, 1360, 980)
after <- c(1230, 1280, 1310, 1140, 1150, 1200, 1340, 1100)

diff <- after - before
n <- length(diff)
SN <- length(diff[diff > 0])

1 - pbinom(SN, n, 0.5)

4.3 Python

# under construction