If you’re running an A/B test on one part of a sales funnel, here’s a trick you might be able to use to reduce the number of subjects needed by half — or more.
Once Upon a Time in a Shopping Cart
Let’s say you have a multi-step sales funnel. About 10% of users reach the checkout page, and of those, about half actually complete the sale. (So on average 5% of all users complete the sale.)
The design team has been hard at work on a new checkout button and wants to run an A/B test to determine its effect on sales. One half of subjects in the test will see the new button, and the other half will see the old button. Like a good student of A/B testing, you tell the experimenters to determine the number of subjects needed for the test in advance.
Here’s a question: do you assign a new visitor to a branch of the experiment as soon as she walks in the door, or do you perform the assignment only when she reaches the checkout page?
Stop and think about it for a second. I’ll wait.
Now you’re probably thinking: Half of the visitors will see the new button, and half will see the old button. The time when they’re assigned to a treatment can’t possibly influence the number of subjects needed for the experiment.
Well, let’s run the numbers, and assume we want to test for a 10% sales lift at standard power and significance levels. If we assign treatment as visitors walk in the door, we would want to test for a change from 5% to 5.5%. But if we assign treatment at the checkout page — which only 10% of users reach — we would instead want to test for a change from 50% to 55%.
Using a sample size calculator, we can determine the number of subjects required for each version of the experiment:
|Experiment||Old rate||New rate||# test subjects
|Assign at beginning||5%||5.5%||30,244|
|Assign at checkout||50%||55%||1,567|
Now let’s work backwards to figure out the total number of visitors that need to walk in the door in order to complete both tests. In the first case, every visitor becomes a test subject, so the number is two times the number needed in each branch: 60,488. In the second case, we only need 1,567 subjects per branch at checkout; because 10% of visitors reach checkout, then on average we need only 31,340 (= 2 × 15,670) visitors to walk in the door. That is, by assigning treatment at checkout, we need only half the number of visitors as compared to assigning treatment at the beginning. Let’s update that table:
|Experiment||Old rate||New rate||# test subjects
|total # visitors
|Assign at beginning||5%||5.5%||30,244||60,488|
|Assign at checkout||50%||55%||1,567||31,340|
Huh? How can the number of visitors required for a successful experiment depend on when we assign treatment?
There’s a problem with our initial reasoning. (But the math is OK!) It’s not true that half of all visitors see the new checkout button. Half of visitors who get to the checkout page will see the new checkout button. In other words, the first experiment is loaded up with “dead weight” in the form of visitors who are assigned to a group, never exposed to the experiment condition, and counted as a failure.
From the perspective of the experiment, these “failures” are indistinguishable from visitors who made it to the checkout page and then failed to convert — that is, the “signal” from users exposed to the experiment is muddied up by “noise” from users who are never exposed to the experiment. More test subjects are therefore required in order to extract meaningful information. In the example above, about twice as many (actually, 1.8 times as many) are required.
Think of it another way: you wouldn’t randomly assign the 7 billion people in the world who never visited your website to an experiment branch and count them all as “failed observations,” would you? So why include the people who visited the website but never reached the experiment?
In practical terms, designers of A/B tests should not assign treatment for all experiments as soon as visitors show up to the store.
Instead, they should practice what I call lazy assignment: assigning visitors to experiments only when it is certain that they will actually be exposed to the experiment condition.
How Much More Efficient Is Lazy Assignment?
The amount of efficiency gained from lazy assignment depends on how well subjects can be isolated in an experiment prior to conversion. The efficiency gain — the factor by which the required number of subjects is reduced — has a simple formula:
Hereis the initial probability, that is, the overall conversion rate from the moment a visitor walks in the door. The variable is the conversion rate from the point at which the experiment actually applies. (See the Mathematical Appendix for a derivation of this formula.)
So instead of running through a complicated calculation as in The Numbers section above, we can compute the efficiency gain directly from the efficiency formula. Here is the result of plugging in numbers from the shopping cart example, where the initial conversion rate was 5% (and the final conversion rate was 50% ( ):
Below is a table with more example values ofand and the corresponding efficiency gain. To read it, find the row corresponding to the initial probability , and the column corresponding to the isolated probability .
|Efficiency gains from lazy assignment|
The table shows that major efficiency gains kick in when the event can be isolated to a 50/50 probability or better. In fact, if the checkout page itself has a baseline conversion rate of 80%, then we can easily obtain efficiency gains of 4 or more — that is, we can use less than a quarter the number of subjects as before!
Yet even if we can only isolate subjects to have a conversion rate of 20%, if the initial conversion rate was 10%, then we’ve reduced the required subject count by more than a tenth (). If even that small change allows for ten percent more experiments, and hence ten percent more opportunities to learn, then I’d say it’s worth being lazy about treatment assignments.
Appendix: Completely Optional Mathematics
Below a derivation of the efficiency formula.
First we should formally define. It’s the total number of visitors needed for experiment 1 (the “full” experiment with treatments assigned at the beginning) divided by the total number of visitors needed to complete experiment 2 (the “isolated” experiment with treatments assigned only at the checkout page).
Letbe the number of subjects in experiment 1, and be the number of subjects in experiment 2. The number is not the same as the ratio of subject counts , since in experiment 2, only a fraction of visitors actually become subjects. Instead we can define it as the ratio of expected successes, since the expected number of successes will be proportional to the number of visitors in both experiments:
Now we’re ready to derive a formula equal to this expression.
The sample size formula for a 2×2 chi-squared test (see 1) is:
Hereis the size of the minimum detectable effect in absolute terms, is the baseline conversion rate, is a constant corresponding to the desired significance and power levels, and is the number subjects required for each branch.
We then have the equations:
We have a third equation by equating the effect sizes relative to the baseline conversion rates in both experiments:
Plugging theand definitions into this equation and doing a little algebra we find:
The left-hand side is our definition of, so finally we have:
1. Sample Size Calculations in Clinical Research by Shein-Chung Chow, Hansheng Wang p. 145