Doctors Revision

Hypothesis Testing in Biostatistics

Text size
On this page

Overview

Clinical Medicine Year 2 • Biostatistics

Hypothesis testing in biostatistics is a planned method for using sample data to evaluate a specific claim about a population, such as whether two treatments differ in mean blood pressure or whether an exposure is associated with a health outcome. A test does not prove a hypothesis true or false. It quantifies how incompatible the observed data are with a defined null model, subject to the sampling design, measurement quality and statistical assumptions. Correct interpretation also considers effect size, a confidence interval, clinical importance and possible bias.

Learning outcomes

After this lesson, you should be able to define null and alternative hypotheses; distinguish one-sided and two-sided tests; explain alpha, p-value, Type I and Type II errors and power; match basic tests to questions and data structures; interpret decisions without saying “accept the null”; and report statistical evidence alongside effect estimates and limitations.

1. From a research question to a testable claim

A research question asks about a population, outcome, comparison or relationship. A statistical hypothesis expresses a claim about a population parameter in measurable terms. For example, “Does an appointment reminder improve attendance?” becomes a question about a defined attendance outcome, time period and comparison. The relevant parameter might be a risk difference, risk ratio or odds ratio, depending on the design and objective.

Testing is not a substitute for a good design. A trial may compare assigned groups; an observational study may compare exposure groups but remain vulnerable to confounding. State the unit of analysis, eligibility criteria, outcome definition and estimand before selecting the test. A p-value cannot repair inaccurate records, non-random recruitment or a mismatched analysis.

2. Null and alternative hypotheses

The null is a statistical reference, not a claim that “nothing happened” in every clinical sense. The alternative is not automatically the investigator’s preferred explanation. Write hypotheses in words and symbols, define the parameter and outcome, and make sure the direction matches the question.

3. One-sided and two-sided alternatives

A two-sided alternative allows an effect in either direction, for example that a new service could increase or decrease attendance. A one-sided alternative specifies a direction in advance. Use a one-sided test only when the opposite direction would not be treated as evidence of interest or safety concern and the justification is set before examining results. Choosing a one-sided test after seeing which direction the estimate went inflates the chance of a false positive and is not defensible.

4. Significance level and decision rule

The significance level, alpha (α), is a threshold selected before analysis for the long-run Type I error rate under the test’s assumptions. A common convention is α = 0.05, but this is not a law of nature or a boundary between “true” and “false.” Clinical trials with multiple primary comparisons, interim monitoring or serious safety outcomes may require a prespecified adjustment or decision process. Report the chosen threshold and why it fits the analysis plan.

After calculating the test statistic and p-value, compare the p-value with α under the prespecified rule. If p < α, reject H₀ for that test. If p ≥ α, fail to reject H₀. The second result does not prove H₀ or establish that groups are equivalent; it may reflect a small effect, inadequate information, measurement error or a wide interval. Equivalence or non-inferiority questions require specific margins and methods.

5. What a p-value does—and does not—mean

The p-value is the probability, assuming the null hypothesis and statistical model are true, of obtaining a test statistic at least as extreme as the observed statistic in the direction(s) specified by the test. It is not the probability that H₀ is true, that the result is due to chance, that the study will replicate, or that a treatment works. The p-value depends on the effect, variability, sample size, design, missing data and model.

A small p-value can occur for a trivial effect in a large sample. A large p-value can occur when an important effect is estimated imprecisely in a small sample. It should not be read in isolation from the point estimate, confidence interval, study design and clinical context. Avoid selectively reporting only outcomes with p < 0.05.

6. Type I error, Type II error and power

Scroll the table sideways on a smaller screen.

Decision and reality Null is true Null is false
Decision and realityNull is trueNull is false
Reject H₀Type I error (false positive); its long-run probability is controlled by α under assumptions.Correct detection of a difference or association for this decision rule.
Fail to reject H₀Correct non-rejection.Type II error (false negative); probability is β for a specified alternative.

