Crossover A/B Test — Within-Subject A/B Testing Design

Statistics
Introduced by
Crossover design: E. J. Williams (1949); A/B testing framework: Ronald Fisher (experimental roots); modern online application widely attributed to Google and Microsoft experimentation teams
Year
1949 (crossover design); 2000s (online A/B application)
Type
Within-subject controlled experiment
Family
Experimental design

What does it do?

A crossover A/B test exposes the same participants or units to treatment A and treatment B in sequence, so each serves as its own control.

Because between-person variability drops out of the treatment comparison, the design can reach a given precision with fewer participants than a parallel A/B test, but only if carryover is negligible or can be managed. Its validity depends on handling carryover and period effects, which a parallel design does not face in the same way.

The intuition behind the method

In a standard A/B test you split users into two groups and compare them. In a crossover A/B test every user receives version A in one period and version B in the other, in an order assigned at random, so each user contributes data under both conditions. Individual differences cancel out because the comparison is made within the same person. The risks are that experiencing A may change how a user responds to B (carryover), and that external conditions may shift between periods. Washout periods and counterbalanced sequence assignment are the design's main tools for managing these risks.

History

Williams (1949) is credited with formalising crossover designs and deriving balanced sequences for comparing treatments in such trials. The two-period AB/BA crossover is the basic form of the design, and Jones and Kenward (2014, third edition) is a standard reference on its design and analysis. The crossover logic was later adapted to online experimentation, where the same user can be randomised into a second condition after a reset period, which can be useful on platforms with a limited pool of active users. The online experimentation literature, including Kohavi, Tang and Xu (2020), covers the use of controlled experiments of this kind in practice.

When to use it

Choose a crossover A/B test when participants are scarce or expensive to recruit, when individual differences in the outcome are large relative to the treatment effect so that within-person comparison is informative, and when carryover is either negligible or can be controlled with a washout. It suits stable outcomes such as ongoing behavior, preference or response to a repeated stimulus, where a participant's baseline is unlikely to change much between periods. Do not use it when the first treatment permanently changes the participant (learning, habit formation), when the outcome can only occur once (irreversible events, one-time purchases), when the washout needed would be impractically long, or when the total duration of the two periods lets attrition or external temporal trends threaten validity.

Limitations and considerations

  • Carryover, the residual influence of the first treatment on the second period, is the central threat to validity. It cannot always be eliminated even with a washout, and it is identified only through the treatment-by-period interaction, which may have low power.
  • Each participant must complete two exposure periods, so total study duration is longer than for a parallel A/B test, which raises the risk of attrition and of external trends affecting the periods.
  • The statistical model is more complex than a two-sample comparison and must include terms for sequence, period and, where relevant, carryover.
  • The design cannot be used when the outcome is a one-time or irreversible event, or when the treatment effect is expected to persist indefinitely.
  • Period effects, such as changes in the environment or in participant behavior between Period 1 and Period 2, can bias the treatment estimate if they are not balanced across sequences. Randomization balances them only in expectation, so in small samples some imbalance can remain and must be adjusted for with the period and sequence terms.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each participant serves as their own control, which removes between-person variance from the treatment comparison. This can increase power relative to a parallel design of the same size, provided carryover is negligible and the outcome is positively correlated within person.
  • Fewer participants are needed to reach a given precision, which matters in low-traffic or hard-to-recruit populations.
  • Because the comparison is within person, treatment effect estimates are often more precise than between-group estimates of the same contrast.
  • Period and sequence effects can be estimated explicitly and adjusted for in the analysis, so temporal drift is separated from the treatment effect.
  • Participants experience both conditions, which can help when the phenomenon depends on individual preference or tolerance.

Applications

  • Bioequivalence and pharmacokinetic studies comparing two drug formulations in the same patients.
  • Online product experiments testing two interface or algorithmic variants on the same user cohort across successive periods.
  • Consumer preference research exposing respondents to two product formulations in sequence.
  • Pricing and promotion experiments in which the same customers are exposed to different incentive conditions across distinct purchase cycles.
  • Digital health interventions in which participants alternate between two app features over defined periods, with the carryover risk assessed for each feature.

How it works

How it works

1

Define the two conditions (A and B), the length of each exposure period, and whether a washout period is needed between periods so that the effect of the first condition can dissipate before the second begins. Specify the primary outcome metric and the minimum detectable effect, which together determine the required sample size. For this design, the sample size depends on the variance of the within-person difference between conditions, not on the total variability across participants. If the two period variances are equal (σ²) and the within-person correlation between periods is ρ, this variance is Var(D) = 2σ²(1 − ρ). The correlation should be estimated from prior data or a pilot study. Relative to a parallel design with the same number of participants per arm, the crossover gains precision only when ρ is positive; at ρ = 0 the two designs are equally precise.

2

