Skip to the content
How to use this manual: Copy the blank working table at the start of the Calculation into your record book and fill it as you compute (or run the check in R). The Calculation section shows the completed working, and the Result interprets the finding in a clinical context.

List of Practical Experiments

  1. Determination of sample size (dichotomous and continuous responses).
  2. Multiple logistic regression with two or three predictors.
  3. Analysis of a 2×2 crossover design.
  4. Analysis of a parallel-group design.
  5. Meta-analysis of clinical trials.

Experiment 1 — Determination of Sample Size

1. Problem

(a) A Phase III trial compares a new drug with placebo for preventing post-operative nausea; the control response rate is \(p_C = 0.45\) and a clinically meaningful new rate is \(p_T = 0.65\). (b) A trial compares an antihypertensive with placebo on change in SBP, with \(\sigma = 12\) mmHg and a meaningful difference \(\delta = 5\) mmHg. Find the required sample size per group.

2. Aim

To determine the per-group sample size for a dichotomous response (at \(\alpha = 0.05\), 80 % power) and a continuous response (at \(\alpha = 0.05\), 90 % power).

3. Formula

\[ n_{\text{dich}} = \frac{\left(z_{\alpha/2}\sqrt{2\bar p\bar q} + z_\beta\sqrt{p_Tq_T + p_Cq_C}\right)^2}{(p_T - p_C)^2}, \qquad n_{\text{cont}} = \frac{2\sigma^2(z_{\alpha/2} + z_\beta)^2}{\delta^2} \]

Applying it:

  1. Dichotomous: use \(\bar p = (p_T + p_C)/2\) and the two-proportion formula.
  2. Continuous: use the two-mean formula with \(z_{\alpha/2} = 1.96\), \(z_\beta = 0.842\) (80 %) or \(1.282\) (90 %).
  3. Round up and inflate for dropout.

4. Calculation

Blank working table:

Response\(n\) per groupWith 10 % dropout
Dichotomous
Continuous

(a) Dichotomous: \(\bar p = 0.55,\ \bar q = 0.45\); \(\sqrt{2\bar p\bar q} = 0.7036\), \(\sqrt{p_Tq_T + p_Cq_C} = \sqrt{0.2275 + 0.2475} = 0.6892\).

\(n = (1.96\times0.7036 + 0.842\times0.6892)^2/(0.20)^2 = (1.379 + 0.580)^2/0.04 = 3.838/0.04 = 95.9\).

(b) Continuous: \(n = 2(144)(1.96 + 1.282)^2/25 = 288\times10.51/25 = 121.1\).

Response\(n\) per groupWith 10 % dropout
Dichotomous96 (192 total)107 (214 total)
Continuous122 (244 total)136 (272 total)
CHECK IN R
power.prop.test(p1 = 0.65, p2 = 0.45, sig.level = 0.05, power = 0.80)$n   # dichotomous
power.t.test(delta = 5, sd = 12, sig.level = 0.05, power = 0.90)$n        # continuous
[1] 95.94245
[1] 122.0139

R agrees with the hand working: 95.9 rounds up to 96 per group. For the continuous endpoint R uses the t distribution, so it gives 122.0 where the normal approximation gives 121.1; both round up to 122.

5. Result

The trial needs 96 subjects per group for the dichotomous endpoint and 122 per group for the continuous endpoint (107 and 136 respectively after allowing for 10 % dropout).

Experiment 2 — Multiple Logistic Regression

1. Problem

In a diabetes trial the outcome is glycaemic control (HbA1c < 7 %; 1 = yes) for \(n = 80\) patients, with predictors \(X_1\) = treatment (1 = new drug), \(X_2\) = baseline HbA1c and \(X_3\) = age. Fit a multiple logistic regression and interpret the odds ratios.

PatientY\(X_1\)\(X_2\)\(X_3\)
1118.252
2009.161
3117.845
……………
80(full data set of 80 patients)

2. Aim

To estimate the logistic model \(\ln\!\frac{p}{1-p} = \beta_0 + \beta_1X_1 + \beta_2X_2 + \beta_3X_3\), obtain adjusted odds ratios and assess each predictor.

3. Formula

\[ \ln\!\left(\frac{p}{1-p}\right) = \beta_0 + \beta_1X_1 + \beta_2X_2 + \beta_3X_3, \qquad \text{OR}_j = e^{\hat\beta_j} \]

Applying it:

  1. Fit the model by maximum likelihood (glm(..., family = binomial)).
  2. Convert coefficients to odds ratios \(\text{OR} = e^{\hat\beta}\) with 95 % CIs.
  3. Assess fit (Hosmer–Lemeshow, AUC) and test each predictor.

4. Calculation

Blank working table:

Variable\(\hat\beta\)SEOR95 % CIp
Intercept——
Treatment (\(X_1\))
Baseline HbA1c (\(X_2\))
Age (\(X_3\))

Illustrative fitted results:

