Hypothesis tests

Online paired means hypothesis test calculator

Assess whether the mean difference between two paired conditions is statistically significant using the paired t-test of differences.

Parameters

Enter the parameters of the differences to get the t statistic, p-value and test decision.

Result pending…

Rejection regions and observed statistic

What is a hypothesis test for paired means?

It is the test to use when the data come in pairs: each unit provides two related measurements, and the question is whether, on average, there is a difference between them. Typical cases are before and after measurements of an intervention in the same people, two conditions applied to the same subject (left and right eye, two treatments in random order), or deliberately matched pairs, such as twins or patients matched by age and sex. It is also known as the dependent-samples t-test or paired t-test.

The idea is very simple: for each pair you compute the difference \(d_i = x_{i1} - x_{i2}\), and the problem becomes a one-mean test on those differences. If the intervention has no effect, the differences should hover around 0; if their mean moves away from 0 by more than chance can explain, you conclude that there is a systematic change.

The great advantage of the paired design is that each subject acts as their own control. Differences between people (some have high blood pressure, others low; some students get better grades than others) disappear when you subtract, and only the variability of the change remains. That is why, with the same number of subjects, it can usually detect much smaller effects than a comparison of two independent groups.

Hypotheses and test statistic

\(H_0: \mu_d = \mu_{d0}\)

\(H_1: \mu_d \neq \mu_{d0}\), \(\mu_d > \mu_{d0}\) or \(\mu_d < \mu_{d0}\)

\( t = \dfrac{\bar{d} - \mu_{d0}}{s_d / \sqrt{n}}, \quad df = n - 1 \)

  • \(\bar{d}\): mean of the differences within each pair.
  • \(s_d\): standard deviation of those differences.
  • \(n\): number of pairs (not of measurements).
  • \(\mu_{d0}\): mean difference under \(H_0\); almost always 0 ("no change").

The denominator \(s_d/\sqrt{n}\) is the standard error of the mean difference. The statistic measures how many standard errors \(\bar{d}\) lies from the value under \(H_0\) and, if \(H_0\) is true, follows a Student's t distribution with \(n-1\) degrees of freedom.

Note that the sign depends on the order of the subtraction. If you compute "before − after", a reduction gives positive differences; if you compute "after − before", negative ones. Decide the order before you start and choose the tail of the test accordingly.

