How should we handle heavily skewed data in A/B tests?
Context
Context: Right-skewed metrics are common in online experimentation because a small fraction of highly active users contribute disproportionately to business outcomes. Most users generate little to no activity or revenue, while a few generate exceptionally high values. Examples include revenue per user (RPU), customer lifetime value (LTV), purchase amounts, session counts, ad clicks and etc. This skewness increases variances, making it harder to detect statistically significant treatment effects without large sample sizes.
Question: How does right skewed data impact A/B test results interpretations?
In this reproducible example, I conduct the followings:
- Simulate two heavily right-skewed groups with various sizes.
- Run two-sample t-test on the original values and the logged values.
- Plot the p value vs mean differences for the original values vs the logged values.
- Compare the interpretations and implications for an A/B-test launch decision.
Simulation Results
For the code and full simulation, see LogTransform.ipynb on GitHub.
Simulation table
Scroll to see all 31 sample sizes. Lift is the difference in arithmetic means divided by the control mean. P-values rounded to zero in the notebook are displayed as <0.001.
| Sample Size | Mean Diff | Log Mean Diff | Lift | P Value | Log P Value |
|---|---|---|---|---|---|
| 20 | 128.238 | 0.140 | 8.208 | 0.125 | 0.841 |
| 2,020 | 43.513 | 0.307 | 0.371 | 0.278 | <0.001 |
| 4,020 | 30.936 | 0.301 | 0.290 | 0.315 | <0.001 |
| 6,020 | 32.296 | 0.302 | 0.326 | 0.027 | <0.001 |
| 8,020 | 14.080 | 0.286 | 0.111 | 0.616 | <0.001 |
| 10,020 | 3.427 | 0.286 | 0.028 | 0.829 | <0.001 |
| 12,020 | 38.971 | 0.266 | 0.368 | 0.022 | <0.001 |
| 14,020 | 55.534 | 0.295 | 0.548 | 0.001 | <0.001 |
| 16,020 | 45.991 | 0.258 | 0.501 | <0.001 | <0.001 |
| 18,020 | 61.952 | 0.335 | 0.682 | <0.001 | <0.001 |
| 20,020 | 40.140 | 0.310 | 0.411 | <0.001 | <0.001 |
| 22,020 | 53.778 | 0.312 | 0.570 | <0.001 | <0.001 |
| 24,020 | 38.771 | 0.328 | 0.374 | <0.001 | <0.001 |
| 26,020 | 57.103 | 0.305 | 0.506 | 0.181 | <0.001 |
| 28,020 | 30.539 | 0.292 | 0.295 | 0.004 | <0.001 |
| 30,020 | 27.060 | 0.268 | 0.250 | 0.030 | <0.001 |
| 32,020 | 44.957 | 0.313 | 0.455 | 0.001 | <0.001 |
| 34,020 | 29.541 | 0.284 | 0.279 | <0.001 | <0.001 |
| 36,020 | 29.504 | 0.288 | 0.284 | <0.001 | <0.001 |
| 38,020 | 46.995 | 0.300 | 0.468 | 0.004 | <0.001 |
| 40,020 | 46.917 | 0.294 | 0.456 | 0.011 | <0.001 |
| 42,020 | 27.972 | 0.265 | 0.254 | 0.002 | <0.001 |
| 44,020 | 28.252 | 0.306 | 0.272 | <0.001 | <0.001 |
| 46,020 | 48.895 | 0.317 | 0.499 | <0.001 | <0.001 |
| 48,020 | 45.087 | 0.314 | 0.442 | <0.001 | <0.001 |
| 50,020 | 40.721 | 0.301 | 0.403 | <0.001 | <0.001 |
| 52,020 | 5.676 | 0.276 | 0.046 | 0.708 | <0.001 |
| 54,020 | 44.836 | 0.314 | 0.432 | <0.001 | <0.001 |
| 56,020 | 27.694 | 0.289 | 0.263 | <0.001 | <0.001 |
| 58,020 | 34.631 | 0.312 | 0.327 | <0.001 | <0.001 |
| 60,020 | 40.272 | 0.306 | 0.380 | <0.001 | <0.001 |
Conclusions
-
Raw data is heavily right-skewed, making it difficult to detect statistically significant differences and increasing the risk of Type II errors (false negatives). Large sample sizes are required to achieve sufficient statistical power.
In Seven Rules of Thumb for Web Site Experimenters, researchers proposed a practical heuristic for the sample size needed for the sampling distribution of the mean to approach normality:
n ≥ 355 × (skewness)²
Note: This heuristic concerns normal approximation, not statistical power directly.
Log transformations help detect changes in typical user behavior with significantly smaller sample sizes. By reducing the influence of extreme values, log transformations can make it easier to identify systematic shifts in user behavior.
-
Log transformations provide insights into relative changes rather than absolute changes. The difference in mean log outcomes can be converted into a percentage change in geometric means:
However, translating these findings back to primary business metrics (e.g., average revenue per user) requires additional calculations and reconciliation with practical threshold.