Sign in

Significance level

Significance level (alpha)

The threshold alpha set before a test: the probability of rejecting a true null hypothesis that you are willing to accept.

Overview

Every test can raise a false alarm, rejecting a null hypothesis that is in fact true. The significance level α\alpha is the rate of false alarms you agree to tolerate, chosen before looking at the data. It fixes a cutoff, the critical value: statistics beyond it are rare enough under the null that you reject. With α=0.05\alpha = 0.05, a true null is rejected in about 1 experiment in 20. That rate applies per test. Run many tests and the chance that at least one raises a false alarm climbs quickly, so α\alpha must be split across them. Bonferroni and Sidak are two standard ways to do the split.

A short history

Ronald Fisher proposed in 1925 that a result be called significant when its p-value falls below 0.05, about two standard deviations for a normal statistic, and treated this as a convenient guide. Jerzy Neyman and Egon Pearson made the level a formal design choice in 1933: alpha is fixed in advance as the accepted rate of false rejections. The convention of 0.05 has been questioned repeatedly, including a 2018 proposal to lower it to 0.005 for new discoveries.

How it works

  1. Choose α\alpha before collecting data, weighing the cost of a false alarm against the cost of a miss.
  2. If the test is one of a family of mm tests, adjust: Bonferroni uses α/m\alpha/m, Sidak uses 1−(1−α)1/m1-(1-\alpha)^{1/m}.
  3. Convert the adjusted level into critical values from the null distribution, zz or tt, in one tail or split over two.
  4. Reject when the statistic falls outside the critical values, or equally when the p-value is below the adjusted level.
  5. Check the rule by simulation: on data where the null is true, the share of rejections should be close to α\alpha.

Watch out for

  • Choosing α\alpha after seeing the p-value turns the test into a formality, because the threshold can always be moved to give the answer wanted.
  • The value 0.05 is a convention, not a law. A safety decision may need a stricter level and an exploratory screen a looser one.
  • Lowering α\alpha reduces false alarms but raises the miss rate at a fixed sample size, so a very strict level can make a real effect undetectable.
  • The Sidak formula and the family-wise rate 1−(1−α)m1-(1-\alpha)^m assume independent tests. Bonferroni holds under any dependence but is slightly more conservative.

Use cases

When to use it

Setting the decision rule for any hypothesis test, and adjusting that rule when several tests are run together so the overall false alarm rate stays where you set it.

In industry

Particle physics
Physicists require five standard deviations, a one sided level of about 3 in 10 million, before announcing a discovery such as the Higgs boson in 2012.
Clinical trials
Confirmatory drug trials conventionally use a two sided level of 0.05, which regulators treat as 0.025 in the favourable direction.
Genomics
Genome wide association studies use 5 times 10 to the minus 8, since about a million independent variants are tested.

Choosing it: what must hold

  • A choice made before the data are seen, and recorded.
  • A judgement of how costly a false alarm is compared with a missed effect.
  • A sample size planned so that the test still has adequate power at the chosen level.
  • Adjustment when several tests are run, so that the overall false alarm rate stays where you set it.

When to choose something else

IfUse instead
A false positive is very costly or many tests are runA stricter level, or a multiple comparison correction such as Bonferroni
You prefer to report strength of evidence over a pass or fail verdictThe exact p-value with a confidence interval
Costs of both error types can be stated explicitlyA decision analysis that weighs Type I and Type II errors