Randomly assign participants to one of two sequences: AB (A first, then B) or BA (B first, then A). This counterbalancing allows period and sequence effects to be estimated and separated from the treatment effect in the analysis. Randomization balances period and sequence effects across the two sequences only in expectation. In small samples the sequences may be unbalanced by chance, so the period and sequence terms in the analysis are still needed to adjust for any residual imbalance.

3

Expose each participant to the first assigned condition for the full exposure period and record the outcome at the end of Period 1. If a washout is specified, allow the washout interval to elapse before the second period begins, then expose participants to the other condition and record the outcome again.

4

During the washout interval, participants receive neither treatment. The interval should be long enough for the first treatment's effect to dissipate; its length must be justified from prior evidence or a pilot study rather than assumed. The interval may be zero where carryover is implausible, such as pure interface changes with no lasting behavioral effect. In that case the carryover risk must be argued from the nature of the intervention, not assumed away.

5

Analyse the data with a mixed-effects model, or an equivalent model with participant, sequence, period and treatment terms, so that the treatment effect is estimated after adjusting for period and sequence. The model should match the type of outcome. For continuous outcomes, a linear mixed model is appropriate. For binary outcomes (for example, conversion) or count outcomes, use a generalized linear mixed model with a suitable link, such as logit for binary outcomes and log for counts. Effects from these models are on the link scale (log odds ratios or log rate ratios) and must be back-transformed before they are reported. Test formally for carryover (a treatment-by-period interaction) using the same model type. If carryover is detected, Period 2 data are contaminated, and the analysis may have to rely on Period 1 data alone, which turns the comparison into a between-subject one and removes the efficiency gain of the crossover.

Common pitfalls

  • Ignoring carryover: treating Period 2 data as independent of Period 1 without testing for a treatment-by-period interaction can bias the treatment effect estimate.
  • Omitting or shortening the washout when the first treatment's effect persists: Period 2 measurements then reflect both conditions. The persistence of the effect should be estimated before the design is finalised.
  • Analysing with a simple paired t-test: a paired t-test on within-person differences gives a valid estimate of the treatment effect only in a balanced AB/BA design with no carryover, because period effects then cancel on average across sequences. It cannot test for carryover and cannot adjust for unbalanced sequences. The mixed-effects model described in the analysis step is needed for those checks and adjustments.
  • Using the design in volatile contexts: if external conditions change sharply between periods (seasonality, product launches, news events), the period effect can be confounded with the treatment and erode the within-subject advantage.
  • Confusing a crossover with a post-hoc repeated-measures analysis: the design depends on random assignment of sequence. Analysing users who happened to encounter both conditions in observational data is not a crossover experiment.

Frequently asked questions

How long should the washout period be?

The washout should last long enough for the first treatment's effect to fall to a negligible level. Its length depends on how quickly the effect dissipates, which is a property of the intervention and the outcome. There is no universal rule, so base the choice on prior evidence or a pilot study. If no residual effect is plausible, the washout may be zero, but this should be justified rather than assumed.

What happens if carryover is significant?

If the formal carryover test (the treatment-by-period interaction) is significant, Period 2 data are contaminated and cannot give an unbiased treatment comparison on their own. The usual fallback is to analyse Period 1 data only, which turns the study into a parallel design and gives up the efficiency gain of the crossover. This is why carryover risk should be assessed before the study is designed.

Is a crossover A/B test the same as a within-subject design in psychology?

Conceptually, yes: both compare the same participants under more than one condition. The term crossover is most common in clinical and online experimentation, while within-subject or repeated-measures design is standard in psychology. In practice, a crossover explicitly randomises the order of conditions and models sequence and period effects, whereas some within-subject designs present all conditions in a fixed order.

Can I run a crossover A/B test with more than two conditions?

Higher-order crossover designs with more than two treatments exist, and Williams (1949) is cited for balanced sequences for multiple treatments. However, participant burden and analysis complexity grow with each additional condition, and managing carryover becomes harder. For online experiments, two-condition crossovers are by far the most common form.

How do I determine the required sample size?

The calculation uses the variance of the within-person difference, not the total variability across participants, because each participant is compared with themselves. With equal period variances σ² and within-person correlation ρ, Var(D) = 2σ²(1 − ρ). For a two-sided test with significance level α, power 1 − β and a mean within-person difference δ, a standard large-sample approximation gives n ≈ (z₁₋α/₂ + z₁₋β)² · Var(D) / δ², where n is the number of participants and each participant contributes one difference. For small samples, a t-based calculation is preferable. Because Var(D) is smaller than 2σ² when ρ is positive, a crossover can need fewer participants than a parallel design with the same precision per arm. The size of this gain depends on ρ, which should be estimated from prior data or a pilot study.

Related methods

Sources

  1. Jones, B., & Kenward, M. G. (2014). Design and Analysis of Cross-Over Trials (3rd ed.). Chapman and Hall/CRC.

    ISBN: 9781439861424
  2. Kohavi, R., Tang, D., & Xu, Y. (2020). Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing. Cambridge University Press.

    ISBN: 9781108724227