Variable\(\hat\beta\)SEOR95 % CIp
Intercept5.821.94——0.003
Treatment (\(X_1\))1.240.523.46(1.25, 9.57)0.017
Baseline HbA1c (\(X_2\))−0.890.250.41(0.25, 0.67)<0.001
Age (\(X_3\))−0.040.020.96(0.92, 1.00)0.046
model <- glm(Control ~ Treatment + BaselineHbA1c + Age, data = trial_data, family = binomial)
exp(cbind(OR = coef(model), confint(model)))                # odds ratios + CI
library(ResourceSelection); hoslem.test(trial_data$Control, fitted(model))   # goodness of fit
library(pROC); roc(trial_data$Control, fitted(model))$auc   # c-statistic

5. Result

The new drug roughly triples the odds of glycaemic control (OR = 3.46, p = 0.017) after adjustment; higher baseline HbA1c lowers the odds by 59 % per 1 % (OR = 0.41, p < 0.001); age has a small borderline effect (OR = 0.96, p = 0.046).

Experiment 3 — 2×2 Crossover Design

1. Problem

A 2×2 crossover trial compares a test (A) and reference (B) formulation in 20 volunteers (10 sequence AB, 10 sequence BA); the endpoint is \(C_{\max}\) (ng/mL). Test the treatment, period and carry-over effects. The within-subject differences (P1 − P2) are: AB: 2.4, 2.8, 1.5, 3.1, 1.1, 3.3, 2.2, 1.8, 1.6, 2.5; BA: −2.3, −1.8, −2.3, −2.1, −2.3, −2.1, −1.8, −2.3, −2.3, −2.3.

2. Aim

To estimate the treatment effect from the within-subject differences and test for a carry-over effect.

3. Formula

\[ \hat\tau_A - \hat\tau_B = \frac{\bar d_1 - \bar d_2}{2}, \qquad SE = \hat\sigma_d\sqrt{\tfrac1{n_1} + \tfrac1{n_2}}, \qquad t = \frac{\hat\tau_A - \hat\tau_B}{SE} \]

Applying it:

  1. Compute the mean difference \(\bar d_i\) per sequence; the treatment effect is \((\bar d_1 - \bar d_2)/2\).
  2. Pool the SDs, form the standard error, and test with a two-sample \(t\) (df = \(n_1 + n_2 - 2\)).
  3. Carry-over test (Grizzle): compare the subject totals \((P_1 + P_2)\) between sequences.

4. Calculation

Blank working table:

Sequence\(n\)\(\bar d_i\)\(s_i\)
AB
BA
Treatment effect / t / p
Sequence\(n\)\(\bar d_i\)\(s_i\)
AB102.230.72
BA10−2.160.21
Treatment effect / t / p2.195 ng/mL / 9.22 / < 0.001

Treatment effect \(= (2.23 - (-2.16))/2 = 2.195\); pooled \(\hat\sigma_d = 0.533\), \(SE = 0.533\times0.4472 = 0.238\), \(t = 2.195/0.238 = 9.22\) (df 18); 95 % CI \(= 2.195 \pm 2.101\times0.238 = (1.695, 2.696)\).

Carry-over (Grizzle): mean \((P_1 + P_2)\) = 96.63 (AB) vs 93.94 (BA), difference 2.69; the two-sample \(t\) on subject totals gives \(t = 1.37,\ p = 0.19\) — no significant carry-over, so the within-subject analysis is valid.

d_AB <- c(2.4,2.8,1.5,3.1,1.1,3.3,2.2,1.8,1.6,2.5)
d_BA <- c(-2.3,-1.8,-2.3,-2.1,-2.3,-2.1,-1.8,-2.3,-2.3,-2.3)
(mean(d_AB) - mean(d_BA)) / 2          # treatment effect
t.test(d_AB, d_BA, var.equal = TRUE)   # test

5. Result

Formulation A gives a significantly higher \(C_{\max}\) than B by \(2.195\) ng/mL (\(t = 9.22,\ p < 0.001\), 95 % CI 1.70–2.70), with no carry-over effect (\(p = 0.19\)).

Experiment 4 — Parallel-Group Design

1. Problem

A Phase III parallel trial compares Drug A and Drug B (50 patients each) on change in HbA1c (%): Drug A mean −1.82 (SD 0.95), Drug B mean −1.24 (SD 1.02). Also, glycaemic control (HbA1c < 7 %) is achieved by 32/50 on A and 21/50 on B. Analyse both endpoints.

2. Aim

To compare the mean HbA1c change (two-sample \(t\)-test, effect size, CI) and the control rates (chi-square, odds ratio).

3. Formula

\[ t = \frac{\bar x_1 - \bar x_2}{s_p\sqrt{2/n}}, \qquad d = \frac{\bar x_1 - \bar x_2}{s_p}, \qquad \chi^2 = \frac{N(ad - bc)^2}{(a+b)(c+d)(a+c)(b+d)} \]

Applying it:

  1. Continuous: pooled variance, two-sample \(t\), 95 % CI and Cohen's \(d\).
  2. Categorical: \(2\times2\) chi-square and the odds ratio.

4. Calculation

Blank working table:

AnalysisStatisticp
Two-sample t (ΔHbA1c)
Chi-square (control rate)
Odds ratio—