Math foundations

  1. Definition

    α=P(reject H0∣H0 true)\alpha = P(\text{reject } H_0 \mid H_0 \text{ true})

    The significance level is the probability of a Type I error, a false rejection. You choose it. The data do not determine it.

  2. Critical values

    two-sided: reject if ∣T∣>q1−α/2,greater: reject if T>q1−α,less: reject if T<qα\text{two-sided: reject if } \lvert T\rvert > q_{1-\alpha/2}, \qquad \text{greater: reject if } T > q_{1-\alpha}, \qquad \text{less: reject if } T < q_{\alpha}

    quq_u is the quantile of the null distribution with probability uu below it. A two-sided test splits α\alpha evenly between the tails. For the standard normal at α=0.05\alpha = 0.05 the cutoffs are ±1.96\pm 1.96 two-sided and 1.6451.645 one-sided.

  3. Family-wise error rate

    FWER=P(at least one false rejection)=1−(1−α)m\text{FWER} = P(\text{at least one false rejection}) = 1-(1-\alpha)^{m}

    For mm independent tests of true nulls, each at level α\alpha. Each test avoids a false alarm with probability 1−α1-\alpha, and all mm must avoid it for the family to be clean.

  4. Bonferroni correction

    αB=αm,FWER≤m αB=α\alpha_{\text{B}} = \frac{\alpha}{m}, \qquad \text{FWER} \le m\,\alpha_{\text{B}} = \alpha

    Test each hypothesis at α/m\alpha/m. The bound follows because the chance of a union of events is at most the sum of their chances, so it holds whether or not the tests are independent.

  5. Sidak correction

    αS=1−(1−α)1/m\alpha_{\text{S}} = 1-(1-\alpha)^{1/m}

    Solve the family-wise formula for the per-test level that makes the rate exactly α\alpha under independence. It is slightly larger than α/m\alpha/m, so slightly more powerful.

Symbols

α\alpha
significance level of one test, or the target rate for the family
H0H_0
the null hypothesis
TT
the test statistic
quq_u
quantile of the null distribution at probability u
mm
number of tests in the family, n_tests in the template
αB, αS\alpha_{\text{B}},\ \alpha_{\text{S}}
per-test level after Bonferroni or Sidak correction
FWER\text{FWER}
family-wise error rate

Worked by hand

Ten independent tests, each of a true null hypothesis, with a target of α=0.05\alpha = 0.05.

no correction: FWER=1−0.9510=1−0.5987=0.4013\text{no correction: } \text{FWER} = 1-0.95^{10} = 1-0.5987 = 0.4013
αB=0.0510=0.005,FWER=1−0.99510=0.0489\alpha_{\text{B}} = \frac{0.05}{10} = 0.005, \qquad \text{FWER} = 1-0.995^{10} = 0.0489
αS=1−0.951/10=0.00512,FWER=1−(1−0.00512)10=0.05\alpha_{\text{S}} = 1-0.95^{1/10} = 0.00512, \qquad \text{FWER} = 1-(1-0.00512)^{10} = 0.05

Without correction there is a 40% chance of at least one false alarm. Bonferroni brings it to 4.89%, a little under target, and Sidak to exactly 5%.

Visual example

Loading the example.

Try this

  • Slide α from 0.01 to 0.2 and count how many null experiments turn into false alarms.
  • Set the tests per study to 10 with no correction: about 40% of studies report something.
  • Now choose Bonferroni or Sidak and compare the two family rates with the target α.

Code sample

from impl import SignificanceLevel
from config import SignificanceLevelConfig

rule = SignificanceLevel(SignificanceLevelConfig(alpha=0.05, distribution="t", df=10))
print(rule.critical_values())          # (-2.228, 2.228)
print(rule.rejects(2.5), rule.decide(p_value=0.031))
many = SignificanceLevel(SignificanceLevelConfig(alpha=0.05, correction="bonferroni", n_tests=5))
print(many.adjusted_alpha(), many.familywise_error_rate())
Read the implementation (164 lines)
"""Significance level: what alpha means, the rejection region it defines, and how to share it across tests.

NumPy and the standard library only. Normal and Student t quantiles are computed in this file (the t
distribution through the regularized incomplete beta function, quantiles by bisection).
"""
from __future__ import annotations

import math

import numpy as np

try:
    from .config import SignificanceLevelConfig
except ImportError:  # run from the template's own folder
    from config import SignificanceLevelConfig

