Online experiment plan for a new ad ranking model
Statistics & ExperimentsModel answerLast updated
Design an A/B test to evaluate whether a new ad recommendation model should replace the production system, covering experimental setup, metrics, and launch criteria.
You work on an advertising platform and have developed a new recommendation model for ranking ads. Before deploying it to production, you need to validate its performance through controlled experimentation.
Design a comprehensive test plan addressing:
a) Experimental setup
Choose your randomization unit (options: user-level, session-level, impression-level, advertiser-level, or auction-level). Justify your choice considering marketplace dynamics like shared advertiser budgets, auction competition between treatment and control, and repeat user exposure. Explain how you'll prevent contamination between groups. Should you run an initial validation test? Describe your traffic ramp strategy.
b) Metric selection
Identify one primary metric for the launch decision and define at least three guardrail metrics covering advertiser outcomes, user experience, and system performance. For click-through rate, explain whether you'd compute it as a mean-of-ratios or ratio-of-means and why.
c) Sample size and test length
Given a baseline revenue-per-thousand-impressions (RPM) of $0.50 and an expected 1.5% improvement, walk through your approach to calculating required sample size for α=0.05 and 80% power. What variance parameters do you need and how would you estimate them? What variance reduction techniques would you apply?
d) Validation procedures
List specific checks you'd perform before and during the experiment to ensure result validity. Address issues like traffic allocation imbalances, covariate distribution, novelty effects, seasonality, advertiser composition shifts, outlier treatment, and statistical corrections for continuous monitoring.
e) Results visualization
You receive a time-series chart showing daily CTR for control and treatment over 28 days. Critique this visualization approach and propose concrete improvements covering: confidence intervals and effect size display, noise reduction, documentation of traffic changes, handling of weekend patterns and missing data, and presentation of heterogeneous effects across placements or user segments.
f) Launch decision framework
Define an explicit rule for when to stop the test and make a launch decision. Include how you'd handle sequential testing corrections, what you'd do if guardrails move negatively while the primary metric improves, and how you'd validate longer-term effects after launch.
Hints
Hint 1
Marketplace experiments have spillover issues: treatment and control share advertiser budgets and compete in the same auctions. Consider how to isolate these effects.
Hint 2
Revenue metrics are heavy-tailed with high user-level variance. Think about variance reduction methods like regression adjustment and how to compute standard errors when your metric is a ratio.
Hint 3
Looking at results repeatedly during an experiment increases false positive risk. You need either a sequential testing framework or a pre-committed analysis schedule.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
a) Experimental setup
Randomization unit: user-level with budget isolation.
Let's compare the alternatives:
- Impression or auction-level: Individual users would experience both models across different ad requests, creating severe contamination. You couldn't measure user-level engagement effects, and learning effects would blur across conditions.
- Session-level: Same contamination problem. Users have multiple sessions, so both models affect the same user.
- Advertiser-level: Too few units for adequate statistical power (hundreds of advertisers vs. millions of users). More critically, treatment and control advertisers compete in the same auctions, causing interference—if treatment bids more aggressively, it affects control advertisers' win rates.
- User-level: Provides millions of independent units and consistent user experience. The challenge is budget spillover: both groups draw from shared advertiser budgets, so if treatment wins more auctions early in the day, it may deplete budgets that control would have used, artificially inflating the effect.
Solution: Partition each advertiser's budget proportionally to the traffic split. If you run 50/50, each advertiser gets two isolated budget pools. Treatment and control then operate as separate sub-markets with independent pacing logic.
Preventing contamination:
- Hash users deterministically using user ID + experiment salt
- Exclude users without stable identifiers or link multi-device users to one account
- Keep this experiment in a separate layer from other ranking tests
- Log treatment assignment on every impression for verification
Initial validation: Yes, run an A/A test (identical models in both arms) for one week. This validates your pipeline, confirms variance estimates match predictions, checks that your SRM detection works, and verifies your false positive rate calibration.
Ramp plan:
- Start at 1% vs 1% for 1-2 days—catch crashes and severe issues
- Expand to 5% vs 5% for several days—monitor guardrails closely
- Ramp to 50% vs 50% (or 20% vs 20% if risk tolerance is lower) for primary analysis
- After positive decision, launch to 100% while maintaining a 1-5% long-term holdback
b) Metric selection
Primary metric: Revenue per user (equivalently, RPM if impression volume is fixed). This directly measures platform revenue impact while preventing the model from "winning" by simply showing more ads.
Guardrail metrics:
| Stakeholder | Metric | Rationale |
|---|---|---|
| Advertisers | Cost per acquisition (CPA), using 7-day click / 1-day view attribution | Protects against winning through inflated prices that degrade advertiser ROI |
| Advertisers | Budget delivery rate | Percentage of advertisers hitting their daily budgets; detects pacing failures |
| Users | Ad feedback signals (hides, reports, negative reactions) | Early indicator of ad quality degradation |
| Users | Return rate and session depth | Measures longer-term engagement impact |
| Platform | Latency (p95, p99) and error rate | Ensures the new model doesn't degrade serving performance |
CTR computation: ratio-of-means.
- Ratio-of-means: (total clicks) / (total impressions) across all users in each arm. This matches how the business defines CTR and gives each impression equal weight.
- Mean-of-ratios: Average of each user's personal CTR. This weights all users equally regardless of activity level, creates undefined values for users with zero impressions, and measures a different quantity than business CTR.
Use ratio-of-means. Since users (the randomization unit) generate multiple correlated impressions, you need clustered variance estimation—standard binomial variance will be too small. Use the delta method with per-user aggregated clicks and impressions, or bootstrap resampling at the user level.
c) Sample size and duration
Effect size: 1.5% × $0.50 = $0.0075 lift in RPM.
Sample calculation: The standard formula for comparing two means is:
n = 2(z_{α/2} + z_{β})² σ² / δ²
At α=0.05 (z=1.96) and power=0.8 (z=0.84), the multiplier is approximately 16.
For a ratio metric like RPM, the critical parameter is the coefficient of variation (CV = σ/μ). Revenue is highly right-skewed—a small fraction of users generate most revenue—so CV around 2-4 is typical. At CV=3:
n ≈ 16 × (3 / 0.015)² ≈ 640,000 users per arm
Variance reduction techniques:
-
CUPED (regression adjustment): Use each user's pre-experiment revenue as a covariate. If pre/post correlation is ρ≈0.6, variance drops by (1-ρ²) ≈ 64%, reducing required sample to ~400k per arm.
-
Stratification: Pre-stratify by country, platform, and user activity level. Estimate treatment effect within strata then combine.
-
Winsorization: Cap extreme values at the 99.9th percentile to reduce heavy-tail variance without removing legitimate high-value users.
Variance inputs needed:
- Per-user revenue mean, variance, and covariance with impressions from 4+ weeks of historical logs
- Pre-period correlation between historical and experimental-period revenue
- Validate all estimates against the A/A test
Duration: Even at large scale, run at least 14 days (two full weeks) to:
- Capture weekly seasonality (weekday vs. weekend patterns differ substantially)
- Allow novelty effects to stabilize
- Cover the 7-day attribution window for conversion metrics
- Let advertiser budget pacing reach steady state
d) Validation procedures
Pre-experiment checks:
- Verify covariate balance: test that treatment and control have similar distributions of pre-period revenue, activity, geography, and device type (standardized mean differences should be <0.1)
- Confirm random assignment is independent of other concurrent experiments
- Document all metric definitions, analysis procedures, and decision criteria before unblinding
During experiment:
-
Sample ratio mismatch (SRM): Daily χ² test on user counts in each arm (alert if p<0.001). Break down by segment to identify the source if SRM occurs.
-
Logging consistency: Verify impressions per user and auction participation rates match between arms.
-
Novelty and learning effects:
- Plot daily treatment effect over time
- Compare first week vs. second week
- Split users by exposure (newly exposed vs. seen treatment for >7 days)
-
Seasonality handling: Always analyze over complete weeks. Flag major holidays or external events (sporting events, news spikes) that create unusual patterns.
-
Advertiser composition: Check whether spend distribution across verticals or advertiser size tiers shifts between arms. Budget isolation should prevent this—verify it works.
-
Outlier handling:
- Define winsorization rules before unblinding
- Remove bot traffic and fraud before analysis
- Report results both with and without outlier adjustments
-
Multiple testing:
- Primary metric gets no adjustment
- Apply Bonferroni or Holm correction across guardrails
- Use Benjamini-Hochberg FDR control for exploratory segment cuts
- Treat segment heterogeneity as hypothesis-generating, not confirmatory
e) Results visualization improvements
A simple time-series of raw CTR in each arm is inadequate for decision-making. Improvements:
1. Show relative lift and absolute difference with uncertainty quantification. Plot:
- Treatment effect (difference or ratio) over time with 95% confidence bands
- Cumulative effect stabilizing as sample grows
- This makes decision-relevant signal clearer than two overlapping lines
2. Handle volatility appropriately:
- Show both raw daily points and smoothed trend (7-day moving average or LOWESS)
- Raw points reveal anomalies; smoothing shows signal through noise
- Include both views rather than choosing one
3. Document experimental changes:
- Mark vertical lines when traffic percentage changed
- Annotate current sample size and power
- Show when holdout groups were added or removed
4. Address temporal patterns:
- Color-code or mark weekends vs. weekdays
- If data is missing for certain days, show gaps explicitly rather than connecting across them
- Consider showing day-of-week fixed effects removed
5. Display heterogeneity:
- Add small multiples or separate panels for key segments: mobile vs. desktop, top placements vs. others, high-activity vs. low-activity users
- Show whether the effect is consistent or varies substantially across these cuts
- Flag if specific segments move in opposite directions
6. Include guardrails: Show key guardrail metrics on the same dashboard with alert thresholds marked.
f) Launch decision framework
Pre-committed stopping rule:
Use a group sequential design with alpha-spending to control false positive risk from interim looks. Options:
- O'Brien-Fleming boundaries (conservative early, liberal late)—spend little alpha early
- Pocock boundaries (constant boundary)—easier to explain but uses more alpha early
Alternatively, use a Bayesian decision rule: calculate probability that lift exceeds minimum valuable effect (e.g., P(lift > 1%) > 95%) and stop when this threshold is met or when P(lift < 0) > 90% for early stopping due to harm.
Guardrail handling:
If primary metric improves but a critical guardrail degrades:
- Confirm the guardrail movement is real (check for data quality issues, validate with independent metrics)
- Quantify the trade-off: what is the cost of the guardrail movement vs. benefit of primary metric improvement?
- Escalate to leadership with explicit trade-off framing
- Generally, do not launch if advertiser ROI or user safety metrics regress meaningfully, even if revenue increases
Launch only if:
- Primary metric significantly positive (p<0.05 with sequential correction)
- All critical guardrails either neutral or positive (Bonferroni-adjusted)
- No evidence of severe segment harm (even if average is positive)
Post-launch validation:
Maintain a long-term holdback of 1-5% on the old model for months. This enables:
- Measuring long-term effects (user retention, advertiser LTV) beyond the experiment window
- Difference-in-differences analysis comparing holdback vs. launched using CUPED with pre-period controls
- Detecting delayed or cumulative effects not visible in a two-week test
Run switchback tests in specific geos alternating model versions by week to validate the effect persists and measure any marketplace equilibrium changes that user-level randomization missed.
Common mistakes to avoid:
- Calling significance after peeking without sequential corrections
- Launching despite guardrail degradation because "leadership cares most about revenue"
- Not accounting for multiple testing when analyzing dozens of segments
- Ignoring novelty effects in week one
- Using impression-level variance when randomization is user-level