Power is 1 − β: the probability a planned study rejects H₀ for a specified true effect, given the assumptions and analysis. Power is not a post hoc probability that the result is true. Sample-size planning should consider a clinically meaningful effect, variability or baseline event rate, α, desired power, allocation ratio, clustering, loss to follow-up and the planned analysis. Inflating sample size without improving measurement or reducing bias does not guarantee valid conclusions.

7. Steps in a responsible hypothesis test

8. Select a test that matches the question

Scroll the table sideways on a smaller screen.

Question / outcome Possible basic test Important conditions to check
Question / outcomePossible basic testImportant conditions to check
Compare a continuous mean in two independent groupsIndependent-samples t-testIndependent observations, meaningful group definition, outliers and distribution; consider unequal-variance version if appropriate.
Compare paired measurements, such as before/after in the same peoplePaired t-testAnalyse within-person differences; check their distribution and pairing.
Compare means across three or more groupsANOVAPlan comparisons, check independence and variance assumptions, and address multiple comparisons.
Compare proportions or categorical outcomesChi-square test; Fisher’s exact test for suitable small tablesCheck expected cell counts, independence and sampling design.
Compare two independent ordinal or skewed outcomesMann–Whitney testIt compares rank distributions; it is not automatically a test of medians unless distributional shapes are comparable.
Assess paired binary changeMcNemar testRequires paired binary observations; use discordant pairs for the comparison.
Model a binary outcome with covariatesLogistic regressionCheck model specification, sparse data, independence, confounding and interpretation of odds ratios.

This is an introductory guide, not a complete menu. Repeated measures, clustered facilities, survey weights, survival outcomes, matched designs or diagnostic accuracy may require specialised methods. Consult a statistician when the design or assumptions are not straightforward.

9. Worked example: appointment reminders

Illustrative results only—not real clinic data: suppose a well-defined study compares missed follow-up between adults assigned to receive a reminder and adults assigned usual care. The estimated risk difference is −8 percentage points (reminder minus usual care), the 95% CI is −14 to −2 percentage points, and the two-sided p-value is 0.01. If α = 0.05 was prespecified and the model is appropriate, the test rejects a zero risk difference. The interval suggests a reduction of about 2 to 14 points under the model, while the point estimate is an 8-point reduction.

Before claiming the reminder caused an improvement, verify randomisation, follow-up, outcome definitions, adherence to assigned groups and missing data. Decide whether an 8-point absolute change matters clinically or operationally. The same p-value in a poorly designed observational study would not establish causation. This example shows how the test decision, effect estimate and practical interpretation answer different parts of the question.

10. Statistical significance versus practical importance

Statistical significance concerns compatibility with a null value under a test; practical importance concerns magnitude, consequences and context. A small difference can be statistically significant in a very large dataset. A potentially important difference can be non-significant when information is limited. Compare results with a prespecified minimum important difference or policy threshold, and discuss benefits, harms, feasibility, costs and equity.

11. Multiple comparisons and selective reporting

Running many tests increases the chance that at least one will cross a conventional threshold even when no real association exists. This may arise from many outcomes, subgroups, time points, exposure definitions or repeated looks at accumulating trial data. Prespecify primary analyses, label exploratory comparisons honestly, and use a justified multiplicity approach when required. Do not change the outcome, hypothesis, subgroup or test because an initial result was not significant.

13. Common errors and their corrections

14. Mini case and exam practice

A district compares mean waiting time before and after introducing a triage process, using records from the same facilities in two different months. Before testing, define the outcome, units, eligible visits, whether observations are paired at any level, and whether case mix changed. A simple independent t-test may be inadequate if facility clustering or seasonal differences are important. Write the null and alternative for the chosen effect scale, select a test from the design, then report the difference, interval, p-value and limitations.

  1. Define a p-value in relation to H₀ and the model.
  2. What is a Type I error? What does power mean?
  3. Why should the analysis plan specify a primary outcome?
  4. When is a paired test appropriate?
  5. Why is “p ≥ 0.05 proves no effect” incorrect?