def _betacf(a: float, b: float, x: float) -> float:
    """Continued fraction of the incomplete beta function (modified Lentz method)."""
    tiny = 1e-300
    qab, qap, qam = a + b, a + 1.0, a - 1.0
    c = 1.0
    d = 1.0 - qab * x / qap
    d = 1.0 / (d if abs(d) > tiny else tiny)
    h = d
    for m in range(1, 2000):
        m2 = 2 * m
        for aa in (
            m * (b - m) * x / ((qam + m2) * (a + m2)),
            -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2)),
        ):
            d = 1.0 + aa * d
            d = 1.0 / (d if abs(d) > tiny else tiny)
            c = 1.0 + aa / c
            c = c if abs(c) > tiny else tiny
            delta = d * c
            h *= delta
        if abs(delta - 1.0) < 1e-15:
            break
    return h


def betainc(a: float, b: float, x: float) -> float:
    """Regularized incomplete beta function I_x(a, b), for a, b > 0 and 0 <= x <= 1."""
    if x <= 0.0:
        return 0.0
    if x >= 1.0:
        return 1.0
    front = math.exp(
        math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) + a * math.log(x) + b * math.log1p(-x)
    )
    if x < (a + 1.0) / (a + b + 2.0):
        return front * _betacf(a, b, x) / a
    return 1.0 - front * _betacf(b, a, 1.0 - x) / b

def norm_cdf(z: float) -> float:
    """P(Z <= z) for a standard normal Z."""
    return 0.5 * math.erfc(-z / math.sqrt(2.0))


def norm_sf(z: float) -> float:
    """P(Z > z) for a standard normal Z (the upper tail)."""
    return 0.5 * math.erfc(z / math.sqrt(2.0))

def t_cdf(t: float, df: float) -> float:
    """P(T <= t) for Student's t with `df` degrees of freedom."""
    tail = 0.5 * betainc(0.5 * df, 0.5, df / (df + t * t))
    return 1.0 - tail if t > 0 else tail


def t_sf(t: float, df: float) -> float:
    """P(T > t) for Student's t with `df` degrees of freedom."""
    return t_cdf(-t, df)

def _bisect(fn, lo: float, hi: float) -> float:
    """Root of the increasing function `fn` on [lo, hi], by bisection."""
    for _ in range(100):
        mid = 0.5 * (lo + hi)
        if fn(mid) < 0.0:
            lo = mid
        else:
            hi = mid
    return 0.5 * (lo + hi)

def norm_ppf(p: float) -> float:
    """Quantile of the standard normal: the z with P(Z <= z) = p, for 0 < p < 1."""
    if not 0.0 < p < 1.0:
        raise ValueError(f"p must be in (0, 1), got {p}")
    if p > 0.5:
        return -norm_ppf(1.0 - p)
    return _bisect(lambda z: norm_cdf(z) - p, -40.0, 0.0)

def t_ppf(p: float, df: float) -> float:
    """Quantile of Student's t: the t with P(T <= t) = p, for 0 < p < 1."""
    if not 0.0 < p < 1.0:
        raise ValueError(f"p must be in (0, 1), got {p}")
    if p > 0.5:
        return -t_ppf(1.0 - p, df)
    lo = -1.0
    while t_cdf(lo, df) > p:
        lo *= 2.0
    return _bisect(lambda t: t_cdf(t, df) - p, lo, 0.0)

