Back to the programme
Session 5 · 2 h

Tests for comparing percentages and means

Programme objectives:Tests for comparing percentagesTests for comparing means

Content: Which test? The type of the outcome decides · Contingency tables 2 × 2, 2 × 3, 3 × 4; χ² or Fisher · Comparing two means: Student’s t test · Paired data · Two quantitative variables: correlation, r and ρ · Interpreting beyond p.

Session 5 — slide 1 / 10

Which test? First, the type of the variable to compare

  • Qualitative outcome (SBP controlled: yes / no) → comparing percentages → χ² test, or Fisher’s exact test if counts are small.
  • Quantitative outcome (SBP in mmHg) → comparing means → Student’s t test, or Mann-Whitney if the distribution is not normal.
  • Two independent groups: different patients. The same patients measured twice (before / after) → paired tests.
Swipe to turn the page

Data to download

hypertension_trial_2026.csv

120 hypertensive patients randomised between two treatments, A and B. Blood pressure before and after three months. Simulated data for the course. 120 rows, 8 variables.

Download the CSV
Variable dictionary
VariableTypeContent
ididentifierpatient number
groupqualitative nominalA / B — treatment allocated at random
sexqualitative nominalF / M
agequantitative continuousyears
sbp_beforequantitative continuousSBP before treatment, mmHg
sbp_afterquantitative continuousSBP after three months, mmHg
controlledqualitative nominalYes if sbp_after < 140 mmHg
adverse_eventsqualitative nominalYes / No

Format: comma separator, decimal point, UTF-8 encoding — jamovi opens it with no settings. In Excel, use Data → From Text/CSV if the columns are not split.

cohort_efm1_2026.csv

200 outpatients: age, measurements, smoking, physical activity, blood pressure, blood glucose. Simulated data for the course. 200 rows, 11 variables.

Download the CSV
Variable dictionary
VariableTypeContent
ididentifierpatient number
sexqualitative nominalF / M
agequantitative continuousyears
height_cmquantitative continuouscentimetres
weight_kgquantitative continuouskilograms
bmiquantitative continuouskg/m², computed
smokingqualitative nominalYes / No — current smoker
physical_activityqualitative ordinalLow < Moderate < High
sbp_mmhgquantitative continuoussystolic blood pressure, mmHg
fasting_glucose_g_lquantitative continuousfasting blood glucose, g/L
hypertensionqualitative nominalYes if SBP ≥ 140 mmHg

Format: comma separator, decimal point, UTF-8 encoding — jamovi opens it with no settings. In Excel, use Data → From Text/CSV if the columns are not split.

Figures of the session (5) — download them for your own notes
jamovi workshop — session 5

Redo the three tests of the session on hypertension_trial_2026.csv: χ², Student’s t, paired t. Each result must match the slides.

  1. 1

    Compare the percentages of controlled patients

    • Analyses → Frequencies → Independent Samples — χ² test of association. Rows: group; Columns: controlled.
    • Statistics: tick χ² and Fisher’s exact test. Cells: observed and expected counts, row percentages.

    Expected result: A: 47 controlled out of 60 (78.3%); B: 34 out of 60 (56.7%). Expected counts A: 40.5 / 19.5, all ≥ 5. χ² = 6.42, p = 0.011; Fisher p = 0.019.

  2. 2

    Compare the mean SBP after treatment

    • Analyses → T-Tests → Independent Samples T-Test. Dependent variable: sbp_after; grouping variable: group.
    • Tick Student’s and Welch’s; Additional statistics: mean difference, confidence interval, descriptives; Assumption checks: normality (Shapiro-Wilk), homogeneity of variances (Levene).

    Expected result: Student: t = -2.39, df = 118, p = 0.019; difference -5.5 mmHg, 95% CI [-10.1, -0.9]. Welch: t = -2.39, p = 0.019.

  3. 3

    Before / after: the paired test

    • T-Tests → Paired Samples T-Test: drag sbp_before then sbp_after. Tick mean difference and confidence interval.

    Expected result: Mean difference 20.6 mmHg, 95% CI [18.6, 22.6], t = 20.9, df = 119, p < 0.001.

  4. 4

    Two quantitative variables: correlation

    • Open cohort_efm1_2026.csv. Analyses → Regression → Correlation Matrix: drag age and sbp_mmhg. Tick Pearson and Spearman, and Plots → Correlation matrix for the scatter plot.
    • Read the sign (direction), the size of r (strength) and p. Then try bmi against sbp_mmhg, and age against fasting_glucose_g_l.

    Expected result: Age × SBP: Pearson r = 0.46, p < 0.001; Spearman ρ = 0.39, p < 0.001 — positive, moderate.

  5. 5

    Going further

    • Redo the paired test within each group: Data tab → Filters → group == "A", then "B".
    • Compare adverse_events between A and B with a χ²: do we conclude? What does the size of the counts say?

    Expected result: Drop under A: 24.3 mmHg, CI [21.6, 27.0]; under B: 16.9 mmHg, CI [14.4, 19.4].