Continuous: \(s_p^2 = (49\times0.9025 + 49\times1.0404)/98 = 0.9714,\ s_p = 0.9856\); \(t = -0.58/(0.9856\times0.2) = -2.94\) (df 98, p = 0.004); 95 % CI \(= -0.58 \pm 1.984\times0.1971 = (-0.971, -0.189)\); Cohen's \(d = -0.588\).

Categorical: \(\chi^2 = 100(32\times29 - 18\times21)^2/(50\times50\times53\times47) = 4.86\) (df 1, p = 0.028); OR \(= (32\times29)/(18\times21) = 2.45\).

AnalysisStatisticp
Two-sample t (ΔHbA1c)t = −2.94, d = −0.590.004
Chi-square (control rate)χ² = 4.86 (df 1)0.028
Odds ratio2.45—
t.test(HbA1c_change ~ Drug, data = parallel_data, var.equal = TRUE)
chisq.test(matrix(c(32,18,21,29), nrow = 2, byrow = TRUE))
fisher.test(matrix(c(32,18,21,29), nrow = 2, byrow = TRUE))   # exact OR

5. Result

Drug A gives a significantly greater HbA1c reduction (difference 0.58 %, p = 0.004, medium-to-large effect \(d = -0.59\)) and a higher control rate (64 % vs 42 %, \(\chi^2 = 4.86,\ p = 0.028\), OR = 2.45).

Experiment 5 — Meta-Analysis of Clinical Trials

1. Problem

Six randomised trials compare aspirin with placebo for preventing cardiovascular events. Pool the odds ratios, assess heterogeneity and evaluate publication bias.

Trialn (Aspirin)Eventsn (Placebo)Events
trial131711483168186
trial220351092037142
trial325301832540212
trial434022093395251
trial551392985127347
trial644012654405302

2. Aim

To compute the pooled odds ratio (inverse-variance fixed effect), the heterogeneity statistics \(Q\) and \(I^2\), and check for publication bias.

3. Formula

\[ \widehat{\ln\text{OR}} = \frac{\sum w_i\ln\text{OR}_i}{\sum w_i}, \quad w_i = \frac{1}{SE_i^2}, \quad Q = \sum w_i(\ln\text{OR}_i - \widehat{\ln\text{OR}})^2 \]

Applying it:

  1. For each trial compute \(\text{OR} = ad/bc\), \(\ln\text{OR}\) and \(SE = \sqrt{\tfrac1a + \tfrac1b + \tfrac1c + \tfrac1d}\).
  2. Weight by \(w = 1/SE^2\); pooled \(\ln\text{OR} = \sum w\ln\text{OR}/\sum w\).
  3. Heterogeneity: \(Q = \sum w(\ln\text{OR} - \overline{\ln\text{OR}})^2\), \(I^2 = \max(0, (Q-df)/Q)\).
  4. Publication bias: funnel plot and Egger's test.

4. Calculation

Blank working table:

TrialORln(OR)SEWeight (%)
trial1–6
Pooled OR / Q / I²

For trial1: \(a = 148,\ b = 3023,\ c = 186,\ d = 2982\); \(\text{OR} = (148\times2982)/(3023\times186) = 0.785\), \(\ln\text{OR} = -0.242\), \(SE = 0.113\).

TrialORln(OR)SEWeight (%)
trial10.785−0.2420.11312.7
trial20.755−0.2810.1319.4
trial30.856−0.1550.10514.7
trial40.820−0.1990.09717.3
trial50.848−0.1650.08224.4
trial60.870−0.1390.08721.5
Pooled OR / Q / I²0.832 (95 % CI 0.768–0.900) / Q = 1.23 (p = 0.94) / I² = 0 %

Pooled \(\ln\text{OR} = -0.184 \Rightarrow \text{OR} = 0.832\). Since \(Q = 1.23 < df = 5\), \(\hat\tau^2 = 0\) and the random-effects estimate equals the fixed-effect one. Egger's test (intercept \(-0.42,\ p = 0.65\)) shows no publication bias; the funnel plot is symmetric.

library(meta)
metabin(event.e = c(148,109,183,209,298,265), n.e = c(3171,2035,2530,3402,5139,4401),
        event.c = c(186,142,212,251,347,302), n.c = c(3168,2037,2540,3395,5127,4405),
        studlab = paste0("trial", 1:6), sm = "OR", method = "MH")
# forest(...) ; funnel(...) ; metabias(..., method = "egger")

5. Result

Aspirin reduces cardiovascular events: pooled OR = 0.832 (95 % CI 0.768–0.900, p < 0.001) — about a 17 % reduction in odds. Heterogeneity is negligible (\(I^2 = 0\%\)) and there is no evidence of publication bias, so the pooled estimate is robust.

Lab Record Format (to be followed for every experiment)

  1. 1. Problem — the trial data and the analytical question.
  2. 2. Aim — the estimate or test the experiment produces.
  3. 3. Formula — the formula, then the numbered steps that apply it.
  4. 4. Calculation — the filled table with the arithmetic (or software output).
  5. 5. Result — the inference, with interpretation in the clinical context.