Plan and analyze an A/B test
AmazonData Scientist · Technical ScreenLast updated
This question tests the ability to design a statistically rigorous A/B test by accounting for clustered randomization, sequential testing boundaries, and multiple comparison corrections.
The Problem
Amazon is launching a new 'One-Click Prime' checkout feature. You are tasked with designing an A/B test to measure the impact on the conversion rate, currently 10%. You aim to detect a minimum detectable effect (MDE) of 0.5% (relative lift) with 80% power at a significance level (alpha) of 0.05.
However, there are two constraints:
- Clustered Variance: Users belong to households. You observe an intra-class correlation coefficient (ICC) of 0.05. The average household size is 2.5 users. You must account for the design effect in your sample size calculation.
- Sequential Monitoring: The team wants to check results daily for 10 days to potentially stop the test early if a significant result is found. You must maintain the overall family-wise error rate at 0.05.
Task
- Calculate the required sample size ($N$) for a standard A/B test (ignoring clusters and sequential testing).
- Adjust $N$ to account for the design effect due to household clustering.
- Briefly explain how you would adjust the p-value threshold for the sequential monitoring to ensure the 0.05 alpha is preserved.
Constraints & Definitions
- Use the standard normal approximation for power calculations: $N = [Z_{alpha/2} + Z_{beta}]^2 * [p(1-p) * 2] / [delta^2]$.
- Design Effect ($DE$) = $1 + (m - 1) * ICC$, where $m$ is the average cluster size.
- Assume $Z_{0.025} = 1.96$ and $Z_{0.20} = 0.84$.
Example
If the variance of the mean of a cluster is inflated, the effective sample size is reduced. For a total of 10,000 users, if the design effect is 1.07, the effective sample size is approximately 10,000 / 1.07.
Hints
Hint 1
First, calculate the base sample size required per arm using the power formula for proportions, keeping in mind the delta is 0.0005 (0.5% of 0.10).
Hint 2
Multiply your base sample size by the design effect calculated from the ICC and average household size to account for the lack of independence within clusters.
Hint 3
For sequential testing, mention the O'Brien-Fleming or Pocock boundaries as methods to control the overall error rate when performing multiple looks at the data.
Follow-up questions
- How would you handle a scenario where the conversion rate is not independent over time, such as a strong day-of-week effect?
- If we were testing 10 different UI variations simultaneously instead of just one, how would you adjust the statistical threshold?
- What diagnostic metrics (e.g., A/A test, SUTVA violation checks) would you inspect before trusting the results of this experiment?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.