The formulas behind every chapter
Sixteen formulas, each with its idea in motion. Tap a panel to open its chapter.
Mean or median? Let the shape decide
When data are skewed, a few long values drag the mean away from the typical patient. The median stays put.
Drag the slider toward the left and the histogram becomes symmetric: mean and median meet. Drag right and a long tail of patients with very long stays pulls the mean upward.
Rule of thumb: symmetric data → mean (SD). Skewed data (length of stay, costs, viral load, CRP) → median (IQR). Check with a histogram, not only a Shapiro–Wilk test, which flags trivial departures in big samples.
In the literature
The RECOVERY trial of dexamethasone in hospitalised COVID-19 reported duration of hospital stay as a median (12 vs 13 days), because stay is right-skewed, while mortality was reported as a proportion.RECOVERY Collaborative Group. N Engl J Med 2021;384:693–704.Common thesis mistake
Reporting “mean ± SD” for a variable where the SD is larger than the mean (for example 6 ± 9 days). That alone tells the examiner the data are skewed.Hypotheses: H₀, H₁ and the two ways to be wrong
The left curve is what your test statistic looks like if H₀ is true; the right curve, if your hypothesised effect is real. Move the sliders to see α, β and power trade off.
Try it: build your thesis hypothesis
Fill in your PICO. The tool writes the research question and the null and alternative hypotheses in words and symbols.
A hypothesis turns a research question into a claim the data can test. The null hypothesis (H₀) is the default of no effect (or, in non-inferiority trials, of an unacceptable effect). The alternative (H₁) is what you hope to show.
| H₀ true | H₀ false | |
|---|---|---|
| Reject H₀ | Type I error (α) | Correct: power |
| Do not reject | Correct | Type II error (β) |
Two-sided tests are the default: they detect benefit or harm. A one-sided test is justified only if it is pre-specified and an effect in the other direction would be treated the same as no effect.
Superiority tests whether the new treatment is better. Non-inferiority tests whether it is not worse by more than a margin Δ. Equivalence tests whether the difference lies within ±Δ.
In the literature
The CONSORT extension for non-inferiority and equivalence trials asks authors to state the hypothesis framework explicitly, to justify the margin Δ before the trial starts, and to show the confidence interval against that margin.Piaggio G et al. JAMA 2012;308:2594–604.Common thesis mistake
Writing “we accept the null hypothesis” after p > 0.05. You fail to reject it. Absence of evidence is not evidence of absence — and switching to a one-sided test after seeing the data is not allowed.What a p-value really measures
Run 1,000 identical trials at once. The histogram shows every trial's p-value. With no true effect, about 5% still fall below 0.05 by chance.
Set the true effect to 0: the bars are flat, and about 5% of trials are “significant” — these are false positives (type I error, α).
Now add an effect: p-values pile up near zero. The share below 0.05 is the power of the trial. Increase patients per arm and watch power rise.
A p-value is the probability of data at least this extreme if the null hypothesis were true. It is not the probability that the treatment works.
In the literature
RECOVERY: 28-day mortality was 22.9% with dexamethasone vs 25.7% with usual care, rate ratio 0.83 (95% CI 0.75–0.93), P<0.001. The tiny p-value reflects a large trial (6,425 patients), not a huge effect — the absolute difference was under 3 percentage points.RECOVERY Collaborative Group. N Engl J Med 2021;384:693–704.Common thesis mistake
Writing “p = 0.08, so there was no difference.” Non-significant means the data were compatible with no difference — and probably with a meaningful one too. Report the effect and its CI.Confidence intervals catch the truth — most of the time
Each line is one study estimating mean systolic BP (true value 120 mmHg, the dashed line). Intervals that miss the truth are shown in coral.
Over many repetitions, about 95% of 95% intervals contain the true value. Any single interval either does or doesn't — we never know which.
Bigger samples make intervals narrower, not more likely to be right. Higher confidence makes them wider.
In the literature
In RECOVERY's subgroup not receiving oxygen, the rate ratio was 1.19 (95% CI 0.92–1.55). The interval crosses 1 and stretches toward 55% higher mortality: the trial could not rule out harm, so dexamethasone was not recommended for these patients.RECOVERY Collaborative Group. N Engl J Med 2021;384:693–704.Common thesis mistake
Saying “there is a 95% probability the true value lies in this interval.” That is a Bayesian credible interval. For a confidence interval, the 95% describes the method.RR, OR, ARR and NNT from one 2×2 table
Choose a published trial or type your own counts. Each dot is one patient in 100; filled dots had the outcome.
Relative risk = risk in treated ÷ risk in control. ARR = control risk − treated risk. NNT = 1 ÷ ARR: patients you treat to prevent one event.
The odds ratio drifts further from 1 than the RR when the outcome is common (above ~10%). Watch them separate in the ventilated preset, where 41% died.
In the literature
RECOVERY ventilated patients: 29.3% vs 41.4% died (age-adjusted rate ratio 0.64 in the paper; the crude ratio here is a little different). ISIS-2 aspirin: vascular deaths 9.4% vs 11.8% — a modest RR but, across 17,000 patients, about 24 vascular deaths avoided per 1,000 treated with aspirin.RECOVERY, N Engl J Med 2021;384:693–704 · ISIS-2 Collaborative Group, Lancet 1988;2:349–60.Common thesis mistake
Reporting only relative effects. “Halves the risk” sounds the same whether risk falls from 40% to 20% (NNT 5) or 0.2% to 0.1% (NNT 1,000).Sample size and power for two proportions
The sample size section of your protocol needs four numbers. Change any one and see how many patients you need.
The curve shows power at every sample size; the dot marks the size that reaches your chosen power. Halve the difference you want to detect and the required sample size roughly quadruples.
Inflate the result for expected loss to follow-up: n ÷ (1 − dropout rate).
In the literature
CONSORT 2010 (item 7a) requires trials to report how sample size was determined: the expected outcome in each group, α, power, and for continuous outcomes the SD. Examiners and reviewers check that your assumptions come from cited prior data, not wishful thinking.Schulz KF, Altman DG, Moher D. BMJ 2010;340:c332.Common thesis mistake
Choosing the effect size after seeing how many patients are available. Justify the effect from the literature or from the minimal clinically important difference.Why a good test can still give mostly false alarms
1,000 people are tested. Sensitivity and specificity belong to the test; positive predictive value depends on how common the disease is.
Start at 1% prevalence (community screening): even with 99.2% specificity, false positives are a sizeable share of positives. Slide prevalence to 20% (a TB clinic) and PPV climbs.
SnNout: a highly sensitive test, when negative, rules out. SpPin: a highly specific test, when positive, rules in.
In the literature
Xpert MTB/RIF, against culture: one test detected 98.2% of smear-positive and 72.5% of smear-negative culture-positive tuberculosis, with specificity of 99.2%. The sliders start at the smear-negative values.Boehme CC et al. N Engl J Med 2010;363:1005–15.Common thesis mistake
Quoting PPV from a hospital study as if it applied to community screening. Report sensitivity and specificity, and compute predictive values for your own setting's prevalence.Kaplan–Meier curves and the hazard ratio
Two simulated arms of 150 patients followed for 4 years. Ticks are censored patients — lost or still event-free when the study ended.
The hazard ratio compares the instantaneous event rate between arms at any moment. HR 0.65 means treated patients have events at 65% of the control rate, throughout follow-up (the proportional-hazards assumption).
Censored patients count while they are observed, then leave the risk set. Ignoring them — or treating them as event-free — biases results. Always show the numbers at risk under the curve.
In the literature
EMPA-REG OUTCOME (7,020 patients with type 2 diabetes): empagliflozin reduced the primary cardiovascular outcome, HR 0.86 (95.02% CI 0.74–0.99), and cardiovascular death, HR 0.62 (95% CI 0.49–0.77). The curves here are simulated, not the trial's data.Zinman B et al. N Engl J Med 2015;373:2117–28.Common thesis mistake
Reporting Cox HRs without checking proportional hazards. If curves cross, a single HR misleads; check Schoenfeld residuals or report restricted mean survival time.Simpson's paradox: the better treatment can look worse
Real data on kidney-stone treatment. Toggle between the pooled result and the result stratified by stone size.
Pooled, PCNL wins (83% vs 78%). Stratified, open surgery wins in both small and large stones. How?
Surgeons gave open surgery mostly to large, harder stones. Stone size affects both the choice of treatment and the chance of success — it is a confounder. Adjust by stratification (Mantel–Haenszel) or regression; in trials, randomisation handles it.
In the literature
Small stones: open 93% (81/87) vs PCNL 87% (234/270). Large stones: open 73% (192/263) vs PCNL 69% (55/80). Overall: open 78% vs PCNL 83%.Charig CR et al. BMJ 1986;292:879–82.Common thesis mistake
Choosing adjustment variables by p-value in univariable screening. Choose confounders from subject knowledge — draw a DAG — and avoid adjusting for mediators.Case–control studies give odds ratios, not risks
In a case–control study, you choose how many controls to recruit. Change that ratio and see what moves and what doesn't.
The apparent “risk” of lung cancer among smokers changes with the number of controls you recruit — it is an artefact of design. The odds ratio stays at 14.0, because it compares odds of exposure in cases with odds of exposure in controls.
When the disease is rare, the OR approximates the relative risk (the rare disease assumption).
In the literature
Of 649 men with lung cancer, 647 smoked; of 649 matched controls, 622 smoked. This hospital case–control study helped establish smoking as a cause of lung cancer.Doll R, Hill AB. BMJ 1950;2:739–48.Common thesis mistake
Reporting “prevalence” or “incidence” from case–control data. Prevalence needs a cross-sectional sample; incidence needs a cohort.Intention-to-treat protects randomisation
Patients who take their pills differ from those who don't — even when the pills are placebo.
ITT analyses everyone in the group they were randomised to, whatever they actually took. It preserves the balance that randomisation created.
Comparing adherers with non-adherers breaks that balance: adherence is a marker of being healthier and more health-conscious (the “healthy adherer” effect). Look at the placebo arm.
In the literature
Coronary Drug Project: 5-year mortality was 20.0% on clofibrate vs 20.9% on placebo. Good clofibrate adherers had 15.0% mortality vs 24.6% for poor adherers — but placebo adherers showed the same gap (15.1% vs 28.2%).Coronary Drug Project Research Group. N Engl J Med 1980;303:1038–41.Common thesis mistake
Calling an analysis “ITT” after excluding patients who were lost to follow-up. State how missing outcomes were handled (for example multiple imputation) and give per-protocol only as a sensitivity analysis.Test enough subgroups and something will be “significant”
Every cell is a subgroup in which the treatment truly does nothing. Coral cells reached p < 0.05 anyway.
The chance of at least one false positive across k independent tests is 1 − 0.95k. With 20 subgroups, that's 64%.
Bonferroni tests each at α/k. It controls false positives but costs power; Holm's method is uniformly better. Better still: pre-specify a few subgroups and test for interaction, not separate p-values.
In the literature
ISIS-2's investigators split patients by astrological birth sign: aspirin appeared slightly harmful for Gemini and Libra, but clearly beneficial for everyone else. The point was deliberate — chance subgroup findings look convincing.ISIS-2 Collaborative Group. Lancet 1988;2:349–60.Common thesis mistake
Running 30 chi-square tests on a questionnaire and highlighting the two with p < 0.05 as findings. Pre-specify primary outcomes, and correct or label the rest as exploratory.Which statistical test should I use?
Answer three questions about your analysis. You'll get the test, its non-parametric alternative where relevant, and a published study that used it. For clustered, matched or repeated designs, see the next chapter.
Study designs: from design to the right analysis
The design decides the analysis. Pick a design and an outcome type to see how the study is built and the complete analysis plan your examiners will expect.
Try it: design detective
Read each fictional study summary. First name the design, then choose its analysis.
Before choosing any test, answer four questions about your design:
1. What is the unit of analysis? Individuals, clusters (villages, clinics) or studies. If you randomise villages, you analyse villages — or use models that account for them.
2. Are observations independent? Matched pairs, crossover periods, repeated visits and clustered children are correlated. They need paired tests, conditional models, mixed models or GEE.
3. What type of outcome? Binary, continuous, time-to-event or count decides the effect measure: RR or OR, mean difference, HR, or IRR.
4. Is confounding possible? Randomised trials balance confounders by design. Observational designs need adjustment chosen from subject knowledge.
Each design also has a reporting guideline (CONSORT, STROBE, STARD, PRISMA). Following it in your thesis answers most examiner questions before they are asked.
In the literature
The CONSORT extension for cluster randomised trials requires authors to report how clustering was handled in the sample size and the analysis, including the intracluster correlation coefficient.Campbell MK et al. BMJ 2012;345:e5661.Common thesis mistake
Analysing clustered, matched or repeated data as if every observation were independent. The point estimate may look fine, but the confidence intervals are too narrow and the p-values too small.Regression: fit the line yourself
Drag the sliders to place your own line through simulated birth-weight data. Least squares picks the line with the smallest sum of squared residuals — the red segments.
Try it: interpret a regression coefficient
Enter a coefficient (β) and its standard error from your software output. The tool converts it to the measure you report and writes the sentence.
Every regression model fits a linear predictor, β₀ + β₁x. What changes is how β is reported:
| Model | Outcome | Report |
|---|---|---|
| Linear | Continuous | β (mean change) |
| Logistic | Binary | OR = eβ |
| Cox | Time to event | HR = eβ |
| Poisson | Count / rate | IRR = eβ |
Check linear-model assumptions with residual plots: Linearity, Independence, Normal residuals, Equal variance. For logistic and Cox models, aim for roughly 10 events per predictor to avoid overfitting.
In the literature
RECOVERY's age-adjusted rate ratios and EMPA-REG OUTCOME's hazard ratios were both estimated with Cox regression. Each published HR is eβ from such a model, with its CI computed from the coefficient's standard error.RECOVERY, N Engl J Med 2021;384:693–704 · Zinman B et al., N Engl J Med 2015;373:2117–28.Common thesis mistake
Choosing covariates by stepwise selection on p-values. Choose confounders in advance from subject knowledge, and report unadjusted and adjusted estimates side by side.Meta-analysis: reading a forest plot
Six simulated trials. Tap a study to leave it out, increase the spread between studies, and switch between fixed- and random-effects pooling.
Try it: pool your own studies
One study per line: name, events treated, total treated, events control, total control (sample data below).
Each square is one study: its position is the effect, its size is the study's weight (1/SE², so bigger studies count more), and its line is the 95% CI. The diamond is the pooled estimate.
Fixed effect assumes one true effect shared by all studies. Random effects assumes true effects vary, adds the between-study variance τ² to every weight, gives small studies relatively more say, and widens the CI.
I² is the share of variation due to real differences rather than chance: roughly 25% low, 50% moderate, 75% high.
In the literature
The Cochrane Collaboration's logo is a forest plot of trials of antenatal corticosteroids before preterm birth. Pooled, the trials showed a clear fall in neonatal deaths years before the treatment was widely used — the case for systematic reviews in one picture.Crowley P, Chalmers I, Keirse MJ. Br J Obstet Gynaecol 1990;97:11–25.Common thesis mistake
Pooling studies that differ in population, dose or outcome definition just because the software allows it, then quoting I² without exploring why studies disagree.Read a trial's results tables like an examiner
A fictional zinc trial in under-fives, written to look like a published paper. Tap any cell to see what it tells you — and where the traps are.
Try it: write the results sentence
Pick an outcome row; the tool writes it the way a journal expects.
Table 1 describes the groups at baseline. In a randomised trial its job is to show the arms are similar — not to test whether they differ.
Table 2 gives the results. Read each row in this order: numbers with the outcome in each arm, the effect estimate, its 95% CI, then the p-value. Ask whether the CI excludes no effect, and whether the effect is clinically important.
Subgroup rows deserve suspicion: look for a test of interaction, not separate p-values.
In the literature
The CONSORT explanation and elaboration document advises against significance tests of baseline differences in randomised trials: any imbalance is due to chance by design. Judge imbalance by its size and how strongly the variable predicts the outcome.Moher D et al. BMJ 2010;340:c869.Common thesis mistake
Reading only the p-value column. A row with p = 0.48 and a CI from 0.14 to 2.50 does not show “no effect on mortality” — it shows the trial was far too small to tell.Statistical software: R, Stata, SPSS and Python
The statistics are the same in every package; only the commands differ. Pick an analysis to see it written in all four, then learn to read the output.
Try it: decode the output
The same logistic regression (outcome on smoking) as each package prints it. Tap any underlined number to see what it means.
Try it: which software suits you?
| Package | Cost | Style | Strong for |
|---|---|---|---|
| R | Free, open source | Code (RStudio) | Any method, graphics (ggplot2), reproducible reports |
| Stata | Commercial licence | Code or menus | Epidemiology, survey data, regression, panel data |
| SPSS | Commercial licence | Menus, with syntax | Standard tests, questionnaires, beginners |
| Python | Free, open source | Code (Jupyter) | Data handling, machine learning, automation |
Free point-and-click options built on R, such as jamovi and JASP, suit students without a licence who are not ready to code.
Whatever you use, save your code or syntax. Even in SPSS, the Paste button writes syntax for every menu action. A script lets you, your supervisor and an examiner rerun every number in your thesis.
Name the package and version in your methods section, for example: “Analyses were done in Stata 18 (StataCorp, College Station, TX) and R 4.4.”
In the literature
The SAMPL guidelines for basic statistical reporting ask authors to identify the statistical software package used, and to describe each method in enough detail that a knowledgeable reader with the data could verify the results.Lang TA, Altman DG. Int J Nurs Stud 2015;52:5–9.Common thesis mistake
Copying raw software output into the thesis. Examiners want a formatted table with effect estimates and 95% CIs, not pages of SPSS boxes — and never a coefficient on the log scale reported as if it were an odds ratio.Graphics: show the data, not just the summary
Simulated haemoglobin in two groups of 30. Both have almost the same mean — but switch chart types and see how much the bar chart hides.
Try it: which graph for my data?
A good figure lets the reader see the data, not only a summary. For continuous outcomes in small samples, plot every point (dot or strip plots) or the distribution (box or violin plots).
Always say what error bars show. SD describes spread in the data; SE describes precision of the mean and shrinks with sample size; a 95% CI is about twice the SE. Unlabelled error bars are uninterpretable.
Bars must start at zero, because their length encodes the value. Avoid 3D effects, pie charts with many slices, dual y-axes and decorative colour; label axes with units; use colour-blind-safe palettes.
In a thesis, every figure needs a self-explanatory caption: what is plotted, the sample size, and what the error bars or boxes represent.
In the literature
A review of physiology journals found bar graphs of continuous data were the norm, although very different datasets can produce identical bar graphs. The authors called for dot plots, box plots and violin plots that show the distribution, especially in small studies.Weissgerber TL et al. PLoS Biol 2015;13:e1002128.Common thesis mistake
“Dynamite plots” — bars of means with a single SE whisker — for small, skewed or bimodal samples, often with the y-axis cut to make a small difference look dramatic.Test yourself across every chapter
Twenty questions drawn at random from all nineteen chapters, many built around research scenarios. Each attempt gives a new mix.
Answer each question, read the explanation, then move on. At the end you get a score, a breakdown by chapter showing where to revise, and a review of every question you missed.
Your chapter progress and best exam score are saved in this browser only.
Found an error, or want a chapter added? Use the feedback form.
Press “Start the exam” to begin.