Continue learning

Study confidence intervals, mean, median and mode, health-research designs and the Clinical Medicine Year 2 curriculum.

Worked examples: chi-square, paired t and independent t tests

The examples below apply hypothesis testing to three common two-group study designs. All data sets are invented for calculation practice. Always choose the statistical test from the study design and variable type before inspecting the p-value. The t-test examples use two-sided alternatives, and all examples use a preselected significance level of 0.05. The chi-square independence test uses the upper tail of the chi-square distribution to assess departure from independence in either direction of association.

Choosing between the three two-group tests

When comparing two groups, test selection depends on whether the outcome is categorical (counts or proportions) or numerical (continuous measurements), and whether the observations come from separate individuals or paired measurements within the same individuals.

Scroll the table sideways to compare

Choosing a two-group hypothesis test
TestOutcome dataDesign structureDegrees of freedomAlternative if assumptions fail
Pearson chi-square testCategorical (counts in categories)Two or more independent groups(rows − 1) × (columns − 1)Fisher’s exact test (sparse counts); McNemar’s test (paired binary data)
Paired t-testNumerical (continuous differences)Paired measurements (same person or matched pairs)n − 1 (where n is the number of pairs)A paired alternative matched to the question. Signed-rank location inference needs suitable symmetry; a sign test or another justified method may suit different assumptions
Independent-samples t-testNumerical (continuous values)Two separate, unrelated groupsWelch–Satterthwaite df (or nA + nB − 2 for pooled Student’s t)A method suited to the intended effect and design. Mann–Whitney examines ranks/distributions; it is not automatically a test of equal means or medians

1. Pearson chi-square test of independence

The Pearson chi-square test evaluates whether two categorical variables are related in the population by comparing the observed counts in each cell of a contingency table with the expected counts calculated under the null model of independence.

Scroll the table sideways if needed

Observed counts for the chi-square example
GroupOutcome presentOutcome absentTotal
Group A302050
Group B203050
Total5050100
Worked calculation steps: Pearson chi-square test
  1. State the hypotheses: Null hypothesis (H0): group and outcome are independent in the population (the proportion with the outcome is equal in Group A and Group B). Alternative hypothesis (Ha): group and outcome are associated in the population.
  2. Compute expected counts: Under independence, expected count = (row total × column total) ÷ grand total = (50 × 50) / 100 = 25 in every cell.
  3. Compute the chi-square statistic: χ² = Σ[(observed − expected)² / expected]. Each of the four cells differs from 25 by ±5, so χ² = 4 × (5² / 25) = 4 × (25 / 25) = 4.00.
  4. Determine degrees of freedom: df = (2 − 1)(2 − 1) = 1.
  5. Obtain the p-value and decision: Without continuity correction, p ≈ 0.0455. Because 0.0455 < 0.05, reject independence at the 0.05 significance level.

Interpretation, assumptions and cautions

  • Result in context: In this model, 60% (30/50) of Group A experienced the outcome compared with 40% (20/50) of Group B, yielding statistical evidence of an association (χ² = 4.00, df = 1, p ≈ 0.0455).
  • Required assumptions: Observations must be independent (one observation per person), categories must be mutually exclusive and expected cell counts must be large enough for the chi-square approximation to hold. Here all expected counts are 25, well above the usual minimum threshold of 5.
  • When to choose a different test: For sparse 2 × 2 tables with small expected counts, use an appropriate exact method such as Fisher’s exact test. When binary outcomes are measured twice on the same people (paired binary data), use a paired method such as McNemar’s test instead.
  • Association is not causation: The p-value describes how unusual a chi-square statistic at least this large would be under the independence model and its assumptions. It is not the probability that chance caused the result. Report the proportions and an effect estimate with uncertainty; choose a difference, ratio or odds ratio appropriate to the study design rather than labelling every association as a causal risk effect.

2. Paired t-test: analyse each person’s difference

