A/B Testing with Network Effects in Two-Sided Marketplaces
Statistics & ExperimentsModel answerLast updated
Design a rigorous experiment for a ranking algorithm change when users influence each other through marketplace interactions and social connections.
You're designing an experiment to test a new search ranking algorithm in a two-sided marketplace. The platform connects buyers and sellers, and you've identified two sources of interference that violate standard A/B testing assumptions:
-
Supply-side interference: When you change how search results rank sellers, you shift demand between them. If treatment users see Seller X promoted, that seller's inventory and pricing may change for everyone, including control users.
-
Demand-side interference: Buyers share links, reviews, and recommendations with friends. When a treated user discovers something through the new ranking, their social connections may be influenced regardless of assignment.
Your task is to:
- Select an appropriate randomization strategy that accounts for both interference types
- Define clear exposure rules and exclusion criteria
- Calculate sample size requirements given a mean cluster size of 50 users and intra-cluster correlation of 0.02
- Describe how to estimate the correlation parameter from historical data
- Explain how to maintain assignment integrity over time and detect assignment problems
- Propose an analysis approach if cluster membership changes during the experiment
What matters is demonstrating understanding of when standard randomization breaks down, how clustering addresses interference, the statistical cost of clustering, and practical implementation challenges.
Hints
Hint 1
Think about what happens when treatment and control groups share sellers or influence each other socially—the effect you measure won't reflect the true global impact
Hint 2
The design effect formula 1 + (m-1)ρ shows how cluster size and correlation combine to inflate variance
Hint 3
You can estimate intra-cluster correlation from historical data by treating your planned clusters as if they were experiment arms and measuring outcome similarity within them
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Understanding the Problem
Standard A/B tests assume SUTVA: each user's outcome depends only on their own treatment, not others' assignments. This marketplace violates SUTVA in two ways. If you randomly assign individual users, treated buyers compete with control buyers for the same seller inventory, and social sharing spreads treatment effects to control users. You'll measure a biased effect—typically inflated for supply interference (treatment "steals" from control) and attenuated for social contagion (control receives spillover benefits).
Randomization Strategy
Cluster randomization addresses interference by grouping interconnected users and assigning whole groups to treatment or control.
Cluster definition options:
- Geographic clusters: If the marketplace is local (food delivery, rides), cities or neighborhoods naturally contain both supply and demand. Friends often live nearby, so this captures both interference types.
- Graph-based clusters: Build a network with buyer-seller transaction edges and buyer-buyer social edges. Partition it using community detection (Louvain, spectral clustering) to maximize within-cluster connectivity. Target 70%+ of edges staying within clusters.
- Seller-centric clusters: Group users by primary seller, but this handles supply interference poorly since buyers typically interact with many sellers.
Recommendation: Use graph partitioning with balanced cluster sizes around 50 users. If the marketplace has strong geographic structure, use regions as a simpler proxy. Stratify clusters by pre-experiment activity (GMV, order volume) before randomization to reduce variance.
Alternative designs: Ego-cluster randomization (treat a user plus all their connections, measure only the ego) handles social contagion cleanly but wastes statistical power. Randomized saturation (assign clusters to 0%, 50%, 100% treatment density) separates direct effects from spillovers but requires more clusters.
Exposure and Exclusion Rules
Define these using only pre-randomization information to avoid post-treatment bias.
Exposure criteria:
- A buyer is exposed if they performed at least one search and saw results from their assigned algorithm version
- A seller is exposed if they received impressions from search sessions in their assigned arm
- Log exposure at decision time (when serving the search results), not retrospectively
Exclusions:
- Automated accounts, employees, test users
- Users who joined after randomization (assign them to holdout or use a deterministic rule based on first activity cluster)
- Sellers whose demand comes from multiple clusters (>50% from outside their dominant cluster)—these create cross-contamination
Report intent-to-treat on all randomized units as the primary result. As a secondary analysis, you can adjust for incomplete exposure using inverse probability weighting, though this introduces assumptions.
Sample Size Calculation
The design effect quantifies how much clustering inflates variance:
DE = 1 + (m - 1)ρ = 1 + (50 - 1) × 0.02 = 1.98
This means you need approximately 2× the sample size compared to individual randomization. Standard errors grow by √1.98 ≈ 1.41×.
If individual randomization required 80,000 users per arm, you now need 158,000 users per arm, or roughly 3,160 clusters per arm at 50 users each.
Why this matters: ρ = 0.02 seems small, but multiplied by (m - 1) = 49, the effect compounds. Unequal cluster sizes make it worse—variance is dominated by large clusters. If cluster sizes have coefficient of variation CV = 0.5, the design effect increases to approximately 2.23.
Keep clusters balanced during partitioning to minimize the penalty.
Estimating Intra-Cluster Correlation
Use historical data to estimate ρ before launching:
-
Apply your cluster definition to 4–8 weeks of past data
-
Fit a variance components model for your primary metric (e.g., conversion rate, revenue per user):
Yᵢⱼ = μ + uⱼ + εᵢⱼ
where uⱼ is the cluster random effect and εᵢⱼ is individual noise
-
Calculate ρ as the proportion of variance between clusters:
ρ = σ²_cluster / (σ²_cluster + σ²_individual)
-
Bootstrap confidence intervals by resampling clusters (not individuals) 100+ times
-
Use the upper confidence bound for planning, not the point estimate—this builds in a safety margin
-
Check across metrics: engagement metrics typically have lower ρ than revenue metrics
-
Validate stability: compute ρ across several historical windows to ensure it's not trending
Variance reduction techniques like CUPED (using pre-period covariates) reduce effective ρ, so estimate ρ on the adjusted outcomes you'll actually analyze.
Maintaining Assignment Integrity
Assignment mechanism:
- Use deterministic hashing:
hash(cluster_id || experiment_salt) % 100 < 50assigns to treatment - The cluster map is a frozen snapshot, versioned and stored, never recomputed on the fly
- Serving systems look up each user's cluster from this snapshot at decision time
Preventing contamination:
- Freeze any machine learning models that train on user behavior, or train separately per arm—otherwise control learns from treatment data
- Partition seller-level features (popularity scores, CTR estimates) by arm or freeze them
- Clear shared caches between treatment and control
- If reassigning clusters, insert a washout period (7–14 days) to let transient effects decay, and exclude the washout from analysis
Validation:
- Sample ratio mismatch at cluster level: χ² test on cluster counts per arm (clusters are independent units)
- Invariant metric checks: pre-experiment user characteristics (signup date distribution, historical activity) should be balanced
- For user-level SRM, account for clustering by bootstrapping or using a clustered chi-square test—naive tests will false-alarm due to within-cluster correlation
Handling Evolving Clusters
If cluster membership changes (users join/leave, connections form):
Rehashing schedule:
- Rebuild clusters periodically (every 2–4 weeks) based on recent activity
- Use the same partitioning algorithm and target cluster size
- Reassign clusters to treatment/control using the same hash function with a new time-stamped salt
- Exclude the washout period after each reassignment
Analysis approach:
-
Use a mixed-effects model with cluster random intercepts:
Yᵢⱼₜ = β₀ + β₁·Treatment + uⱼₜ + εᵢⱼₜ
where j indexes clusters and t indexes time epochs
-
This accounts for correlation within clusters and across time
-
Cluster standard errors at the (cluster × epoch) level
-
Report both epoch-specific effects and the pooled average effect
-
Check for effect heterogeneity across epochs—if the ranking change has a learning curve or network cascade, effects may grow over time
Alternative: Assign clusters once at the start and accept some measurement error from membership drift. This is simpler and avoids washout costs, acceptable if drift is <20% over the experiment window.
Common Mistakes
- Using individual randomization because "the platform is large enough"—size doesn't fix interference
- Defining exposure post-hoc based on who engaged, which creates selection bias
- Planning with point estimates of ρ instead of conservative upper bounds
- Ignoring unequal cluster sizes—a few giant clusters drive all the variance
- Retraining models or aggregating features across arms, leaking treatment into control
- Running standard SRM tests on user counts without accounting for clustering