This post discusses calculating simultaneous confidence intervals for the differences in Average Revenue between each of the test groups and the control group in online A/B experiments. An A/B experiment is a controlled experiment that shows multiple variations of a website to different site visitors. Inferences on differences in Average Revenue are a direct way for businesses to measure the revenue impact of their A/B experiments. Average Revenue can also be thought of as Revenue-per-Visitor (RPV), if each sample observation or row in the dataset represents a visitor to the website. We use nonparametric bootstrap simulation, a computationally intensive, data-driven approach to statistical inference based on resampling, to compute these intervals from a synthetic dataset.

We are only interested in making multiple comparisons to a control group, which is a special case of the more general multiple comparisons problem. In the general case, if there are \(k\) groups or levels in the treatment factor, then there are a total of \(\binom{k}{2} = k(k-1)/2\) pairwise comparisons to be made. In the special case of test groups vs. the control group, there are only \(k-1\) such comparisons. When making multiple comparisons, there are two kinds of error rates that arise. The familywise error rate, also known as the overall significance level, is the chance that at least one error is made in all of the intervals. The comparisonwise error rate is the chance that at least one error is made in each individual interval.

We want a specific confidence level to apply simultaneously to all of our intervals, instead of having the confidence level apply to each individual interval. When several confidence intervals are calculated, the probability that all of the intervals are correct can be really small. We will show why this is true. Suppose we calculate \(k-1\) confidence intervals each having an \(1-\alpha^{\ast}\) confidence level. Let \(A_j\) denote the event that the \(j^{th}\) confidence interval is correct with probability \(\mathbb{P}(A_j) = 1-\alpha^{\ast}\). Then \(A_{j}^{C}\) is the event that the \(j^{th}\) confidence interval is not correct with probability \(\mathbb{P}(A_{j}^{C}) = \alpha^{\ast}\). From DeMorgan’s Law and Boole’s Union Inequality, we have \[ \mathbb{P}\left( \bigcap_{j=1}^{k-1} A_j \right) = 1 - \mathbb{P}\left( \bigcap_{j=1}^{k-1} A_j \right)^C = 1 - \mathbb{P}\left( \bigcup_{j=1}^{k-1} A_{j}^{C} \right) \geq 1 - \sum_{j=1}^{k-1} \mathbb{P}(A_{j}^{C}) = 1 - (k-1)\alpha^{\ast}. \] Therefore, the probability the \(k-1\) confidence intervals are simultaneously correct is at least \(1 - (k-1)\alpha^{\ast}\). Here, \(\alpha = (k-1)\alpha^{\ast}\) is the familywise error rate (overall significance level) and \(\alpha^{\ast}\) is the comparisonwise error rate. When we calculate \(k-1\) simultaneous confidence intervals with an overall confidence level of \(1-\alpha\), each of the intervals has a comparisonwise confidence level of \(1-\alpha^{\ast} = 1 - \alpha/(k-1)\).

Suppose the following simulated data represents Revenue-per-Visitor data from a typical online A/B experiment. 25k visitors to an e-commerce website were randomized into \(k = 4\) treatment groups: “Control”, “Test1”, “Test2” and “Test3”, each representing different variations of the website under experiment.

##   Session.ID          Treatment       Revenue       
##  Length:25000       Control:9916   Min.   : 0.0000  
##  Class :character   Test1  :5014   1st Qu.: 0.0000  
##  Mode  :character   Test2  :4993   Median : 0.0000  
##                     Test3  :5077   Mean   : 0.1096  
##                                    3rd Qu.: 0.0000  
##                                    Max.   :14.3900
## # A tibble: 6 x 3
##                         Session.ID Treatment Revenue
##                              <chr>    <fctr>   <dbl>
## 1 h99h35umpxkq2kjo4qxtducvp2h3n0al   Control       0
## 2 njkbc76v3n2i6mgyhkdtofcwgu46c6w6     Test2       0
## 3 j8lu6cdb7dt2f3zfra4lzttfkf91z23o     Test1       0
## 4 tfgqux2826u564byomrrywdzks5xk6zm     Test2       0
## 5 2ecl031dgqtrwiap896ufqrxhqptczmr     Test2       0
## 6 4uz1vlu3d17hfg4orp6i9lfqqiwowzwb   Control       0
## # A tibble: 6 x 3
##                         Session.ID Treatment Revenue
##                              <chr>    <fctr>   <dbl>
## 1 i3uz1p0efl6klz1uf8n9d99pek34pwa5     Test2    0.00
## 2 5ni6n6ycwsfw8uscdp37gm7z6yg9faha   Control    0.00
## 3 5yatt23n0rrdefegzblq45f5gi8u4r56     Test2    0.00
## 4 1jbcstb0xuqzt81m71fvotftqw8k38cl     Test3    0.99
## 5 bsvfgt7ho7x6ibs8zfcxpa9tdygeagz2   Control    0.00
## 6 e6vm79kccmbii5jg7emdy4zkcc5npq1b   Control    0.00
## # A tibble: 4 x 5
##   Treatment Avg.Revenue Sd.Revenue Positive.Revenue Zero.Revenue
##      <fctr>       <chr>      <chr>            <chr>        <chr>
## 1   Control      $0.108      $0.47             9.5%        90.5%
## 2     Test1      $0.147     $0.628            10.3%        89.7%
## 3     Test2      $0.087     $0.357            10.2%        89.8%
## 4     Test3      $0.098     $0.408             9.7%        90.3%

