7 routes42 sections324 units

Unit 4.7 · about 5 h

78 / 324

Randomized experiment design, power and MDE

The design determines which uncertainty calculation is valid. Sample size follows from the effect worth detecting and the independent units available, not from how many telemetry rows can be collected.

  • derive
  • measure

You can now

  • Specify an estimand, randomization unit, analysis unit, primary metric, guardrails, practical threshold and stopping/multiplicity policy before an experiment.
  • Derive normal-approximation power, sample size and minimum detectable effect for two independent equal-variance arms.
  • Audit clustering, interference, attrition, sample-ratio mismatch and post-treatment segment selection before interpreting an effect.

Covers

  • Randomization, units, metrics and experiment design
  • Power and minimum detectable effect

Study, in this order

4 steps

  1. 14.310x Lecture 15: randomized comparisons
    MIT 14.310x - Data Analysis for Social Scientists

    Slides 2 to 8: average treatment effects, difference in means, variance, intervals and testing

    Depth · Separate finite-population randomization variance from the independent-superpopulation normal model used in this card's power check. Stop before the Oregon example.

  2. 14.310x Lecture 13: power calculations
    MIT 14.310x - Data Analysis for Social Scientists

    Slides 75 to 83: power inputs, normal approximation, stratification and clustering

    Depth · Retain both rejection tails when checking power. The sample-size shortcut drops a small tail and is an approximation, not an exact equality.

  3. 14.310x Lecture 22: units and spillovers
    MIT 14.310x - Data Analysis for Social Scientists

    Slides 2 to 4, interventions, units and stratification; slides 10 to 17, spillovers and two-step randomization

    Depth · Use the labor-market example to explain interference. Skip the detailed outcome tables and the later rice-program case.

  4. Trustworthy experimentation during the experiment
    Patterns of trustworthy experimentation

    Capture Unexpected Effects Early with a Complete Metric Set, including the taxonomy table; Measure Early and Often; Set Up Alerts to Detect Unintended Degradations; Use Segments that are Stable during the A/B Test; Segment by Date

    Depth · Use the operational checklist, not its word 'guarantees' for segment validity. Stable segments and no detected sample-ratio mismatch do not prove exchangeability, prevent false alarms or establish correct uncertainty. Separate safety monitoring from fixed-horizon efficacy inference.

Focus on

  • Specify assignment and analysis units before choosing a standard error. Difference in means estimates an intention-to-treat effect of assignment when outcomes are observed without selection. Treatment receipt and post-treatment activity are different estimands.
  • For independent arms with \(n\) observations each and known common variance \(\sigma^2\), \(D = \text{mean}(T) - \text{mean}(C)\) has variance \(2\sigma^2/n\). With \(\lambda = \delta/\text{SE}\) and \(c = z(1 - \alpha/2)\), two-sided power is \(1 - \Phi(c - \lambda) + \Phi(-c - \lambda)\).
  • For positive \(\delta\) and a negligible lower tail, \(n\) per arm is approximately \(2\sigma^2[z(1 - \alpha/2) + z(1 - \beta)]^2/\delta^2\). MDE reverses this equation. Distinguish per-arm \(n\) from total \(2n\) and absolute outcome change from relative percentage change.
  • Predeclare one primary metric and how guardrail decisions and multiple metrics will be handled. Test observed assignment counts against the configured allocation, not an assumed 50/50 split. Investigate SRM rather than treating balanced counts as proof that logging is unbiased.

Reproduce closed-book

Derive the difference-of-means variance by adding independent arm variances, then derive the two-tail power expression and the approximate per-arm sample size. By hand set \(\alpha = 0.05\), target power = 0.8, \(\sigma = 1\) and \(\delta = 0.2\): the shortcut rounds up to \(n = 393\) per arm, total 786. Use NumPy float64 and scipy.stats.norm to compute c = norm.ppf(0.975), SE = sqrt(2/393), approximate MDE = (c + norm.ppf(0.8))*SE, and exact normal-model two-sided power = norm.sf(c - delta/SE) + norm.cdf(-c - delta/SE). Rounded values are SE 0.07134, MDE 0.1999 and power 0.8006. Check by sampling sufficient statistics, not individual rows: rng = numpy.random.default_rng(47); first control = rng.normal(0, 1/sqrt(393), size=20000), then treatment = rng.normal(0.2, 1/sqrt(393), size=20000). Reject when abs((treatment - control)/SE) > c. Power is 0.7988; its absolute difference from exact power is 0.0018 or less, with a Monte Carlo acceptance tolerance of 0.01. Explain why the same calculation does not apply to 393 observations that come from only a few independent clusters. Seeded values came from NumPy 2.5.4 with SciPy 1.18.1.

Traps

  • Counting repeated events from the same randomized user as independent participants. More rows need not add independent information.
  • Using a significant pilot's selected effect as the unquestioned power input. Winner's curse can make the planned experiment too small.
  • Choosing a favorable metric, duration or active-user subgroup after seeing results. Those choices change the estimand and the error policy.

Practice

18.05 Problem Set 8, Problem 3: radar-gun threshold and power

Problem 3(a), 3(b)(i to ii) and 3(c), z-test, p. 2: null, threshold, power at 45 mph and number of cameras

Attempt before reading the official solutions linked on the course Problem Sets page. This is a one-sided test, unlike the reproduce check. The section mini-project should add a pre-analysis plan, assignment-unit audit, SRM and guardrail decision rules.

Self-test

  1. Why does halving the target effect require about four times as many observations?

  2. Prove equal allocation minimizes variance when total N and common arm variance are fixed.

  3. Can passing SRM and finding stable pre-treatment segments establish a causal effect?

  4. What is wrong with deciding from \(p\) alone even in a valid experiment?

Completion criterion

Stop when

You derive power and per-arm sample size, pass the Monte Carlo check, solve the radar-gun problem, and can explain why clustered rows or post-treatment segments invalidate a naive experiment analysis.

Mark passed, then open 4.8 Only mark this when you can do it without notes.

Leads to

Resources for this unit

Also in this section

  • MIT 18.05 - Inference practice
    MIT OpenCourseWarerequiredpractice
    Use classes 17-20, 22-24 and 26 with their problem sets for tests, intervals, bootstrap and regression.
  • Causal Inference: What If
    Hernán & Robinsrequiredtheory
    Read Chapters 1-3 and 6-8 for causal effects, DAGs, confounding, selection bias and identification reasoning.
  • Always Valid Inference
    Johari, Pekelis & Walshdepthdepth
    Use the introduction and worked motivation to understand optional-stopping failure. Reproducing the theory is outside this gate.
  • Probabilistic Machine Learning: An Introduction
    Kevin P. Murphyreferencetheory
    Use the April 18, 2025 online edition: Sections 4.2.3 to 4.2.5, 4.5.1 and 4.6.4.1 for Bernoulli and Gaussian MLE/MAP; the definition and central intervals in 4.6.6; 2.1.2 and 11.7.4 for predictive uncertainty. Exercises 4.1 and 4.2 supply derivation practice.
  • Permutation nulls and false discovery control
    SciPyreferencereference
    Read permutation_test Notes, Unpaired statistics, for exchangeability and exact partitions; false_discovery_control Notes and the named thrombolysis example for Bonferroni and Benjamini-Hochberg. Use as an independent implementation oracle, not as a substitute for stating assumptions.
  • Probability calibration: the statistical property
    scikit-learnreferencereference
    Read the opening calibration definition, the proper-scoring-rule note, and Section 1.16.1, Calibration curves. Stop before recalibration methods; the later Classical ML unit implements them.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels