Follow-Up: handling zero-inflated, heavily skewed data in A/B testing and variance reduction techniques
Context
Context: In my last post, I explored why analyzing heavily right-skewed data can be challenging. Specifically, extreme skewness may require a substantially larger sample size to achieve sufficient statistical power, increasing the risk of Type II errors.
However, my original simulation overlooked an important part of real-world business metrics: heavily right-skewed data often contain a large proportion of zeros, making a direct log transformation problematic since log(0) is undefined.
Questions:
How can we handle zero-inflated, heavily right-skewed data in A/B testing?
What other techniques can we use to reduce variance and improve statistical power?
This post is divided into two parts:
Part I: Handling Zero-Inflated, Heavily Right-Skewed Data
Using simulation methods, I demonstrate a few techniques people might think about when it comes to handling the issues including \(log(x + 1)\), \(log(x + \varepsilon)\), standard normalization, and Box-Cox (Spoiler alert: not all of them work!). I discuss how each method affects statistical significance, result interpretation, and A/B test launch decisions.
Part II: Variance Reduction Techniques
I walk through several alternative methods to improve statistical power, including proportion metrics, proxy metrics, stratification, CUPED (including regression-based methods).
Part I: Handling Zero-Inflated, Heavily Right-Skewed Data
For the code and full simulation, see LogTransform_II.ipynb on GitHub.
In this reproducible simulation example, I:
Simulate two heavily right-skewed, zero-inflated revenue distributions.
Apply Welch's two-sample t-test to different common metric transformation methods: raw, log(x + 1), log(x + ε), standard normalization, and Box-Cox.
Compare mean differences and p-values across sample sizes and different proportions of zeros.
Discuss how zero inflation and metric transformations affect statistical significance, interpretation, and A/B-test launch decisions.
- Scroll horizontally on smaller screens to see all three panels at full size.
- Here Raw and Normalization are the same line!
Conclusions
\(Log(x + ε)\) is highly sensitive to differences in zero rates and could inflate the variances around zero: Since \(ε\) is small, \(log(ε)\) transform to a negative number which amplify between-group differences and thus variances, making the p value less sensitive.
\(Log1p = Log(1+p)\) is robust across zero-inflation scenarios: \(Log1p\) compresses extreme positive values while mapping zeros naturally to zero. Unlike \(Log(x + ε)\), it avoids introducing extreme negative values and remains sensitive to changes in both the proportion of positive observations and the magnitude of positive revenue. It produces consistently smaller \(p\)-values than the raw test across the simulated scenarios.
Box-Cox is adaptive and recommended: Log transformations are special cases of the Box-Cox transformation, which uses maximum likelihood estimation (MLE) to identify the optimal transformation method.
Normalization is not variance reduction: A shared z-score transformation leaves Welch's t-statistic and p-value unchanged; it changes the units, not the distribution's skewness.
Statistical significance is not the same as business impact: Log and Box-Cox transformations test differences in transformed means rather than raw means. Practitioners must still quantify the incremental revenue impact on the original scale to determine whether a launch is justified.
Note: There are more advanced methods for instance David Lindelöf provides an excellent write-up on using advanced modeling approach (Two-Part Hurdle GLM) to handle highly skewed, zero-inflated data.
Part II: Alternative Methods to Improve Statistical Power and Reduce Variance
Beyond metric transformations, several alternative techniques can help improve statistical power without increasing sample size.
Proportion Metrics: Replace highly skewed raw values with proportion-based metrics where appropriate to improve statistical sensitivity.
Proxy Metrics: Identify less noisy, more sensitive metrics that are predictive of the primary business outcome.
Stratification: The intuition is that the variance of sample average can be decomposed into the within-strata variance and the between-strata variance, and the latter is removed through stratification.
Note: It is recommended to use pre-experiment information for stratification.
CUPED (Controlled Experiments Using Pre-Experiment Data): Leverage pre-experiment data to explain baseline variation, reduce variance, and improve statistical power without increasing sample size.
Steps:
Run a simple regression: \(Y \sim X\), where \(Y\) is the outcome variable and \(X\) is the chosen pre-experiment covariate.
Calculate the adjusted outcome: \(Y_i^{\text{CUPED}} = Y_i - Y_i^{\text{Pred}}\).
Run a standard statistical test comparing \(Y^{\text{CUPED}}_{T=1}\) vs. \(Y^{\text{CUPED}}_{T=0}\).
CUPED-adjusted variance is \(\operatorname{Var}(Y^{\text{CUPED}}) = \operatorname{Var}(Y)(1-\rho_{X,Y}^2)\), where \(\rho_{X,Y}\) is the correlation between the outcome and the pre-experiment covariate.
Pro Tips:
Use the same outcome metric from the pre-treatment period as the covariate. (Intuition: The stronger the correlation, the greater the variance reduction.)
Recent developments (Camelo et al., 2026; Hershaff, 2026) have demonstrated that using predicted experiment-period outcomes as CUPED covariates can achieve greater variance reduction than using historical outcomes alone.
The intuition is straightforward: these predictions not only leverage historical outcome information but also incorporate time information specific to the experiment period.
A longer pre-treatment period generally helps capture more stable user behavior, as long as the historical data remains relevant.
How to handle new users with no historical data?
Use available pre-treatment user attributes (e.g., location, device type).
Represent missing historical information with a separate dummy variable: 1 if historical data is available, 0 otherwise.
Regression-based methods: Regression-based methods reduce variance by teasing out the variation in the outcome that is unrelated to the treatment variable, allowing us to estimate the treatment effect more precisely.
\[Y_i = \alpha + \delta T_i + \beta X_i + \epsilon_i\]Method 1\[Y_i = \alpha + \delta T_i + \beta X_i + (\gamma X_i)T_i + \epsilon_i\]Method 2In Method 1, the ATE (average treatment effect) is \(\delta\).
In Method 2,
\[\text{Treatment Effect} = \delta + \gamma X_i\]\[\begin{aligned} ATE &= \frac{1}{n}\sum_{i=1}^{n}(\delta+\hat{\gamma}X_i)\\ &= \delta+\hat{\gamma}\bar{X} \end{aligned}\]Note: In practice, these two methods generally yield similar variance reduction unless:
Treatment and control groups have substantially unequal sample sizes; and
The covariance between \(X\) and \(Y\) differs substantially across groups, i.e., \(\operatorname{Cov}_{T=0}(X,Y)\) and \(\operatorname{Cov}_{T=1}(X,Y)\) are substantially different.
References
[1] Deng, Alex, Ya Xu, Ron Kohavi, and Toby Walker. “Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-Experiment Data.” Proceedings of the Sixth ACM International Conference on Web Search and Data Mining, pp. 123–132, 2013.
[2] Deng, Alex. “General Regression Adjustment and Doubly Robust Estimation.” Causal Inference and Its Applications in Online Industry, §10.2.2.