In the plots below, at each of the treatment levels, we see that the distribution for Revenue is right-skewed and highly concentrated at zero or zero-inflated, because a large proportion of visitors simply do not convert, thus contributing zero revenue. This is typical of Revenue data from A/B experiments.

At each of the treatment levels, we plot the kernel density estimates of the probability density function for Average Revenue by obtaining a set of simulated averages via sampling with replacement from the original dataset. A significant p-value for the Shapiro-Wilk test of Normality is evidence to reject the null hypothesis that the distribution for Average Revenue is Normal. Unless samples from a zero-inflated distribution are large enough to include a significant number of non-zero values, confidence intervals based on a Normal Approximation may not be reliable.

We now turn our attention to the nonparametric bootstrap. The advantage of the bootstrap over any analytical method is its simplicity. In the absence of a suitable parametric model, we can use the empirical distribution function (EDF) as a straw man in place of an actual model. The EDF places a point-mass of \(1/n\) at each of the \(n\) sample observations. This fact allows us to sample with replacement from our original dataset to obtain what is known as a nonparametric bootstrap resample. In a sense, this bootstrap resample is a realization from the same data-generating process that gave us the original dataset.

We can simulate a large number of nonparametric bootstrap resamples (the rule of thumb is to simulate at least 999 resamples) and for each bootsrap resample, we calculate the difference in Average Revenue between each of the test groups and the control group. Then using these simulated differences, we calculate \(k-1\) equitailed bootstrap \((1-2a)\) confidence intervals (cf. Davison and Hinkley (1997), p.28) with lower and upper bounds given by \[ \begin{cases} \text{lower bound} = 2t - t_{((B+1)(1-a))}^{\ast}, \\ \text{upper bound} = 2t - t_{((B+1)a)}^{\ast}. \end{cases} \] Here \(t\) will be the difference in Average Revenue, between a fixed test group and the control group, using the original dataset; \(B\) is the number of bootstrap resamples; \(t_{1}^{\ast}, t_{2}^{\ast}, \dots, t_{B}^{\ast}\) will be the simulated differences in Average Revenue between a fixed test group and the control group; \(t_{(j)}^{\ast}\) denotes the jth ordered value of \(t_{1}^{\ast}, \dots, t_{B}^{\ast}\). For the formulae to apply exactly, it is necessary that \((B+1)(1-a)\) and \((B+1)a\) be integers; interpolation can be used if these are not integers. If we choose an overall confidence level \(1-\alpha = 0.95\), then the comparisonwise confidence level is \(1-\alpha^{\ast} = 1 - \alpha/(k-1) = 1 - \frac{0.05}{3} = 0.98\bar{3}\) in each of the \(k-1 = 3\) intervals, and \(a = \alpha^{\ast}/2 = 0.008\bar{3}\) in the formulae for the lower and upper bounds of the equitailed bootstrap intervals.

From a nonparametric bootstrap simulation of \(B = 9999\) resamples, we obtain the following 95% simultaneous confidence intervals for the differences in Average Revenue between each of the test groups and the control group. Interpretation of these results is straightforward. If the lower bound of the interval is positive, then the test group beats the control group. If the upper bound of the interval is negative, then the control group beats the test group. If the interval includes zero, then the result is uncertain.

##                   Obs.Diff.    Lower    Upper              Result
## Test1 vs. Control    $0.039  $0.0149  $0.0627 Test1 beats Control
## Test2 vs. Control  -$0.0204 -$0.0372 -$0.0035 Control Beats Test2
## Test3 vs. Control  -$0.0097 -$0.0276   $0.008           uncertain

This post concludes with a quote from J.W. Tukey (1991) who makes a convincing argument (to me at least) that confidence intervals are more informative and more scientifically honest than hypothesis tests.

“Statisticians classically asked the wrong question - and were willing to answer with a lie, one that was often a downright lie. They asked ‘Are the effects of A and B different?’ and they were willing to answer ‘no’. All we know about the world teaches us that the effects of A and B are always different - in some decimal place - for every A and B. Thus asking ‘Are the effects different?’ is foolish. What we should be answering first is ‘Can we tell the direction in which the effects of A differ from the effects of B?’ In other words, can we be confident about the direction from A to B? Is it ‘up’, ‘down’ or ‘uncertain’?”

References


Davison, A.C. and Hinkley, D.V., Bootstrap Methods and their Applications, Cambridge University Press, 1997.
Siroker, D. and Koomen, P., A/B Testing, John Wiley and Sons, 2013.
Tukey, J.W., The Philosophy of Multiple Comparisons, Statistical Science, Vol. 6, No. 1, 100-116, 1991.