Ab test design data analysis

From FerroxLabs/murage · View interactive version

Ab test design data analysis is an AI agent skill from the GitHub repository FerroxLabs/murage. Designs an A/B test from scratch. Defines the hypothesis, calculates required sample size, specifies randomization method, sets success metrics and minimum detectable effect, and produces a results interpretation template. Use when the user wants to set up a controlled experiment to test whether a c

How to use this skill

Skill file

A/B Test Design

When to Use

Use this skill when:

Do NOT use when:


Process

Step 1 -- Elicit the Hypothesis and Change Description

Ask the user to precisely describe the intervention. Vague hypotheses produce uninterpretable results.

Step 2 -- Define and Operationalize the Primary Metric

One primary metric. Exactly one. Pre-specify it before any data collection begins.

Step 3 -- Establish the Minimum Detectable Effect (MDE)

The MDE is a business decision, not a statistical one. Drive this conversation carefully.

Step 4 -- Calculate Required Sample Size

The sample size calculation is the technical core of the design. Get it right.

For binary (proportion) metrics:

The exact formula for two-proportions z-test (two-sided, equal groups):

n_per_group = (Z_α/2 + Z_β)² × [p₁(1-p₁) + p₂(1-p₂)] / (p₂ - p₁)²

Where:

Quick reference: sample size per group (α=0.05 two-tailed, 80% power)

| Baseline Rate | MDE (absolute) | Relative Lift | n per group |

|--------------|----------------|---------------|-------------|

| 1% | 0.3 pp | 30% | ~5,400 |

| 2% | 0.5 pp | 25% | ~6,200 |

| 3% | 0.5 pp | 17% | ~9,900 |

| 3% | 1.0 pp | 33% | ~2,700 |

| 5% | 0.5 pp | 10% | ~18,500 |

| 5% | 1.0 pp | 20% | ~4,700 |

| 10% | 1.0 pp | 10% | ~14,700 |

| 10% | 2.0 pp | 20% | ~3,700 |

| 20% | 2.0 pp | 10% | ~15,600 |

| 20% | 4.0 pp | 20% | ~3,900 |

| 50% | 5.0 pp | 10% | ~6,100 |

Note: these values are precisely computed from the formula above, not approximations. The 16 × p(1-p)/MDE² shortcut underestimates sample size when p₁ and p₂ differ meaningfully.

For continuous (mean) metrics:

n_per_group = 2 × (Z_α/2 + Z_β)² × σ² / δ²

Where:

At 80% power, α = 0.05: n = 2 × 7.849 × σ² / δ² = 15.7 × (σ/δ)²

