A/B Testing Strategy for Topic Recommendations
Statistics & ExperimentsModel answerLast updated
Design an end-to-end recommendation A/B test covering unit selection, power calculations with clustering adjustments, metric guardrails, and bias controls.
You are tasked with designing an experiment to evaluate a new topic/hashtag recommendation system starting on 2025-09-01.
Prepare a comprehensive experimental plan covering the following five areas:
- Randomization Unit & Network Effects: Select the appropriate unit of randomization (e.g., user, session, impression) and justify your choice. Discuss potential violations of the Stable Unit Treatment Value Assumption (SUTVA) and how to mitigate them.
- Experiment Architecture & Ramp Plan: Outline criteria for user eligibility, exposure triggering, deployment phases, and mechanisms to prevent cross-variant contamination.
- Metric Framework: Define a primary conversion metric along with at least three critical guardrails (including non-inferiority tolerances).
- Power Analysis & Sample-Ratio Mismatch (SRM): Given a baseline conversion rate of 4.0%, a relative Minimum Detectable Effect (MDE) of +5%, two-sided $\alpha = 0.05$, and power = 0.80:
- Calculate the required sample size per variant for a user-level analysis.
- Adjust the required sample size for a session-level analysis assuming an average of $m = 5$ sessions per user and an intraclass correlation of $\rho = 0.02$.
- Specify an SRM monitoring protocol.
- Bias Control & Integrity: Explain techniques for variance reduction (e.g., CUPED), handling of novelty or primacy bias, sequential analysis rules, and minimum runtime requirements.
Hints
Hint 1
Selecting a user-level unit ensures persistent user experiences across sessions, but session-level metrics require cluster-robust corrections.
Hint 2
To compute absolute MDE, multiply the baseline rate by the relative change: 4.0% * 5% = 0.2 percentage points.
Hint 3
Triggered analysis isolates affected users, but control units must log a counterfactual trigger to maintain baseline comparability.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Randomization Unit Selection & Network Effects
Unit Selection
The experiment should use User-Level Randomization, generated deterministically via hashing: $$\text{bucket} = \text{hash}(\text{user_id} + \text{experiment_salt}) \pmod{1000}$$
Evaluation of Alternatives
- Impression/Session Level: Unsuitable for this task. Topic follow decisions persist across user sessions. Assigning a user to treatment in one session and control in another creates cross-session leakage—a follow in a control session might be driven by a recommendation seen in a prior treatment session. It also creates a fragmented, inconsistent user experience.
- User Level: Preserves user experience consistency and ensures downstream behavioral tracking remains tied to a single variant.
Network Interference & SUTVA Violations
While user-level bucketing prevents intra-user leakage, it remains susceptible to marketplace or social graph spillover (SUTVA violations). For instance, if treatment users follow more topics, creator engagement shifts, modifying trending algorithms that control users also see. This network spillover typically attenuates the observed effect, biasing results towards the null.
- Mitigation Strategy: If pre-test graph analyses show high clustering, deploy Cluster-Based Randomization (randomizing by connected subgraphs or geographic markets). If user-level randomization is retained, preserve a long-term 5% global holdout arm to track ecosystem-wide spillover over extended horizons.
2. Experiment Architecture, Rollout Plan, & Contamination Controls
Exposure Triggering & Counterfactual Logging
To maximize statistical power, analyze data using triggered exposure:
- Users enter the experiment assignment pool upon login, but enter the evaluation cohort only after reaching an active recommendation surface.
- Control users log a counterfactual exposure event at the exact point they would have received a recommendation. This ensures identical entry conditions across both variants.
Deployment Ramp Schedule
| Phase | Allocation (T/C) | Focus / Objective |
|---|---|---|
| Canary | 1% / 1% | Log validation, crash rates, latency impact, immediate SRM check |
| Ramp | 5% / 5% | Metric pipeline stability, guardrail health check |
| Full Run | 50% / 50% (of eligible traffic) | Primary evaluation period |
Calendar Note: September 1, 2025 falls on US Labor Day. Because holiday traffic exhibits non-standard behavior, the test duration must extend past the holiday week to capture representative weekday and weekend usage.
Contamination Prevention
- Sticky Assignment: Hashing relies strictly on server-side
user_id, guaranteeing consistency across multiple devices and app re-installs. - Layer Isolation: Run the experiment within a mutually exclusive feature layer to avoid interference with concurrent search or feed tests.
- Feature Isolation: Ensure recommendation models servicing the control group do not consume real-time signals generated exclusively by treatment variant activity.
3. Metric Framework
Primary Metric
- 24-Hour Recommended Topic Follow Rate: Proportion of triggered users who follow at least one recommended topic within 24 hours of first exposure. $$\text{Primary Metric} = \frac{\text{Exposed users who follow } \ge 1 \text{ recommended topic within 24h}}{\text{Total exposed users}}$$ Rationale: Formulated as a binary indicator per user, generating independent and identically distributed (i.i.d.) observations at the unit of randomization.
Guardrail Metrics
| Metric | Type | Non-Inferiority Tolerance | Purpose |
|---|---|---|---|
| Daily Session Duration | Engagement | $< 0.5%$ relative decline | Guard against cannibalizing broader app engagement. |
| Policy-Violating Follow Rate | Platform Safety | $0%$ tolerance (No stat-sig increase) | Ensure recommendations do not promote harmful or low-quality topics. |
| p99 Recommendation Latency | System Health | $< 15\text{ ms}$ increase | Prevent complex scoring models from slowing down UI response times. |
| 7-Day Topic Unfollow Rate | Retentive Quality | $< 1.0%$ relative increase | Detect low-intent follows that revert shortly after exposure. |
4. Power Calculation & SRM Protocols
Parameter Set
- Baseline conversion rate ($p_1$): $0.040$
- Relative MDE: $+5%$ $\rightarrow$ Absolute MDE ($\delta$): $0.040 \times 0.05 = 0.002$
- Target conversion rate ($p_2$): $0.042$
- Significance level ($\alpha$): $0.05 \rightarrow z_{\alpha/2} = 1.960$
- Power ($1 - \beta$): $0.80 \rightarrow z_{\beta} = 0.842$
A. User-Level Power Calculation
Using standard two-sample binomial proportion variance formulas:
$$\sigma^2 = p_1(1 - p_1) + p_2(1 - p_2) = (0.040 \times 0.960) + (0.042 \times 0.958) = 0.03840 + 0.040236 = 0.078636$$
$$n_{\text{arm}} = \frac{(z_{\alpha/2} + z_{\beta})^2 \cdot \sigma^2}{\delta^2} = \frac{(1.960 + 0.842)^2 \cdot 0.078636}{(0.002)^2} = \frac{7.8512 \cdot 0.078636}{0.000004} \approx \mathbf{154,350 \text{ users per arm}}$$
B. Clustered Session-Level Power Adjustment
If metrics are evaluated at the session level rather than aggregated per user, repeated sessions per user introduce variance inflation measured by the Design Effect (DE):
$$\text{DE} = 1 + (m - 1)\rho$$
With average sessions per user $m = 5$ and intraclass correlation $\rho = 0.02$:
$$\text{DE} = 1 + (5 - 1)(0.02) = 1.08$$
$$\text{Adjusted } n_{\text{arm}} = n_{\text{arm, unclustered}} \times \text{DE} = 154,350 \times 1.08 \approx \mathbf{166,698 \text{ users per arm}}$$
Note: Aggregating to one binary outcome per user eliminates clustering inflation ($\text{DE} = 1$). If session-level observations are analyzed directly, cluster-robust standard errors (CRSE) or the delta method must be applied to prevent inflated false-positive rates.
C. Sample-Ratio Mismatch (SRM) Protocol
- Test Method: Execute a daily Chi-Square ($\chi^2$) Goodness-of-Fit test comparing observed assignment counts to the target 50/50 split.
- Threshold: Use a strict alpha threshold of $\alpha = 0.001$.
- Action: If an SRM is detected ($p < 0.001$), pause reporting readouts immediately. Investigate potential sources: asymmetric crash rates dropping logs in treatment, differential network latency, or inconsistent triggering logic.
5. Bias Control & Experimental Integrity
Variance Reduction (CUPED)
Apply CUPED (Controlled-experiment Using Pre-Experiment Data) to enhance metric sensitivity:
$$\hat{Y}_{\text{CUPED}} = Y - \theta (X - E[X]), \quad \text{where } \theta = \frac{\text{Cov}(Y, X)}{\text{Var}(X)}$$
- Pre-Period Covariate ($X$): Topic follow count or engagement rate logged over the 14 days prior to experiment launch.
- Impact: With a correlation $r = \text{Corr}(Y, X) \approx 0.50$, metric variance contracts by $(1 - r^2) = 0.75$, reducing required sample size by up to $25%$.
- Cold-Start Strategy: For new users lacking pre-experiment history, set $X = \bar{X}$ and include an explicit binary flag indicating a missing baseline.
Novelty and Primacy Effects
- Novelty Effect: Users may engage with new recommendation interfaces out of initial curiosity, inflating short-term metrics.
- Primacy Effect: Users may initially ignore modified UI patterns due to established habits.
- Handling Strategy: Track the treatment effect over time. A novel feature will show decaying uplift over the test duration. Calculate readouts on stabilized cohorts (e.g., users exposed after Day 7) to confirm persistent impact.
Sequential Testing & Minimum Duration
- Minimum Runtime: Run the experiment for a minimum of 14 full days to capture two complete weekly business cycles and account for post-holiday normalization.
- Continuous Monitoring: If early peeking is required for safety monitoring, use Group Sequential Design (e.g., O'Brien-Fleming boundaries) or mSPRT (Always-Valid p-values) to control overall Type I error rates.