A paired t-test is used when two numerical measurements are linked—such as before-and-after measurements on the same participant or matched pairs. Rather than treating "before" and "after" as two separate groups, the test calculates a single within-person difference for each pair and tests whether the population mean of those differences equals zero.

Sample data: Five paired differences, calculated consistently as before minus after, are 5, 8, 6, 11 and 10 units. Using these five differences, the sample mean difference is 8 units, and the sample standard deviation is √(26/4) ≈ 2.5495 units.

Worked calculation steps: paired t-test
  1. State the hypotheses: Null hypothesis (H0): the population mean paired difference is zero (μd = 0). Two-sided alternative hypothesis (Ha): μd ≠ 0.
  2. Verify sample summary values: Mean difference = (5 + 8 + 6 + 11 + 10) / 5 = 40 / 5 = 8. Deviations from 8 are −3, 0, −2, +3 and +2, giving a sum of squared deviations of 9 + 0 + 4 + 9 + 4 = 26, sample variance = 26 / (5 − 1) = 6.5 and sample SD = √6.5 ≈ 2.5495.
  3. Compute the standard error (SE): SE of the mean difference = SD / √n = 2.5495 / √5 ≈ 1.1402.
  4. Compute the test statistic and degrees of freedom: t = (8 − 0) / 1.1402 ≈ 7.016, with df = n − 1 = 5 − 1 = 4.
  5. Obtain the p-value and decision: For t ≈ 7.016 with df = 4, the two-sided p ≈ 0.00217. At the 0.05 level, reject H0: there is strong statistical evidence of a nonzero mean difference under the stated assumptions.

Interpretation, assumptions and cautions

  • Effect and precision: The estimated mean before-minus-after difference is 8 units. Under the paired t model, its 95% confidence interval is approximately 4.83 to 11.17 units, calculated as 8 ± t0.975,4 × 1.1402. This is an interval for the population mean difference, not for individual changes.
  • Genuine pairing: Each before value must match the same person’s after value (or its matched partner). Do not treat paired data as two independent samples, because doing so ignores within-person correlation and distorts the standard error.
  • Independence and normality of differences: Differences should be independent between pairs. The exact small-sample t procedure assumes a normally distributed population of differences; influential outliers or marked non-normality can affect it. A plot of only five values cannot establish normality. This example demonstrates arithmetic, not proof that the model fits real clinical data.
  • Direction and confounding: The sign of the mean difference (+8 rather than −8) depends solely on subtracting after from before. Moreover, a simple before–after change does not rule out natural recovery over time, seasonal trends or co-interventions. A comparison group and a suitable design can strengthen inference, but a control group alone does not eliminate confounding or bias.

3. Independent-samples t-test: compare separate groups

An independent-samples t-test compares the population means of a numerical variable across two separate, unrelated groups. Unlike the z-test, it uses sample standard deviations rather than a known population standard deviation, relying on a t reference distribution, with heavier tails at low degrees of freedom and an approach to the standard normal distribution as degrees of freedom increase.

Sample data: Group A has values 10, 12, 14, 16 and 18 (nA = 5, mean = 14, sample variance = 10). Group B has values 7, 9, 11, 13 and 15 (nB = 5, mean = 11, sample variance = 10). Both groups contain independent observations.

Worked calculation steps: Welch’s independent-samples t-test
  1. State the hypotheses: Null hypothesis (H0): the two population means are equal (μA = μB). Two-sided alternative hypothesis (Ha): μA ≠ μB.
  2. Compute the standard error for Welch’s test: SE = √(sA²/nA + sB²/nB) = √(10/5 + 10/5) = √(2 + 2) = 2.
  3. Compute the test statistic: t = (meanA − meanB) / SE = (14 − 11) / 2 = 3 / 2 = 1.50.
  4. Determine degrees of freedom: For these equal-size, equal-variance summaries, the Welch–Satterthwaite df = 8. In general, Welch’s df depends on both sample sizes and estimated variances and may be fractional. Do not automatically substitute the pooled-test degrees of freedom.
  5. Obtain the p-value and decision: For t = 1.50 with df = 8, the two-sided p ≈ 0.172. Because 0.172 > 0.05, do not reject equality of means at the 0.05 significance level.