class SignificanceLevel:
    """Turns alpha into a decision rule for a z or t statistic."""

    def __init__(self, config: SignificanceLevelConfig | None = None) -> None:
        self.config = config or SignificanceLevelConfig()

    def adjusted_alpha(self) -> float:
        """The per-test alpha after the configured multiple-testing correction."""
        c = self.config
        if c.correction == "bonferroni":
            return c.alpha / c.n_tests
        if c.correction == "sidak":
            return 1.0 - (1.0 - c.alpha) ** (1.0 / c.n_tests)
        return c.alpha

    def _quantile(self, p: float) -> float:
        return norm_ppf(p) if self.config.distribution == "z" else t_ppf(p, self.config.df)

    def critical_values(self) -> tuple[float, float]:
        """(lower, upper) bounds of the acceptance region; the statistic rejects when it falls outside.

        For a one-sided alternative the unused bound is -inf or +inf.
        """
        a = self.adjusted_alpha()
        if self.config.alternative == "two-sided":
            upper = self._quantile(1.0 - a / 2.0)
            return -upper, upper
        if self.config.alternative == "greater":
            return -math.inf, self._quantile(1.0 - a)
        return self._quantile(a), math.inf

    def rejects(self, statistic: float) -> bool:
        """True when the test statistic lies in the rejection region."""
        lower, upper = self.critical_values()
        return statistic < lower or statistic > upper

    def decide(self, p_value: float) -> bool:
        """True (reject the null hypothesis) when the p-value is below the adjusted alpha."""
        if not 0.0 <= p_value <= 1.0:
            raise ValueError(f"p_value must be in [0, 1], got {p_value}")
        return p_value < self.adjusted_alpha()

    def familywise_error_rate(self) -> float:
        """Chance of at least one false rejection among `n_tests` independent true nulls: 1 - (1 - a)^m,
        where a is the adjusted per-test alpha."""
        return 1.0 - (1.0 - self.adjusted_alpha()) ** self.config.n_tests

    def simulate_false_positive_rate(self, n: int = 20, trials: int = 5000, seed: int = 0) -> float:
        """Share of true-null experiments that the rule rejects; it should come out close to alpha.

        Each trial draws n standard normal values (true mean 0) and tests "mean = 0" with the configured
        statistic: z uses the known standard deviation 1, t uses the sample standard deviation and needs
        `df` = n - 1.
        """
        if self.config.distribution == "t" and abs(self.config.df - (n - 1)) > 1e-9:
            raise ValueError("for the t statistic, df must equal n - 1")
        rng = np.random.default_rng(seed)
        x = rng.normal(size=(trials, n))
        scale = 1.0 if self.config.distribution == "z" else x.std(axis=1, ddof=1)
        stats = x.mean(axis=1) / (scale / math.sqrt(n))
        lower, upper = self.critical_values()
        return float(np.mean((stats < lower) | (stats > upper)))
Repository
Not published yet
Needs
Python 3.10 and NumPy
Tests
7, run with python3 -m unittest -v

Practice

Create SignificanceLevel() and read critical_values(), then call simulate_false_positive_rate() and compare the result with 0.05. Next use SignificanceLevelConfig(correction="bonferroni", n_tests=10) and compare adjusted_alpha(), critical_values() and familywise_error_rate() with the worked example, and repeat with correction="sidak".

Check on learning

  1. A lab runs 20 independent tests of effects that do not exist, each at α=0.05\alpha = 0.05, and publishes whichever is significant. How likely is it that it has something to publish?
    A way to think about it

    Use the family-wise formula with m=20m = 20. Then consider what a reader who sees only the one published test would wrongly assume.

  2. Why is the one-sided critical value (1.645) closer to zero than the two-sided one (1.96) at the same α\alpha, and what do you give up for the easier cutoff?
    A way to think about it

    Both rules put a total of 5% in the rejection region. See where each puts it, and what happens if the effect goes the other way.

  3. Bonferroni guarantees the family-wise rate under any dependence, yet it is called conservative. In what situation is it most wasteful?
    A way to think about it

    Imagine ten tests that are nearly copies of each other. How many independent chances of a false alarm are there really?

  4. If simulate_false_positive_rate is run with the zz rule on data whose true standard deviation is 1.5 instead of 1, would the rate be above or below α\alpha?
    A way to think about it

    The zz statistic divides by the assumed standard deviation. If the real spread is larger, see what happens to the spread of the statistic relative to the fixed cutoffs.