Hypothesis testing: a step-by-step guide
Hypothesis testing is the standard way researchers decide whether a pattern in their sample is likely to reflect something real, or could easily be produced by chance. The logic is a little backwards at first. You don’t try to prove your idea. You assume there’s nothing going on and ask how surprising your data would be if that were true.
The five steps
- State the null and alternative hypotheses.
- Choose the test, based on your design and variable types, after checking its assumptions. Set the significance level (usually α = .05).
- Calculate the test statistic and p-value.
- Decide whether to reject the null hypothesis.
- Report the result with an effect size and confidence interval, in plain language.
We’ll walk through each step with a real example.
The example: two sleeping drugs
In a 1905 study, ten patients each tried two sleeping drugs, and researchers recorded how many extra hours of sleep each drug gave compared with no drug. In 1908, William Gosset, writing as “Student”, used these data to introduce the t-test. The question: do the two drugs differ in how much extra sleep they produce?
Step 1: state the hypotheses
- Null hypothesis (H₀): the mean difference in extra sleep between the drugs is zero.
- Alternative hypothesis (H₁): the mean difference is not zero.
The null is always the “nothing going on” statement that the test tries to find evidence against. More on writing these in null and alternative hypotheses.
Step 2: choose the test and check its assumptions
The same ten patients took both drugs, so the measurements are paired. That points to a paired samples t-test, which needs the ten differences to be roughly normal. Check this before committing to the test. If it fails, you’d use the Wilcoxon signed-rank test instead. Here the check passes, so the paired t-test it is. We use α = .05: we’ll call a result significant if data this extreme would occur less than 5% of the time under the null.
Step 3: calculate the test statistic and p-value
On average, drug 2 gave 1.58 more hours of extra sleep than drug 1. The paired t-test compares that average difference with how much the differences vary between patients:
- t(9) = −4.06
- p = .003
- 95% confidence interval for the difference: −2.46 to −0.70 hours
- Effect size: Cohen’s d = −1.28
(The values are negative because the calculation is drug 1 minus drug 2.)
Step 4: decide
The p-value (.003) is below α (.05), so we reject the null hypothesis. If the drugs truly had the same average effect, a difference this large would turn up in fewer than 1 in 300 studies like this. That’s surprising enough to conclude there’s evidence of a difference. The p-value lesson explains what this number does and doesn’t mean.
Step 5: report
A paired samples t-test found evidence that drug 2 produced more extra sleep than drug 1, mean difference = 1.58 hours, 95% CI [0.70, 2.46], t(9) = −4.06, p = .003, d = −1.28.
Notice what’s included: the size of the difference and its uncertainty, not just “p < .05”. The confidence interval says the advantage is plausibly anywhere from about 40 minutes to two and a half hours. The effect size says the difference is large relative to the patient-to-patient variation.
Two ways to be wrong
| H₀ actually true | H₀ actually false | |
|---|---|---|
| Reject H₀ | Type I error (false positive), probability α | Correct |
| Don’t reject H₀ | Correct | Type II error (false negative), probability β |
α is the false-positive rate you accept. Power (1 − β) is the chance of detecting an effect that really exists. Small samples have low power, so they often fail to detect real effects. That’s why a non-significant result from a small study is weak evidence either way.
What a hypothesis test can’t tell you
- Whether the effect is big enough to matter. With a huge sample, a trivial difference can be significant. Look at the effect size and confidence interval.
- The probability that your hypothesis is true. A p-value is calculated assuming the null is true. It isn’t the chance that the null is true.
- Causation, unless the groups were created by random assignment.
- That there is no effect, when p > .05. Write “no evidence of a difference”, not “no difference”.
Common mistakes
- Choosing the test after seeing which one gives p < .05.
- Checking assumptions after running the test, then ignoring them if the result looks good.
- Running many tests and reporting only the significant ones, which inflates false positives.
- Treating .049 and .051 as opposite conclusions. They are nearly identical evidence.
Analytika builds the first two safeguards in: assumption checks run on your data before a test is chosen, and the write-up uses “no evidence of” language for non-significant results.
More in Hypothesis testing
Try it with the free tools
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.