Here are six essential A/B test diagnostics, each with the check you’d run (SQL/analytic) and possible corrective actions.1) Sample Ratio Mismatch (SRM)- What: Treatment/control allocation deviates from expected random split.- Check (SQL): count by variant and compare to expected using chi-square or binomial.sql
SELECT variant, COUNT(*) AS n
FROM assignments
WHERE experiment_id=123
GROUP BY variant;
Then run a chi-square test on counts.- Action: If SRM significant, investigate logging/launch bugs, targeting rules, duplicate IDs, or non-random assignment. Stop analysis until fixed; consider rerun or exclude affected periods/users.2) Baseline Imbalance (covariate imbalance)- What: Key pre-treatment metrics differ across groups.- Check (SQL):sql
SELECT variant,
AVG(age) AS avg_age,
SUM(past_purchases) AS total_purchases
FROM users u JOIN assignments a USING(user_id)
WHERE a.experiment_id=123
GROUP BY variant;
Run t-tests or standardized mean differences.- Action: If imbalance, verify randomization, stratify or adjust with regression (covariate adjustment), or use blocking/stratified randomization in future.3) Pre-period metric drift / Trending- What: Metrics change over time differently by variant (time confounder).- Check (SQL): compute daily counts/metrics by variant and plot or test interaction.sql
SELECT assign_date, variant, COUNT(*) AS n
FROM assignments WHERE experiment_id=123
GROUP BY assign_date, variant;
- Action: If drift, control for time (time fixed effects), restrict to stable window, or retrace deployment that caused temporal bias.4) Outlier influence / heavy-tail users- What: A few users dominate metric (e.g., revenue).- Check (SQL):sql
SELECT variant, PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY revenue) AS p99,
SUM(revenue) AS total_rev
FROM events e JOIN assignments a USING(user_id)
WHERE a.experiment_id=123
GROUP BY variant;
Compare mean vs median and run winsorized analyses.- Action: Report robust metrics (median, trimmed mean, bootstrapped CI), cap/winsorize, or analyze both with/without outliers.5) Incomplete/late data (missingness)- What: Some events not logged or delayed, differing by variant.- Check (SQL):sql
SELECT variant,
COUNT(DISTINCT user_id) AS users_with_events,
COUNT(*) AS total_events
FROM events e JOIN assignments a USING(user_id)
WHERE a.experiment_id=123 AND event_time < NOW() - INTERVAL '48 hours'
GROUP BY variant;
Compare event completion rates and time-to-event distributions.- Action: Wait for data to stabilize, backfill missing logs, exclude recent window, or flag for instrumentation fixes.6) Peeking / Multiple testing inflation- What: Repeated looks inflate false positives.- Check (analytic): Track number/timing of significance checks; compute alpha spending or use sequential testing boundaries.- Action: Apply proper sequential methods (alpha spending, Bayesian monitoring, or Bonferroni for multiple metrics), or revert claims if improper peeking occurred.For each diagnostic, document findings, rerun after fixes, and report both primary (pre-registered) and sensitivity analyses.