Experiment designs beyond A/B: bandits, switchback, geo-lift and more
Bandit and contextual (LinUCB) experiments, switchback, difference-in-differences, synthetic control and geo-lift, surrogate metrics, heterogeneity, power analysis and survival, with the API routes.
Fixed-horizon A/B tests with CUPED, Bayesian and sequential engines are in Experiments API. This page covers the other designs. The request and response schemas are in GET /v1/openapi.json; every route is under /v1/projects/{project_id} and takes a normal API key.
In the app, the stateless calculators are on the Designs page of Experiments.
Bandits (Thompson sampling)
Create an experiment with kind: "bandit". An hourly job reads the primary conversion metric and rewrites the flag's variant percentages (two decimals, summing to exactly 100) with Thompson sampling, so better variants get more traffic. Options live in stats_config.bandit:
Key | Meaning |
|---|---|
| Floor on every variant's share (default |
|
|
| See below |
Contextual bandits (LinUCB)
Set stats_config.bandit.contextual to {"property": "plan", "alpha": 1.0, "lambda": 1.0}. LinUCB then picks a variant per category of that person property and pins the choice on the flag as a variant override per category. alpha is the confidence bonus (default 1.0), lambda the ridge strength (default 1.0). For a numeric property add "bins": [10, 100] (ascending thresholds). To use two or three properties at once, give "properties": ["plan", "country"].
GET /experiments/{id}/bandit/contextual returns the current choices for the multi-property policy and how much each attribute matters; the lists are empty until the experiment has data.
Switchback
For effects that cannot be split by user (pricing in a region, marketplace load). Every unit alternates between control and treatment blocks in a randomised, per-unit balanced order.
POST /experiments/designs/switchback/schedulewithunits,slices,run_len(slices per block),washout(slices dropped after each switch) andseedreturnsslots:{unit, slice, treated, washout}. The slice length and the clock are yours.POST /experiments/designs/switchback/analyzewithobservations({unit, slice, treated, value}),washout,cluster_by(unit, the default, orslice) andalphareturns the treatment effect with cluster-robust errors. It assumes carryover fades within the washout and that units do not affect each other.POST /experiments/designs/switchback/analyze-eventsdoes the same from stored events for a flag served byfilters.design: sendvalue(the metric),flag_key,salt,start,slice_days,slices,run_len,washout, optionalgeoandalpha. Event cells are daily, so slices are whole days.
Block-randomised assignment
POST /experiments/designs/assign with units ({id, stratum}), variants ({key, weight}) and seed splits the units inside each stratum to within one unit of the weights. Use it for regions (strata = size tiers) or any offline allocation.
Difference-in-differences
POST /experiments/designs/did takes four cells, treated_pre, treated_post, control_pre, control_post, each {n, mean, variance}, and optional alpha. It returns effect, se, ci_low, ci_high and p_value. It is valid under parallel trends and treats the cells as independent. POST /experiments/designs/did-events computes the cells from stored events for treated and control regions with the same metric spec as geo-lift.
Synthetic control and geo-lift
A weighted mix of untreated donor regions is fitted on the pre-period and compared with the treated regions after the intervention. The response has donor weights, actual and synthetic series, effect_per_period, cumulative, relative_lift, pre and post RMSPE, and a placebo-in-space p_value (the rank of the post/pre RMSPE ratio among the donors).
POST /experiments/designs/synthetictakestreated(a series),donors({region: series}, each as long astreated) andpre_periods.POST /experiments/designs/geo-liftreads daily series from events:value(the metric spec:source,filters,property,math),geo(country,region,cityorproperty:<key>),treated(regions),donors(empty means the 50 largest other regions),intervention_at,pre_days,post_days.
Surrogate metrics
A model predicts a long-horizon outcome (such as 90-day revenue) from short-term metrics, so an experiment can be read before the outcome is complete. It is ridge regression trained on a historical cohort whose outcome is already known.
POST /experiments/surrogatescreates andPOST /experiments/surrogates/{id}/traintrains a model. Body:name,outcome_metric_id,surrogate_metric_ids(1 up to the project limit, default 3; the outcome cannot be one),cohort_event(starts each person's clock),short_days(1 to 90),horizon_days(2 to 366, greater thanshort_days),train_days(default 90) andridge.GET /experiments/surrogatesandGET/DELETE /experiments/surrogates/{id}list, read and remove models.GET /experiments/{id}/surrogates/{model_id}applies the model to each arm and returns the predicted long-term outcome and its difference from control.
Heterogeneity
GET /experiments/{id}/results/slices?dimension=...(optionalmetric) returns the metric per variant in each slice (device_type,country,browser,os,channel,property:<k>orperson_property:<k>) and Cochran's Q across slices: is the effect the same in every slice?GET /experiments/{id}/interactionsreports Cochran's Q across arms.GET /experiments/meta-analysis?metric=<metric id>pools one metric across concluded experiments by inverse variance, with Cochran's Q for heterogeneity.GET /experiments/programgives win rate and top and bottom lifts across concluded experiments.
Power analysis
POST /experiments/power takes kind (proportion, the default, or mean), baseline, mde (relative, or absolute with absolute: true), sd (required for mean), alpha, power, variants, daily_traffic and traffic_fraction. It returns sample_size_per_variant and, with daily_traffic, duration_days. Send units_per_variant (or days with daily_traffic) for the reverse question and the response gives the smallest detectable change as mde_absolute and mde_relative.
GET /experiments/{id}/running-time estimates the days left for a running experiment from its exposure rate. POST /experiments/traffic-preview previews traffic before launch.
Survival (time between events)
Survival is an analytics query, not an experiment design: POST /query/survival takes a survival query and returns a Kaplan-Meier curve with a log-log confidence interval (level, default 0.95), the time-between-events histogram, and the median time. Over five seconds it answers 202; repeat the call when the query has finished.