Week 12 · Capstone · Analyze a randomized experiment

Report an effect, quantify uncertainty, and stress-test the conclusion.

← Week 11 · Subject contents

Report an effect, quantify uncertainty, and stress-test the conclusion.

Work through the problem

An experiment assigned six independent users to each of two arms. The target is a difference in mean minutes saved. Compute Δ = mean(treatment)−mean(control). Compare the exact randomization p-value with a bootstrap interval that resamples within each arm. The former tests a sharp no-effect null. The latter describes approximate uncertainty about the mean difference.

The large treatment outcome could be valid or a measurement error. Report the primary result with every recorded observation. As a sensitivity check, recompute after excluding that observation and describe the change. The exclusion is exploratory unless the rule was set before the experiment. A small trial cannot establish the effect for every user group.

Run the Python lab

from itertools import combinations
import numpy as np
control = np.array([0, 1, 2, 3, 3, 4])
treatment = np.array([1, 2, 3, 4, 4, 12])
delta = treatment.mean() - control.mean()
pool = np.r_[control, treatment]
null = []
for group in combinations(range(12), 6):
    mask = np.isin(np.arange(12), group)
    null.append(pool[mask].mean() - pool[~mask].mean())
p = np.mean(np.abs(null) >= abs(delta) - 1e-10)
rng = np.random.default_rng(9)
bootstrap = rng.choice(treatment, (20000, 6)).mean(1) - rng.choice(control, (20000, 6)).mean(1)
print(f"Difference {delta:.3f}, exact p {p:.3f}")
print("Bootstrap 95% interval:", np.quantile(bootstrap, [.025, .975]).round(3))
print("Without highest outcome:", round(treatment[:-1].mean() - control.mean(), 3))
assert np.isclose(delta, 13/6)

Output from the lab

Difference 2.167, exact p 0.303
Bootstrap 95% interval: [-0.5    5.504]
Without highest outcome: 0.633

Practice

  1. What would you tell a decision maker?

Check your reasoning

  1. The estimated gain is about 2.17 minutes. The interval is wide and the estimate falls to about 0.63 minutes when the highest outcome is removed. Collect more data and predefine an outlier policy.

← Week 11 · Subject contents

Further reading · MIT 18.650 · Statistics for Applications