How to carry out the test, step by step

  1. Compute the difference for each pair, always in the same order.
  2. Compute the mean \(\bar{d}\) and the standard deviation \(s_d\) of the differences. These are the two values the calculator asks for, together with the number of pairs.
  3. State the hypotheses and set \(\alpha\), usually 0.05.
  4. Compute the t statistic and the p-value with \(n-1\) degrees of freedom (or compare with the Student's t table).
  5. Decide and interpret, reporting the decision together with the confidence interval for the mean difference.

Decision rule

  • If the p-value is less than \(\alpha\), \(H_0\) is rejected: there is evidence that the mean difference is not \(\mu_{d0}\).
  • If the p-value is greater than or equal to \(\alpha\), there is not enough evidence to reject \(H_0\).
  • A non-significant result does not prove that there is no change; it may be due to low power.

Why is the paired design more powerful?

The variance of a difference between two measurements is

\( \sigma_d^2 = \sigma_1^2 + \sigma_2^2 - 2\rho\,\sigma_1\sigma_2 \)

where \(\rho\) is the correlation between the two measurements in each pair. When the measurements of the same subject are similar (positive \(\rho\), the usual case), the term \(2\rho\sigma_1\sigma_2\) is subtracted, and the differences vary much less than the original data. A smaller standard error means a larger statistic for the same difference, that is, more power.

Example 2 below shows it with numbers: with the same 8 students, the paired test gives \(p \approx 0.0005\); if the data were analysed as if they were two independent groups, the p-value would be 0.14 and nothing would be detected. That is why it is a mistake to analyse paired data with the independent two-sample test.

The flip side is that, in a before-and-after design without a control group, a significant change does not prove that the intervention caused it: the passage of time, practice with the test or regression to the mean may have played a part. Whenever possible, it is worth comparing with a control group.

Assumptions of the test

  • Paired data: each measurement in one condition has its partner in the other. If the groups are different people with no matching, use the independent two-sample test.
  • Pairs independent of each other: the two measurements of a pair are related, but one pair must not influence another.
  • Approximate normality of the differences (not of the original data), or a number of pairs large enough, around 30 or more, for the central limit theorem to do its job.

With few pairs, check the differences with a histogram or the Shapiro-Wilk test and look for outliers: a single pair with an extreme change can drag \(\bar{d}\) and inflate \(s_d\). If the differences are clearly skewed and there are few of them, the non-parametric alternative is the Wilcoxon signed-rank test.

Worked example 1: two-tailed test

Systolic blood pressure is measured in 25 patients before and after a treatment. The mean of the differences (before − after) is \(\bar{d} = 2.5\) mmHg with standard deviation \(s_d = 8\) mmHg. We test \(H_0\colon \mu_d = 0\) against \(H_1\colon \mu_d \neq 0\) with \(\alpha = 0.05\).

\( t = \dfrac{2.5 - 0}{8 / \sqrt{25}} = \dfrac{2.5}{1.6} = 1.5625 \)

With \(df = 24\), the two-tailed critical value is \(t_{0.025;\,24} \approx 2.064\). Since \(|t| = 1.5625 < 2.064\), the p-value is \(p \approx 0.131 > 0.05\): \(H_0\) is not rejected.

Conclusion: there is not enough evidence that the treatment changes mean blood pressure. The 95% confidence interval for the mean difference, \(2.5 \pm 2.064 \times 1.6\), runs from −0.80 to 5.80 mmHg: it is compatible with no effect, but also with reductions of almost 6 mmHg. With 25 patients and this variability, the test detects with 80% probability only mean changes of about 4.7 mmHg or more; detecting 2.5 mmHg would require a considerably larger sample, which you can work out with the link in the result.

In the calculator: d̄ = 2.5, s_d = 8, n = 25, μ_d0 = 0 and "Two-tailed (≠)".

Worked example 2: from the data to the test, one-tailed

Eight students take a test before and after an intensive course. Before seeing the data, it is stated that the course, if it has any effect, improves the grade. The grades are:

Student12345678
Before6270556874606658
After6675547380657063
\(d_i\) = after − before45−156545

The mean of the differences is \(\bar{d} = 33/8 = 4.125\) points and their standard deviation is \(s_d \approx 2.167\). We test \(H_0\colon \mu_d = 0\) against \(H_1\colon \mu_d > 0\):

\( t = \dfrac{4.125}{2.167/\sqrt{8}} = \dfrac{4.125}{0.766} \approx 5.384 \)

With 7 degrees of freedom, the right-tailed critical value is \(t_{0.05;\,7} \approx 1.895\), and the p-value is \(p \approx 0.0005\). \(H_0\) is rejected: there is evidence that the mean grade rises after the course, by about 4 points.

Compare this with what would have happened if the before and after grades had been treated as two independent groups: the standard deviations of the grades are 6.5 and 8.1 points, because the students are very different from each other, and Welch's test would give \(t \approx 1.13\) and \(p \approx 0.14\). Pairing removes that variability between students (the correlation between the two grades is 0.98), which is why the effect shows up so clearly.

In the calculator: d̄ = 4.125, s_d = 2.167, n = 8, μ_d0 = 0 and "Right tail (>)".

How to interpret the result

Rejecting \(H_0\) (p-value < α) indicates that the mean difference between the two measurements is incompatible with \(\mu_{d0}\): there is a systematic change. Its practical relevance depends on its size, so look at the mean difference and its confidence interval, and judge whether that change matters in your context.

Not rejecting \(H_0\) (p-value ≥ α) does not prove that there is no change. The most common mistake is to conclude "the treatment does not work" when the sample was too small to detect it, as in example 1.

In the calculator, the result shows the decision with the p-value, the statistic with its degrees of freedom and a sentence stating the conclusion. On the chart, the green area is the non-rejection region, the red areas are the critical regions and the amber line marks the observed statistic. Under "Calculation details" you will find the observed difference, the standard error, the critical value, the confidence interval (for the two-tailed test) and the effect size.

Power and minimum detectable difference

Below the conclusion, the calculator shows the minimum detectable difference: the smallest real mean difference that, with your number of pairs and your \(s_d\), the test would detect with 80% probability. If it is larger than the change that would matter to you, the study has low power and a non-significant result says little. The link opens the sample size calculator for paired means with your \(s_d\), your α and the type of test, so you can work out how many pairs you would need to detect the difference you care about.

Relationship with the confidence interval

In the two-tailed test, \(H_0\) is rejected exactly when \(\mu_{d0}\) lies outside the \(100(1-\alpha)\%\) confidence interval for the mean difference. You can compute that interval with the confidence interval for paired means.

Effect size

With paired data, the most common effect size is \(d_z = (\bar{d} - \mu_{d0})/s_d\), which expresses the mean difference in standard deviations of the differences. Be careful when comparing it with Cohen's d for two independent groups: \(d_z\) is usually much larger for the same change, because \(s_d\) is smaller than the standard deviation of the original data. In example 2, \(d_z \approx 1.90\).

Common mistakes

  • Analysing paired data as two independent groups, losing almost all the advantage of the design.
  • Entering the number of measurements instead of the number of pairs: with 25 patients measured twice, \(n = 25\).
  • Using the standard deviation of the original data instead of that of the differences.
  • Mixing up the order of the subtraction or choosing the tail without taking it into account.
  • Attributing the change to the intervention in a before-and-after design without a control group.
  • Concluding that there is no effect because the test is not significant.

Frequently asked questions

  • When is the paired t-test used? When each value in one condition has its partner in the other: the same subject measured before and after, two treatments in the same subject, or pairs matched on relevant characteristics.
  • How does it differ from the independent two-sample test? It works with the difference within each pair, which removes the variability between subjects. If the two measurements are correlated, as is usual, it is much more powerful.
  • What data do I need? The mean and standard deviation of the differences within each pair, and the number of pairs. If you have the original data, first compute the difference for each pair.
  • What assumptions does it require? That the pairs are independent of each other and that the differences follow an approximately normal distribution, or that there are enough pairs. The original data do not need to be normal.
  • What does μ_d0 mean? The value of the mean difference under the null hypothesis. It is almost always 0, meaning no change; it can be another value if you want to test a specific change.
  • Does the order of the subtraction matter? Only for the sign: before − after and after − before give differences of opposite sign. Choose the order before you start and pick the tail accordingly.
  • What if the differences are not normal? With many pairs the test remains valid. With few pairs and very skewed differences, use the Wilcoxon signed-rank test.
  • What is the minimum detectable difference? The smallest real mean difference that the test would detect with 80% probability given your number of pairs and variability.
  • How many pairs do I need? It depends on the change you want to detect, the standard deviation of the differences and the desired power. Work it out with the sample size calculator for paired means.

Reference: Dependent t-test for paired samples — Wikipedia