The ratio σ/δ is the inverse of the standardized effect size (Cohen's d). Cohen's conventions: small = 0.2, medium = 0.5, large = 0.8. At d = 0.2 (small effect), n ≈ 394 per group. At d = 0.5 (medium), n ≈ 64 per group.

Practical variance estimation for continuous metrics:

Power settings:

Significance level (α) settings:

Step 5 -- Design the Randomization Strategy

Randomization validity determines the entire causal claim of the experiment.

Step 6 -- Establish Test Duration and Calendar Constraints

Duration is determined by traffic, not by impatience.

Step 7 -- Define Guardrail Metrics and the Decision Framework

Pre-commit to the decision rules. Changing them after seeing results is p-hacking.

Guardrail metrics:

Pre-specified decision rules:


Output Format

## A/B Test Design Plan
### [Test Name / Experiment ID]
Prepared: [Date]

---

### 1. Hypothesis

**Null hypothesis (H₀):** Changing [description of change] has no effect on [primary metric].
**Alternative hypothesis (H₁):** Changing [description of change] will [increase/decrease] [primary metric]
  by at least [MDE absolute] ([MDE relative]%). Test direction: [two-tailed / one-tailed].
**Mechanism:** [One sentence explaining why this change should produce the expected effect.]

---

### 2. Experiment Design

| Element | Specification |
|---------|--------------|
| Control (A) | [Current version -- describe precisely] |
| Treatment (B) | [Modified version -- describe precisely] |
| Unit of randomization | [User ID / Cookie / Session / Cluster] |
| Eligible population | [Definition: logged-in users who visit checkout page, etc.] |
| Exclusion criteria | [Bots, internal users, users in overlapping experiments, etc.] |
| Traffic split | [50/50 or specify ratio with justification] |
| Assignment method | [Hash-based: hash(user_id + experiment_salt) mod 100] |

---

### 3. Metrics

**Primary metric:**
| Field | Value |
|-------|-------|
| Metric name | [Name] |
| Metric type | [Binary proportion / Continuous mean / Ratio metric] |
| Precise definition | [Numerator / denominator / time window] |
| Baseline value | [Current observed value with confidence interval if available] |
| Standard deviation | [For continuous metrics only -- from historical data] |
| Minimum detectable effect | [Absolute: X pp / units] -- [Relative: X%] |

**Guardrail metrics:**
| Metric | Baseline | Stop-test threshold | Owner |
|--------|----------|---------------------|-------|
| [Metric 1] | [Value] | [≥ X% decline triggers stop] | [Team] |
| [Metric 2] | [Value] | [≥ X% decline triggers stop] | [Team] |
| [Metric 3] | [Value] | [≥ X% decline triggers stop] | [Team] |

**Secondary / exploratory metrics (observed, not decision-making):**
- [Metric A]
- [Metric B]

---

### 4. Sample Size and Power

| Parameter | Value |
|-----------|-------|
| Statistical test | [Two-proportion z-test / Two-sample t-test / Mann-Whitney U] |
| Significance level (α) | [0.05 two-tailed / 0.01 / 0.05 one-tailed] |
| Statistical power (1-β) | [80% / 90%] |
| Baseline value (p₁ or μ₁) | [Value] |
| Expected value under H₁ (p₂ or μ₂) | [Baseline + MDE] |
| Standard deviation (σ) | [For continuous metrics] |
| Formula used | [State formula explicitly] |
| Sample size per group | [n] |
| Total sample required | [2n for 50/50] |

**Sample size calculation (show work):**
[Step-by-step computation using the formula, with all numbers substituted]

---

### 5. Timeline

| Parameter | Value |
|-----------|-------|
| Daily total eligible traffic | [N] |
| Traffic fraction allocated to experiment | [% or statement if 100%] |
| Daily traffic per group | [N/2 for 50/50] |
| Minimum days to reach sample | [Total sample / daily traffic] |
| Weekly cycles required | [Round up to nearest week] |
| Recommended test duration | [Days, accounting for novelty effect if applicable] |
| Maximum test duration | [28 days] |
| Planned start date | [Date or TBD] |
| Planned analysis date | [Start + recommended duration] |
| Calendar risks | [Holidays, launches, events during test window] |

---

### 6. Pre-Specified Decision Rules

**Ship treatment if:**
- p-value < [α] AND effect direction is positive AND no guardrail is breached

**Kill treatment if:**
- p-value < [α] AND effect direction is negative, OR any guardrail metric is breached

**Accept null (no change) if:**
- p-value ≥ [α] after full sample collection and no guardrail breach

**Emergency stop criteria:**
- [Guardrail metric 1] drops below [threshold]
- [Guardrail metric 2] drops below [threshold]
- Error rate increases above [X%]

---

### 7. Results Interpretation Template
*(Pre-fill after test completes)*

| Metric | Control | Treatment | Absolute Difference | Relative Difference | p-value | 95% CI |
|--------|---------|-----------|---------------------|---------------------|---------|--------|
| [Primary metric] | [baseline] | [observed] | [Δ] | [Δ/baseline %] | [p] | [lower, upper] |
| [Guardrail 1] | | | | | | |
| [Guardrail 2] | | | | | | |

**Decision:**
☐ Ship -- treatment showed significant improvement (p = [value], 95% CI [lower, upper pp])
☐ Kill -- treatment showed significant harm (p = [value])
☐ No change -- inconclusive result (p = [value], MDE of [X] not detected)
☐ Emergency stop -- guardrail breach: [specify metric and observed value]

**Narrative:**
> [Metric] in the treatment group was [X]% [higher/lower] than control ([treatment value] vs. [control value]).
> The 95% confidence interval for the difference is [[lower], [upper]] [units or pp].
> [Decision rationale in 2-3 sentences referencing pre-specified rules.]

Rules

  1. Never run a test without a pre-specified primary metric and MDE. The primary metric and MDE must be locked before any data is collected. If results are used to choose the metric, the Type I error rate is no longer controlled at α -- it can exceed 50% when many metrics are examined.
  1. Never check results and decide to stop or extend based on the p-value. Each additional peek at accumulating data at α = 0.05 inflates the effective false positive rate. After 5 peeks, the true false positive rate exceeds 19%. After 10 peeks, it exceeds 29%. Either commit to the pre-planned sample size, or explicitly adopt a sequential testing framework (mSPRT, O'Brien-Fleming bounds) from the start.
  1. Always check for Sample Ratio Mismatch (SRM) before analyzing results. An SRM means the observed group sizes deviate significantly from the intended allocation. Run a chi-squared test against expected proportions. Even a 2% SRM (e.g., 51/49 when 50/50 was intended) can bias the estimated treatment effect by 5-10%. SRM is caused by bot filtering, logging bugs, or hash-based assignment errors.
  1. Match the unit of analysis to the unit of randomization. If users are randomized but events (page views, clicks) are analyzed, the independence assumption is violated. Observations from the same user are correlated, deflating the standard error and causing false positives. Always aggregate to the randomization unit before computing means and variances.
  1. Use the delta method for ratio metrics, not naive per-event averages. Dividing total clicks by total sessions across all users in a group is a ratio of sums, not an average of per-user ratios. The variance of this ratio cannot be computed with a standard t-test. Use the delta method or bootstrap to estimate variance correctly.
  1. Do not apply multiple comparisons corrections to guardrail metrics -- apply them only to exploratory secondary metrics. Guardrails are safety checks, not hypothesis tests. They use a threshold approach (did the metric cross a harm boundary?), not a significance testing approach. For secondary exploratory metrics analyzed as a family, apply Bonferroni (α/k) or Benjamini-Hochberg for less conservative correction.
  1. Always report the confidence interval for the effect, not just the p-value and direction. "The improvement is between 0.2 and 1.8 percentage points" communicates practical significance. "p = 0.03, positive direction" does not. The width of the confidence interval tells you how precise the estimate is.
  1. Account for novelty effects in tests involving visible UI changes. New UI elements generate artificially elevated engagement in the first 1-3 days from users exploring something unfamiliar. For tests expected to run 14+ days, compute the treatment effect separately for the first 3 days and the remaining days. If the effect decays substantially, the stable long-run effect is what matters for the ship decision.
  1. Never use one-tailed tests without pre-specifying a strong directional reason AND documenting the business justification. One-tailed tests require half the sample of two-tailed tests at the same power. This is tempting but dangerous. One-tailed testing is only valid when it is scientifically impossible or operationally irrelevant for the treatment to perform worse. In practice, treatments very often perform worse than expected.
  1. Validate assignment logs independently of the product analytics system. Bugs that affect the treatment group can also affect event logging. If the logging system is built on the same codebase being tested, the logged outcome events may be differentially missing between groups. Always verify sample counts and event counts from the assignment log against the analytics pipeline before analysis.

Edge Cases

Very Low Traffic Sites (Under 500 Daily Eligible Visitors)

When minimum test duration exceeds 4 weeks for any realistic MDE, standard fixed-horizon A/B testing is often infeasible. Present the user with a structured decision tree:

  1. Relax the MDE: Increase the minimum detectable effect. If the test requires 10 weeks at MDE = 0.5 pp but only 3 weeks at MDE = 2.0 pp, ask whether a 2 pp improvement is meaningful. If yes, proceed.
  2. Increase statistical risk: Reduce power from 80% to 70% or raise α from 0.05 to 0.10. Quantify the trade-off explicitly: at 70% power, 30 out of 100 real effects will be missed.
  3. Concentrate the test: Instead of exposing all traffic, focus on the highest-traffic segment (e.g., only mobile web users, only the most-visited product category). This concentrates sample but limits generalizability.
  4. Use a within-subject (crossover) design: If the outcome is not permanently affected by a single exposure, show users both variants across separate sessions. This dramatically reduces variance and thus sample size. Requires careful washout period design to prevent carry-over.
  5. Accept the limitation: Some products genuinely cannot run valid A/B tests. In this case, recommend qualitative user research, session recording analysis, or expert heuristic evaluation as alternatives.

Multiple Variants (A/B/C or More)

Testing k variants simultaneously requires adjustments:

Continuous High-Skew Metrics (Revenue, Session Duration)

Revenue per user is almost universally right-skewed. The top 1% of users may drive 20-40% of revenue. This creates two problems:

Recommended approaches:

Cannibalization and SUTVA Violations (Network Effects)

The Stable Unit Treatment Value Assumption (SUTVA) requires that one user's treatment assignment does not affect another user's outcome. This fails in social and marketplace contexts:

Pre-Existing Differences Between Groups (Covariate Imbalance)

Even with proper randomization, the observed groups may differ on baseline covariates by chance (more likely with small n):

Overlapping Experiments (Experiment Interaction Effects)

In mature product organizations, dozens of experiments may run simultaneously on the same user population:


Example

Input: "We're adding a progress bar to our multi-step checkout flow (currently 4 steps). Our checkout completion rate is 28%, and we get about 4,500 users entering checkout per day. We think the progress bar will increase completion by reducing anxiety about how many steps are left. We want to detect at least a 2 percentage point improvement."

Output:

A/B Test Design Plan

Experiment: Checkout Progress Bar

Prepared: [Date]


1. Hypothesis

Null hypothesis (H₀): Adding a progress bar to the checkout flow has no effect on checkout completion rate.

Alternative hypothesis (H₁): Adding a progress bar to the 4-step checkout flow will increase checkout completion rate by at least 2.0 percentage points (from 28% to at least 30%).

Test direction: Two-tailed. While improvement is expected, a progress bar that reveals 4 steps might discourage users who assumed fewer steps existed. A negative outcome is operationally relevant.

Mechanism: The progress bar reduces uncertainty about remaining effort, which is a known driver of checkout abandonment. Users who can see they are on step 2 of 4 are more likely to continue than users who have no context for how much remains. This is consistent with goal gradient effect research in behavioral psychology.


2. Experiment Design

| Element | Specification |

|---------|--------------|

| Control (A) | Current 4-step checkout flow with no progress indicator |

| Treatment (B) | Identical 4-step checkout flow with a step-count progress bar displayed at the top of each step ("Step 2 of 4") |

| Unit of randomization | User ID (logged-in users) -- for guest checkout users, cookie-based with a 30-day TTL |

| Eligible population | All users who initiate checkout (arrive at step 1 of the checkout flow) |

| Exclusion criteria | Internal team accounts (identified by email domain), users currently in the cart redesign experiment (mutual exclusion -- overlapping checkout surface), bot traffic (filtered by user-agent and behavioral velocity) |

| Traffic split | 50/50 |

| Assignment method | Hash-based: variant = MD5(user_id + "checkout_progress_bar_v1") mod 100; buckets 0-49 → control, 50-99 → treatment. Guest users use cookie ID as the hash input. |


3. Metrics

Primary metric:

| Field | Value |

|-------|-------|

| Metric name | Checkout completion rate |

| Metric type | Binary proportion |

| Precise definition | Proportion of users who reach step 1 of checkout who also complete step 4 (order confirmation page load), measured per unique user per session day, attributed to the variant they were assigned at step 1. A user who abandons and returns counts as one experiment unit from their first assignment. |

| Baseline value | 28.0% (measured over the trailing 28 days, 95% CI: 27.4% -- 28.6% based on historical daily variance) |

| Minimum detectable effect | 2.0 percentage points absolute (28.0% → 30.0%), which is a 7.1% relative lift |

Guardrail metrics:

| Metric | Baseline | Stop-test threshold | Owner |

|--------|----------|---------------------|-------|

| Revenue per checkout initiator | $12.40 | ≥ 5% relative decline vs. control triggers immediate stop | Revenue team |

| Checkout step 1 → step 2 progression rate | 72.1% | ≥ 3% relative decline (concern that progress bar discourages early steps) | Product |

| Checkout page load time P95 | 2.1 seconds | Any increase > 300ms triggers engineering review | Engineering |

| Customer support contacts re: checkout | 0.8% of initiators | ≥ 25% relative increase triggers stop | CX team |

Secondary / exploratory metrics (observed only, no decision authority):


4. Sample Size and Power

| Parameter | Value |

|-----------|-------|

| Statistical test | Two-proportion z-test (two-sided) |

| Significance level (α) | 0.05 |

| Statistical power (1-β) | 80% |

| Baseline rate (p₁) | 0.280 |

| Expected rate under H₁ (p₂) | 0.300 |

| MDE (absolute) | 0.020 |

| Z_α/2 | 1.960 |

| Z_β | 0.842 |

| Formula | n = (1.960 + 0.842)² × [p₁(1-p₁) + p₂(1-p₂)] / (p₂ - p₁)² |

| Sample size per group | 3,831 |

| Total sample required | 7,662 |

Calculation (full work shown):

(Z_α/2 + Z_β)² = (1.960 + 0.842)² = (2.802)² = 7.851

Numerator:
p₁(1-p₁) + p₂(1-p₂)
= 0.280 × 0.720 + 0.300 × 0.700
= 0.2016 + 0.2100
= 0.4116

Denominator:
(p₂ - p₁)² = (0.300 - 0.280)² = (0.020)² = 0.000400

n_per_group = 7.851 × 0.4116 / 0.000400
            = 3.231 / 0.000400
            = 8,078... 

Wait -- let me recompute precisely:
7.851 × 0.4116 = 3.2311
3.2311 / 0.0004 = 8,077.8

Rounding to 8,078 per group × 2 = 16,156 total.

After precise computation: n = 8,078 per group, 16,156 total.

Note: The simplified approximation (16 × p_avg × (1-p_avg) / MDE²) gives:

The approximation (8,236) is close to the exact value (8,078) -- both round to the same operational answer. Use 8,100 per group (8,078 rounded up for conservatism) and 16,200 total.


5. Timeline

| Parameter | Value |

|-----------|-------|

| Daily total eligible traffic | 4,500 users initiate checkout |

| Traffic fraction allocated to experiment | 100% of checkout initiators (after exclusions, estimated 4,350/day net) |

| Daily traffic per group (50/50) | ~2,175 per group |

| Minimum days to reach sample | 16,200 / 4,350 = 3.7 days (rounds to 4 days) |

| Weekly cycles required | 1 full week (7 days) -- required minimum regardless of sample size |

| Recommended test duration | 14 days (2 full weeks -- captures both weekday and weekend purchase behavior cycles; checkout rates vary significantly Fri-Sun vs. Mon-Wed in e-commerce) |

| Maximum test duration | 28 days |

| Planned start date | TBD -- avoid launching within 5 days of any promotional email campaign or flash sale that would spike checkout volume atypically |

| Planned analysis date | Start date + 14 days |

| Calendar risks | Black Friday, Cyber Monday, Mother's Day, or similar events should not fall within the test window. If they do, extend the test to include the same event in both halves of the test period, or delay until traffic normalizes. |

| Sample adequacy note | At 14 days and 4,350 eligible users/day: expected sample = 60,900 total (30,450 per group) -- this is 3.75× the required sample, providing ample power. The test is limited by the minimum calendar duration (2 weeks), not by traffic. |


6. Pre-Specified Decision Rules

Ship treatment if:

p-value < 0.05 AND observed treatment completion rate > observed control completion rate AND no guardrail metric is breached.

Kill treatment if:

p-value < 0.05 AND observed treatment completion rate < observed control completion rate, OR any guardrail metric exceeds its stop threshold.

Accept null (no change) if:

p-value ≥ 0.05 after 14 days of data collection with ≥ 16,200 total users enrolled. Conclusion: the progress bar does not meaningfully change checkout completion at the 2 pp MDE level. Do not extend the test further. If a smaller effect is hypothesized to be meaningful, a new test should be designed with the revised MDE.

Emergency stop criteria (check daily by monitoring team):

Peeking policy:


7. Results Interpretation Template

(Pre-fill after test completes on day 14)

| Metric | Control | Treatment | Absolute Difference | Relative Difference | p-value | 95% CI |

|--------|---------|-----------|---------------------|---------------------|---------|--------|

| Checkout completion rate | 28.0% | [observed]% | [Δ pp] | [Δ/0.28 %] | [p] | [lower pp, upper pp] |

| Revenue per initiator | $12.40 | [observed] | [$Δ] | [Δ %] | [p] | [$lower, $upper] |

| Step 1→2 progression | 72.1% | [observed]% | [Δ pp] | [Δ %] | [p] | [lower pp, upper pp] |

| Page load P95 | 2.1s | [observed] | [Δ ms] | -- | -- | [lower, upper] |

Decision:

☐ Ship -- treatment showed significant improvement (p = [value], 95% CI [lower, upper pp])

☐ Kill -- treatment showed significant harm (p = [value])

☐ No change -- inconclusive result (p = [value] ≥ 0.05; 2.0 pp MDE not detected)

☐ Emergency stop -- guardrail breach: [specify]

Narrative template (fill in after results):

Checkout completion rate in the progress bar variant was [X]% compared to [Y]% in the control group (absolute difference: [Δ] percentage points, 95% CI: [lower pp, upper pp]; p = [value]).

[If shipping:] This corresponds to approximately [Δ × 4,350 daily users] additional completions per day. At a baseline average order value of $[AOV], the estimated incremental daily revenue is $[Δ × daily completions × AOV]. Recommendation: deploy progress bar to 100% of checkout traffic immediately.

[If killing:] The progress bar reduced completion rates, likely because displaying 4 remaining steps increased perceived effort for users who had not yet committed to completing checkout. Recommend: explore condensing checkout to 3 steps, or testing a progress bar that only appears from step 2 onward to avoid the anchoring effect of revealing full step count at step 1.

[If inconclusive:] No statistically significant difference was observed (p = [value]). The true effect, if any, is likely smaller than 2.0 percentage points. Either the mechanism does not operate at scale,

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.