Português

Sign test

Ranks (nonparametric) · One sample · reference distribution: Binomial(n, ½)

When to use it

Test the median of a sample without assuming anything about the shape of the distribution; it only uses whether each value is above or below.

Null hypothesis

The population median equals m₀.

Assumptions

Test statistic

S = \#\{\, x_i > m_0 \,\} \sim \text{Bin}\left(n, \tfrac{1}{2}\right)

Effect size

Cohen’s g: how far the proportion of positive signs is from ½.

g = \hat{p} - \tfrac{1}{2}

How to report it

15 of 20 above the reference value, sign test p = .041

In R and Python

R
binom.test(sum(x > m0), sum(x != m0), p = 0.5)
Python
stats.binomtest(int((x > m0).sum()), int((x != m0).sum()), p=0.5)

In Python, stats is scipy.stats and np is numpy.

Variants and alternatives

Where it sits in the catalog

Ranks (nonparametric). Nonparametric tests assume no distribution for the data. They replace each value by its rank, its position in order (1st, 2nd, 3rd…), which protects them from extreme values and makes them fit ordinal data.

One sample. A single group compared with a reference value set in advance, such as a target or a standard.

In the decision tree

  1. What do you want to do? Compare groups, or one group with a reference value
  2. What kind of response did you measure? Numeric: a measurement, such as weight, time or score
  3. How many groups or measurements? One group, against a reference value
  4. Are the data approximately normal, or is the sample large (n ≳ 30)? No
  1. What do you want to do? Compare groups, or one group with a reference value
  2. What kind of response did you measure? Numeric: a measurement, such as weight, time or score
  3. How many groups or measurements? Two groups
  4. Are the groups made of different individuals or the same individuals? The same individuals, such as before and after (paired)
  5. Are the differences between pairs approximately normal? No, and not symmetric either

Open the decision tree