Resolving Subgroup Reversals and Aggregation Bias in Experiments
Statistics & ExperimentsModel answerLast updated
Detect composition shift and Simpson's paradox in A/B tests, build stratified estimators, and establish decision rules for heterogeneous subgroup effects.
During an A/B test analysis, the overall metrics indicate a +1.2 percentage point (pp) gain in conversion rate. However, a broken-down subgroup analysis yields the following contrasting lifts:
- First-time Visitors: −0.5 pp
- Returning Visitors: +2.0 pp
Address the following three system and statistical requirements:
- Composition Shifts & Aggregation Bias: Explain how unequal segment distributions between arms lead to Simpson's paradox. Provide numerical examples showing (a) distorted effect sizes and (b) a full directional reversal (where both subgroup effects are negative, but aggregate lift is positive). Detail why randomized trials can still suffer from imbalanced segment distributions across arms.
- Stratified & Longitudinal Estimators: Construct a pre-registered post-stratified estimator to correct for composition shift. Show the exact variance formula and detail how to formulate this within an interacted linear regression (Lin's estimator) and longitudinal framework (MMRM / GEE).
- Heterogeneity Testing & Deployment Protocol: Formulate a hypothesis test to confirm whether subgroup treatment variations are statistically distinct on an absolute scale. Lay out a formal, pre-registered decision ruleset mapping test outputs to deployment actions (e.g., universal release, targeted release, or complete holdout).
Hints
Hint 1
Evaluate whether the reported overall conversion (+1.2 pp) sits within the range bounded by the subgroup impacts [-0.5 pp, +2.0 pp], and calculate the implicit weights required for both arms.
Hint 2
Consider how post-treatment conditioning, asymmetric feature exposure, and non-uniform ramp-up rates across time distort arm composition.
Hint 3
Ensure your post-stratification weighting scheme uses fixed target weights (such as pooled traffic shares) rather than variant-specific proportions.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Composition Bias & Simpson's Paradox in Experiments
A. Deconstructing the Reported Results
The overall result of +1.2 pp falls strictly within the interval bounded by the two subgroup effects: $[-0.5\text{ pp}, +2.0\text{ pp}]$. This aggregate lift is a weighted combination of segment-level treatment effects.
Assuming equal total sample sizes between Treatment and Control ($N_T = N_C$), let $w_T$ be the fraction of returning visitors in Treatment and $w_C$ be the fraction in Control. If the segment composition is perfectly balanced across variants ($w_T = w_C = w$), the aggregate effect simplifies to: $$\tau_{\text{agg}} = w \cdot (+2.0) + (1 - w) \cdot (-0.5)$$
Setting $\tau_{\text{agg}} = 1.2\text{ pp}$ gives: $$2.0w - 0.5 + 0.5w = 1.2 \implies 2.5w = 1.7 \implies w = 0.68$$
Thus, an aggregate lift of +1.2 pp is expected in an unconfounded experiment where returning visitors comprise 68% of the traffic in both arms. However, if $w_T \neq w_C$, the unadjusted aggregate metric is distorted by composition bias.
B. Concrete Numerical Demonstrations
Scenario 1: Magnitude Distortion (The Prompt Setup)
Consider $N = 10,000$ visitors per variant. Returning visitors convert at a higher baseline rate (8.0%) than First-time visitors (3.0%).
- Control Variant: 50% First-time ($n=5,000$, 150 conversions = 3.0%), 50% Returning ($n=5,000$, 400 conversions = 8.0%)
- Aggregate Control Rate: $\frac{150 + 400}{10,000} = 5.50%$
- Treatment Variant: 44% First-time ($n=4,400$, 110 conversions = 2.5%), 56% Returning ($n=5,600$, 560 conversions = 10.0%)
- Subgroup Effects: First-time = $2.5% - 3.0% = -0.5\text{ pp}$; Returning = $10.0% - 8.0% = +2.0\text{ pp}$
- Aggregate Treatment Rate: $\frac{110 + 560}{10,000} = 6.70%$
- Unadjusted Aggregate Effect: $6.70% - 5.50% = \mathbf{+1.20\text{ pp}}$
Under a standardized 50/50 target distribution, the true population Average Treatment Effect (ATE) is: $$\tau_{\text{strat}} = 0.5(-0.5\text{ pp}) + 0.5(+2.0\text{ pp}) = \mathbf{+0.75\text{ pp}}$$
In this scenario, $0.45\text{ pp}$ of the headline gain is driven purely by Treatment having a higher share of high-converting Returning users.
Scenario 2: Complete Directional Reversal (Simpson's Paradox)
Suppose the treatment negatively impacts both user segments, but Treatment receives a disproportionate share of high-converting Returning visitors:
- Control Variant: 70% First-time ($n=7,000$, 210 conversions = 3.0%), 30% Returning ($n=3,000$, 300 conversions = 10.0%)
- Aggregate Control Rate: $\frac{210 + 300}{10,000} = 5.10%$
- Treatment Variant: 40% First-time ($n=4,000$, 112 conversions = 2.8%), 60% Returning ($n=6,000$, 570 conversions = 9.5%)
- Subgroup Effects: First-time = $2.8% - 3.0% = \mathbf{-0.2\text{ pp}}$; Returning = $9.5% - 10.0% = \mathbf{-0.5\text{ pp}}$
- Aggregate Treatment Rate: $\frac{112 + 570}{10,000} = 6.82%$
- Unadjusted Aggregate Effect: $6.82% - 5.10% = \mathbf{+1.72\text{ pp}}$
Despite both subgroups suffering conversion declines, the unadjusted total conversion rises by +1.72 pp due to the shift in group composition.
C. Causes of Segment Imbalance in Randomized Experiments
Proper randomization balances pre-treatment covariates in expectation. A statistically significant mix shift points to one of four experimental issues:
- Post-Treatment Conditioning (Bad Control): Segment membership was determined after variant assignment. For instance, if the treatment increases user engagement, it moves users from "First-time" to "Returning" status during the trial. Stratifying on post-treatment variables induces selection bias.
- Ramp Confounding: The assignment ratio was stepped up over time (e.g., 5% to 50% allocation) while baseline traffic composition varied by day of week or time of day.
- Exposure Triggering Differentials: The treatment modification altered which users met the criteria to trigger log events and enter the experiment population.
- Sample Ratio Mismatch (SRM): Downstream technical faults, aggressive bot-filtering, or logging failures dropped data unevenly across segments.
2. Pre-Registered Estimators & Modeling Approaches
A. Post-Stratified Estimator
Define target population weights $w_s$ for stratum $s \in {1, \dots, K}$ using fixed pre-assignment distributions (e.g., pooled sample proportions across all variants: $w_s = \frac{N_{T,s} + N_{C,s}}{N_T + N_C}$).
$$\hat{\tau}{\text{strat}} = \sum{s=1}^K w_s \left( \hat{p}{T,s} - \hat{p}{C,s} \right)$$
where $\hat{p}{T,s}$ and $\hat{p}{C,s}$ represent the sample conversion rates in stratum $s$.
Assuming independence across strata and treatment arms: $$\widehat{\text{Var}}(\hat{\tau}{\text{strat}}) = \sum{s=1}^K w_s^2 \left( \frac{\hat{p}{T,s}(1 - \hat{p}{T,s})}{n_{T,s}} + \frac{\hat{p}{C,s}(1 - \hat{p}{C,s})}{n_{C,s}} \right)$$
B. Regression Formulation (Lin's Interacted Estimator)
To adjust for composition shifts while incorporating continuous pre-experiment covariates (such as CUPED baseline metric variance reduction), fit an ordinary least squares model with centered covariates:
$$Y_i = \alpha + \tau T_i + \sum_{s=1}^{K-1} \beta_s (S_{i,s} - \bar{S}s) + \sum{s=1}^{K-1} \gamma_s T_i (S_{i,s} - \bar{S}_s) + \varepsilon_i$$
Where:
- $T_i \in {0, 1}$ is the treatment assignment flag.
- $S_{i,s}$ is an indicator for segment $s$.
- $\bar{S}_s$ is the mean of segment $s$ across the combined sample.
Centering segment indicators at their sample means ensures the main treatment coefficient $\hat{\tau}$ estimates the population-weighted ATE. Heteroskedasticity-robust standard errors (HC2 or HC3) must be used.
C. Repeated Measures Framework (MMRM / GEE)
When observing panel data with repeated metrics per user across time steps, fit a model that accounts for within-user correlation and temporal shifts:
$$Y_{it} = \beta_0 + \tau T_i + \delta_t + \lambda_s S_{is} + \theta_t (T_i \times \text{Period}t) + \phi_s (T_i \times S{is}) + \varepsilon_{it}$$
Using Generalized Estimating Equations (GEE) with an identity link and cluster-robust standard errors yields unbiased estimates of absolute percentage-point impacts across execution periods.
3. Testing Heterogeneity & Deployment Decision Rules
A. Test for Treatment Effect Heterogeneity
To determine whether subgroup impacts differ significantly on an absolute scale, evaluate the null hypothesis: $$H_0: \tau_{\text{Returning}} - \tau_{\text{First-time}} = 0$$
Let $\hat{\delta} = \hat{\tau}{\text{Returning}} - \hat{\tau}{\text{First-time}} = (+2.0\text{ pp}) - (-0.5\text{ pp}) = +2.5\text{ pp}$.
The variance of the difference between independent subgroup estimates is: $$\widehat{\text{Var}}(\hat{\delta}) = \widehat{\text{Var}}(\hat{\tau}{\text{Returning}}) + \widehat{\text{Var}}(\hat{\tau}{\text{First-time}})$$
Compute the test statistic: $$Z = \frac{\hat{\delta}}{\sqrt{\widehat{\text{Var}}(\hat{\delta})}}$$
If $|Z| > z_{\alpha/2}$, reject $H_0$ and confirm significant treatment heterogeneity. For $K > 2$ segments, compute a Wald $\chi^2$ test on the $K-1$ interaction terms.
B. Pre-Registered Decision Protocol
Let $m \ge 0$ denote the non-inferiority tolerance margin for subgroup drop-offs (e.g., $m = 0.2\text{ pp}$).
[ Interaction Test H0: Equal Effects ]
/ \
p >= alpha p < alpha
/ \
[ Evaluate Stratified ATE ] [ Evaluate Subgroup 95% CIs ]
/ \ / \
ATE > 0 ATE <= 0 All CI Lowers > -m Any CI Lower <= -m
/ \ / \
Global Ship Do Not Ship Global Ship Segmented Release
(Ship positive segments;
hold back harmed groups)
- Uniform Global Release:
- Condition A: Heterogeneity test is not significant ($p \ge \alpha$), and overall post-stratified $\hat{\tau}_{\text{strat}}$ is statistically positive.
- Condition B: Heterogeneity is significant ($p < \alpha$), but all subgroup 95% confidence intervals have lower bounds above the harm tolerance ($-m$).
- Segmented Release:
- Heterogeneity test is significant ($p < \alpha$), and at least one segment's confidence interval lower bound falls below $-m$.
- Action: Deploy the feature strictly to beneficial segments (e.g., Returning visitors). Retain harmed segments on Control (e.g., First-time visitors) and initiate a targeted follow-up experiment.
- Full Rollback:
- Stratified ATE shows no overall positive effect and no clear targetable winning segment.
C. Operational Prerequisites for Segmented Release
Before proceeding with a targeted deployment, verify:
- Targetability: The segmentation variable must be identifiable at request time before rendering the UI.
- Long-Term Dynamics: Evaluate whether harming First-time visitors reduces the future pool of Returning visitors.
- Maintenance Burden: Weigh the infrastructure cost of maintaining multiple code paths against the incremental conversion gain.