Hypothesis testing
Hypothesis testing is a statistical procedure that uses sample data to decide whether an observed result is consistent with a stated assumption, the null hypothesis. It reports a p-value, the probability of a result at least as extreme if the null hypothesis were true.
What it is
Hypothesis testing is a method for deciding, from a sample, whether an observed difference or pattern is more than chance variation would produce. The analyst states a null hypothesis, which is the assumption of no effect or no difference, and an alternative hypothesis, which is the claim the data might support.
The steps are:
- State the null and alternative hypotheses.
- Choose a significance level, written alpha, before looking at the data.
- Compute a test statistic from the sample.
- Compute the p-value and compare it with alpha.
The National Institute of Standards and Technology (NIST) describes the p-value as the probability, under the null hypothesis, that the test statistic takes values equal to or more extreme than the one observed. If the p-value is at or below alpha, the null hypothesis is rejected. Otherwise it is not rejected.
Two errors are possible. A type I error rejects a true null hypothesis, and alpha is the probability of that error. A type II error fails to reject a false null hypothesis.
A confidence interval is the companion tool. It gives a range of values for the quantity being estimated.
Why it matters
Samples vary, so a gap between two groups can appear by chance. A test puts a number on how surprising the gap would be if nothing real were happening.
Analysts use it to decide whether a change in an average, a rate or a relationship is worth acting on. A result with no stated test is an anecdote, and a test misread can lead to a wrong decision in either direction.
Worked example
Illustrative numbers. A bank expects a payment process to take 10 minutes on average. After a change, a sample of 100 payments averages 9.5 minutes, with a sample standard deviation of 2.5 minutes.
- Null hypothesis: the true average is still 10 minutes. Alternative: it differs from 10.
- Alpha is set at 0.05.
- The standard error is 2.5 divided by the square root of 100, which is 0.25. The test statistic is (9.5 minus 10) divided by 0.25, which is minus 2.
- A statistic of minus 2 is about two standard errors from the null value. The two-sided p-value is close to 0.05.
The result is borderline. The analyst reports the estimate, the interval and the p-value rather than a bare yes or no.
How to read it
A small p-value is evidence against the null hypothesis. It does not give the probability that the null hypothesis is true, and it does not measure the size or importance of the effect. A large p-value means the data do not rule out the null, not that the null is proved.
Who uses it
- Data analysts test whether differences between groups or periods exceed chance.
- Business intelligence analysts check that a movement in a metric is more than noise before reporting it.
- Investment risk and performance analysts test whether a return differs from a benchmark.
- Credit risk model developers test whether coefficients and model differences are statistically distinguishable from zero.
- Market research analysts test survey results across segments.
Common confusions
- The p-value is not the probability that the null hypothesis is true. It assumes the null hypothesis and asks how extreme the data are.
- Failing to reject the null is not acceptance of it. The sample may be too small to detect a real effect.
- Statistical significance is not practical importance. A very large sample can make a trivial difference significant.
- Choosing alpha after seeing the result defeats the test. The level is set beforehand.