Interpretation, assumptions and cautions

  • Effect and precision: The estimated mean difference A minus B is 3 units. Its Welch 95% confidence interval is approximately −1.61 to 7.61 units, using 3 ± t0.975,8 × 2. The interval includes zero and also effects in either direction; it does not establish equivalence.
  • Failing to reject is not proof of equality: Although Group A’s sample mean (14) is 3 units higher than Group B’s (11), the two-sided p ≈ 0.172 is the tail probability for a test statistic at least this extreme under the equal-means model and its assumptions. It is not the probability that the observed difference is due to chance. Do not conclude that the population means are identical—only that this small sample provides insufficient evidence against H0.
  • Welch’s t-test versus pooled Student’s t-test: Welch’s method allows unequal population variances and is generally safer as a default. A pooled Student’s t-test instead assumes equal population variances across both groups; justify that assumption from the design and context rather than relying only on a preliminary variance-test result and uses df = nA + nB − 2.
  • Distribution and independence: Both groups must be independent of each other, observations within each group must be independent (never treat repeated measurements on the same person as separate subjects) and the small-sample t procedure requires suitable population-distribution assumptions and no influential outliers. Robustness depends on distribution shape, group balance and sample size; 30 is not a universal boundary guaranteeing validity.

Assumptions, uncertainty and clinical importance

Running a formula is only part of statistical reasoning. Before accepting any result, check whether the data meet the test’s assumptions and interpret what the numbers mean for real patients.

Checklists: assumption verification and complete statistical reporting

Pre-test assumption checklist

  • Independence: Confirm whether observations come from separate individuals (chi-square or independent t-test) or from paired/repeated measurements on the same person (paired t-test or McNemar’s test).
  • Sample size and distribution: For small numerical samples, inspect histograms or plots for strong skewness and influential outliers. Larger samples can improve robustness in some settings, but sample size alone does not resolve severe outliers, dependence or bias. If assumptions are unsuitable, select a justified alternative that answers the intended question; rank methods may target a different effect.
  • Variance equality (two numerical groups): Use Welch’s t-test whenever population variances might differ; reserve the pooled Student’s t-test for situations where equal variances are justified.
  • Expected cell counts (categorical tables): Verify that expected counts are adequate for the chi-square approximation rather than using it blindly on sparse tables.

Reporting checklist

  • Study summaries: Report exact sample sizes and group summaries (counts and percentages for categorical data; means and standard deviations—or medians and interquartile ranges if skewed—for numerical data).
  • Magnitude and precision: Report the estimated difference or effect size alongside its confidence interval.
  • Test details: State the exact test version used (for example, Welch’s independent t-test or Pearson chi-square without continuity correction), the test statistic, degrees of freedom and exact p-value.

Distinguishing association, uncertainty and clinical importance

  • Association and statistical significance: A small p-value means that a test statistic at least as extreme as observed has a small tail probability under the null model and its assumptions. It is not the probability that the null hypothesis is true. It does not prove causation (confounding or bias may explain an observational association) and does not tell you whether an effect is large enough to matter.
  • Uncertainty: Standard errors and confidence intervals describe sampling uncertainty under their assumptions. They do not automatically include selection bias, measurement error or model misspecification. Precision depends on sample size and variability; small studies can miss important effects or produce unstable effect estimates.
  • Clinical importance: Clinical importance is assessed separately from statistical significance. A large study may give a small p-value for a small effect; a smaller study may leave substantial uncertainty around an important effect. Judge importance using the outcome, effect size, confidence interval, benefits, harms and patient context. No p-value or single numerical threshold settles clinical importance by itself.

Further reading for this section

References and further reading

Educational revision content only. Statistical tests depend on design and assumptions; follow the approved analysis plan and seek qualified statistical advice for complex or high-stakes work.

Further Reading

For deeper study, use authoritative statistics and reporting resources:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top