Marketing Analytics

Chapter 4 · Learning from Experiments

Nils Wlömert

Vienna University of Economics and Business (WU)

November 2026

Part 1 · Experiments I

Today, part B

Experiments I (session 3)

4.1 Back to the A/B test
4.2 The difference between two means
4.3 Testing a hypothesis
4.4 Same people, both conditions: the paired t-test
4.5 How large is the effect?
4.6 Reporting the result

Experiments II (session 4)

4.7 The difference between two shares
4.8 How many users do we need?
4.9 More than two groups and other tests
4.10 Using p-values responsibly

Driving question: Did it work?

4.1 Back to the A/B test

Smart Mix: +3.2 hours

t.test(hours ~ group, data = ab_test)

    Welch Two Sample t-test

data:  hours by group
t = 2.2, df = 387, p-value = 0.03
alternative hypothesis: true difference in means between group Smart Mix and group Control is not equal to 0
95 percent confidence interval:
 0.2936 6.1961
sample estimates:
mean in group Smart Mix   mean in group Control 
                  23.22                   19.97 

Where Chapter 3 ended: two means with their intervals — and a test output with numbers we have not decoded yet.

Before any test: look at the data

Boxplot + the actual users (jitter): the first chart in any analysis.

  • How many? 200 dots per group
  • How spread out? Boxes (middle 50%) overlap almost completely
  • Outliers? A few heavy listeners on the right in both groups; the mean (red) sits above the median (box line)
  • Comparable groups? Same shape, similar spread → the t-test’s assumptions look fine
ggplot(ab_test, aes(x = group, y = hours)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(width = 0.15, alpha = 0.3)

Three questions for the product team

  1. Could the difference be chance? Two random groups never have exactly the same mean — is 3.2 hours more than chance typically produces?
  2. How large is the effect — and does it matter?
  3. Was the experiment large enough? How large should the next one be?

The formulas stay minimal: we compute one standard error by hand to see what a test does. After that, R does the arithmetic — we do the interpretation.

4.2 The difference between two means

Signal and noise

Repeat the experiment many times → the difference varies too. Its sampling distribution is:

  1. Centered on the true effect
  2. Approximately normal (central limit theorem)
  3. As wide as the standard error of the difference:

SE_{\bar{x}_1 - \bar{x}_2} = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}

Smart Mix:

\sqrt{\frac{16.2^2}{200} + \frac{13.7^2}{200}} = 1.50 \text{ hours}

Every test compares the signal (observed difference) with the noise (the standard error). This is the only SE we compute by hand today.

A world in which Smart Mix does nothing

If Smart Mix had no effect, a difference of 3.2 hours or more would occur in only ~4% of experiments. Either Smart Mix works — or the team saw a rare accident.

Live demo: how surprising is the difference?

Course book, §4.2 — change the users per group and the observed difference.

https://wu-rds.github.io/MA2026/04-experiments.html#sec-exp-difference

Is a difference of 3.2 hours surprising with 50 users per group? With 800?

4.3 Testing a hypothesis

Null hypothesis and test statistic

  • H_0: no effect, \mu_1 = \mu_2
  • H_1: an effect, \mu_1 \neq \mu_2

Test statistic = signal / noise:

t = \frac{3.24 - 0}{1.50} = 2.16

If H_0 were true, 95% of all t values would lie between −1.97 and +1.97. Ours lies outside.

The p-value and the decision

p-value: the probability of a difference at least as extreme as the observed one — if H_0 were true.

  • Smart Mix: p = 0.031 — in a no-effect world, ~3 in 100 experiments would show ≥ 3.2 hours
  • Decision rule with significance level \alpha = 5% (chosen in advance):
    • p < \alpha → statistically significant, reject H_0
    • p \geq \alpha → do not reject H_0 — not “there is no effect”

Our simulation said ~4%, the t-test says 3.1% — the test formalizes the thought experiment.

The confidence interval of the difference

(\bar{x}_1 - \bar{x}_2) \pm t_{0.975} \times SE_{\bar{x}_1 - \bar{x}_2} = 3.24 \pm 1.97 \times 1.50

CI excludes 0 ⇔ p < 0.05. Test and interval always agree.

The interval tells more: the effect could be a quarter of an hour — or six hours.

Reading the output

Output Meaning
Welch Two Sample t-test Two independent groups; equal variances not assumed (R’s safe default)
t = 2.1617 Observed difference = 2.16 standard errors away from zero
df = 386.96 Degrees of freedom — shape of the t-distribution; irrelevant for large samples
p-value = 0.03125 With no effect, ≥ this difference in 3.1% of experiments
alternative hypothesis: … Two-sided: a difference in either direction
95 percent confidence interval: 0.29 6.20 Effects compatible with the data
mean in group … Group means; their difference = the estimated effect

Degrees of freedom — intuitively

An information budget. Each observation is one piece of information. Every quantity we estimate from the data uses one up. What is left — n minus the number of estimated parameters — is the information available for judging the noise.

Situation Estimated df
One sample, SD of n values 1 mean n - 1
Two groups (t-test) 2 means n_1 + n_2 - 2
ANOVA with 3 groups 3 means N - 3
Regression with k predictors k + 1 coefficients n - k - 1

Why “free to vary”? Budget of 100 € for three presents, all spent: choose present 1 (30 €) and 2 (50 €) freely — present 3 is fixed (20 €). Three values, one constraint → 2 degrees of freedom. Same with deviations from a mean: once the mean is known, the last deviation is determined.

Fewer df → less information about the noise → the standard error is itself uncertain → fatter tails, larger critical values. Smart Mix: ~398 df → practically the normal distribution. Welch’s 386.96: a weighted version of the same idea.

Your turn (5 min)

Run the test again with only the first 50 users per group:

t.test(hours ~ group,
       data = ab_test |> group_by(group) |> slice_head(n = 50))

How do the difference, the confidence interval, and the p-value change? Explain with the standard error.

4.4 The same people in both conditions: the paired t-test

Two designs, two tests

Design (§1.6) Who is compared Data Test
Between-subjects Different people in each condition One row per person + a group variable Welch t-test: t.test(y ~ group)
Within-subjects The same people in every condition One row per person, one column per condition Paired t-test: t.test(x1, x2, paired = TRUE)

Smart Mix was between-subjects (each user saw one home screen) → Welch test. The question does not change with the design — but the data come in pairs, and the test must use that.

Same people, both conditions: the design

The question: does the new search design let users find songs faster?

Within-subjects design: the same 60 users search for songs with the old design and with the new one, in random order (half old → new, half new → old). Outcome: seconds to find a song.

search_test <- search_data()
head(search_test, 4)
# A tibble: 4 × 3
   user old_design new_design
  <int>      <dbl>      <dbl>
1     1       38.5       39.3
2     2       38.9       30.7
3     3       43.2       50.8
4     4       51         41.8
  • Each user appears twice → the two columns are not independent: a fast user is fast with both designs
  • What varies between users (skill, familiarity) is huge; what we care about is the difference within each user
  • So the test looks at one number per user: new − old
head(search_test$new_design - search_test$old_design, 8)
[1]  0.8 -8.2  7.6 -9.2  0.5  1.7 -3.7 -3.7

Same people, both conditions: the test

t.test(search_test$new_design, search_test$old_design, paired = TRUE)

    Paired t-test

data:  search_test$new_design and search_test$old_design
t = -3.9, df = 59, p-value = 0.0003
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
 -3.235 -1.031
sample estimates:
mean difference 
         -2.133 

paired = TRUE tests whether the mean of the within-user differences is zero: the new design saves 2.1 seconds (95% CI 1.0–3.2). Each user is their own control — the differences between users drop out.

The same data as a between-subjects comparison

t.test(search_test$new_design, search_test$old_design)   # ignores the pairing

    Welch Two Sample t-test

data:  search_test$new_design and search_test$old_design
t = -1.5, df = 118, p-value = 0.1
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -4.9714  0.7047
sample estimates:
mean of x mean of y 
    39.49     41.62 

Same data, same means, same 2 seconds — but p = 0.14 and the interval includes 0. The independent-groups test judges the difference against the spread of all search times (users differ: SD ≈ 8 s); the paired test against the spread of the within-user differences (SD ≈ 4 s). Comparing different people adds uncertainty — the within-subjects design removes it.

When to use which: between-subjects data → Welch test (nothing to pair). Within-subjects data, matched pairs, before/after on the same people → paired test. Price of within-subjects: carryover and order effects (§1.6) — the paired test cannot fix those.

Your turn: QuickBite (15 min)

A food-delivery app — two experiments, two data sets (04-experiments.R, section “Your turn”):

(1) The free-delivery voucher. 300 new customers, randomly split: 150 got a voucher for their first four weeks, 150 did not. Outcome: order value in euros.

  • Look at the data (boxplot + jitter)
  • Summarise the groups and draw the chart with intervals
  • Run the appropriate t-test
  • Report the result in one sentence: effect, uncertainty, test

(2) The routing app. 40 couriers delivered with the old app and the new one (random order). Outcome: minutes per delivery.

  • Draw the chart that shows the within-courier comparison
  • Run the appropriate t-test and report the result
  • Run the test for a between-subjects design on the same two columns — what changes, and why?

First question for both: which design is this — and therefore which test?

4.5 How large is the effect?

Significant ≠ large ≠ important

  • Original unit: +3.2 hours in four weeks
  • Relative: +16% vs. control (20.0 hours)
  • Standardized: Cohen’s d — the difference in units of the spread of individuals

d = \frac{\bar{x}_1 - \bar{x}_2}{s_{\text{pooled}}}, \qquad s_{\text{pooled}} = \sqrt{\frac{s_1^2 + s_2^2}{2}}

Smart Mix: s_{\text{pooled}} = √((16.2² + 13.7²)/2) = 15.0 hours → d = 3.2 / 15.0 = 0.22

psych::cohen.d(ab_test$hours, ab_test$group)$cohen.d
       lower  effect upper
[1,] -0.4131 -0.2167 -0.02

(Sign = order of the groups; size ≈ 0.22. For unequal group sizes, R weights the two variances by group size — still no √n anywhere.)

t vs. d — same numerator, different denominator. t divides by the standard error s_{\text{pooled}}\sqrt{2/n}, which shrinks with √n → t grows with the sample. d divides by s_{\text{pooled}} itself → the same at 400 or 40,000 users. t says how detectable the effect is; d how large.

Conventions (Cohen, 1992): 0.2 small · 0.5 medium · 0.8 large — a starting point, not a verdict: +16% listening time can be worth a lot.

4.6 Reporting the result

Effect first, uncertainty second, test last

Users with Smart Mix listened on average 23.2 hours in four weeks, compared with 20.0 hours in the control group — an increase of 3.2 hours (+16%, 95% CI [0.3; 6.2] hours). The difference is statistically significant (Welch t-test: t(387) = 2.16, p = .031) but small in standardized terms (d = 0.22). The confidence interval is wide: the true effect could be anywhere between a few minutes and six hours.

The last sentence is the most important one: it tells the reader how much the conclusion is worth.

The chart that goes with the paragraph: means, their intervals, and the test result on the bracket.

Part 2 · Experiments II

Before we start

Debrief A1 + quiz Chapter 3 (15 min, one sheet)

  • Page 1: debrief of Assignment 1 (3 assignment points)
  • Page 2: quiz on Chapter 3 (participation)
  • Closed book, no laptop

Assignment 2 is handed out today (end of session).

New: devices only when we code

  • Input blocks: laptops closed, phones away — follow the slides and the live examples
  • Coding blocks (2 × 25 min): laptops open, work alone or with your neighbor
  • At the end of each block, one group presents its results

Today: shares → sample size → coding block 1 → ANOVA → coding block 2 → non-parametric tests → p-values.

4.7 The difference between two shares

A Premium trial offer

  • New Premium page with a one-month free trial vs. standard page
  • 2,000 free users per group, randomized
  • Outcome: upgrade within two weeks (yes/no)

prop.test(x = c(131, 104), n = c(2000, 2000))

    2-sample test for equality of proportions with continuity correction

data:  c(131, 104) out of c(2000, 2000)
X-squared = 3.1, df = 1, p-value = 0.08
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.001569  0.028569
sample estimates:
prop 1 prop 2 
0.0655 0.0520 

Same logic as for means

SE_{\hat{p}_1 - \hat{p}_2} = \sqrt{\frac{\hat{p}_1 (1 - \hat{p}_1)}{n_1} + \frac{\hat{p}_2 (1 - \hat{p}_2)}{n_2}} \qquad \text{CI: } (\hat{p}_1 - \hat{p}_2) \pm 1.96 \times SE

  • \hat{p}(1 - \hat{p}) takes the place of s^2: it is the variance of a yes/no variable
  • Largest at 50/50, small when (almost) everyone or no one converts

Same intuition as for means: more variation within the groups and smaller groups → more uncertain difference. Premium test: 1.35 ± 1.96 × 0.74 = [−0.11; 2.81] points.

“Not significant” — so it does not work?

  • +1.35 percentage points (+26% relative) — but p = 0.08
  • 95% CI of the difference: −0.16 to +2.86 points
  • Compatible with no effect — and with a substantial one

Why not [−0.11; 2.81] as on the previous slide? prop.test() applies a continuity correction by default (counts are whole numbers): the interval widens by ½ × (1/2,000 + 1/2,000) = 0.05 points on each side, and p rises from 0.07 to 0.08. prop.test(..., correct = FALSE) reproduces the hand calculation exactly.

The right conclusion: “this experiment was too small to tell” — not “the trial offer does not work”. (prop.test() = chi-square test for a 2 × 2 table; chisq.test() for more groups or categories.)

Your turn (5 min)

Two sales agents each talk to 300 customers. Jon gets 200 to buy, Mark 100.

  1. Is Jon’s conversion rate significantly higher? Use prop.test() and report the difference with its 95% CI.
  2. Does this show that Jon is the better salesperson?

Example after McDonnell Feit & McCullough, Business Experiments.

4.8 How many users do we need?

Sample size: decide before you start

Means — Smart Mix, d = 0.22, 80% power:

power.t.test(delta = 0.22, sd = 1, power = 0.80)$n
[1] 325.3

Shares — Premium test, 5% → 6%:

power.prop.test(p1 = 0.05, p2 = 0.06, power = 0.80)$n
[1] 8158

Start from the smallest effect that would still matter for the decision — not from the effect you hope for.

  • Smart Mix: ~330 per group (not 200)
  • Premium test: > 8,000 per group (not 2,000)
  • Omit power and give n instead → the power of the test you ran

Why online advertising needs huge experiments

  • CTR 0.50% → 0.55% (+10%): > 300,000 users per group
  • Lewis & Rao (2015), The Unfavorable Economics of Measuring the Returns to Advertising: even experiments with millions of users are often too imprecise to tell whether ads pay off
  • Remember eBay (§1.2): the whole US market

Low baseline rates + small lifts = enormous samples.

Lewis & Rao (2015), “The Unfavorable Economics of Measuring the Returns to Advertising”, Quarterly Journal of Economics, 130(4), 1941–1973.

What the 80% means: two ways to be wrong

No effect in reality (H_0 true) Effect in reality (H_0 false)
Significant Type I error — false alarm (\alpha) ✓ effect detected (power = 1 - \beta)
Not significant ✓ Type II error — effect missed (\beta)
  • \alpha = 5% (sig.level): one in twenty tests of a useless feature is “significant” anyway
  • Power = probability of detecting a real effect of the assumed size (power = 0.80): one in five real effects of that size is still missed
  • Fewer errors of both kinds → only with larger samples — which is exactly what power.t.test() / power.prop.test() compute

Live demo: how many users does a conversion test need?

Course book, §4.8 — baseline rate, lift, and traffic per day.

https://wu-rds.github.io/MA2026/04-experiments.html#sec-exp-power

Your group project: ~60 per condition → only d \gtrsim 0.5 detectable with 80% power (small effects: < 20% power). Make your manipulation strong.

Your turn (5 min)

A newsletter has a click-through rate of 2%. A new subject line should be tested.

  1. How many recipients per version for detecting +10% (2.0% → 2.2%) with 80% power?
  2. And if only +25% matters?

Use power.prop.test().

Type I and II errors in everyday life

Situation Type I error (false alarm) Type II error (missed effect)
Pregnancy test “Pregnant” — but she is not “Not pregnant” — but she is
Smoke detector Alarm because of burnt toast Real fire, no alarm
Court trial Innocent person convicted Guilty person acquitted
A/B test Useless feature rolled out Valuable feature dropped

The court trial is a test: H_0 = “innocent” is kept unless the evidence is strong. “Not guilty” does not prove innocence — just as “not significant” does not prove “no effect”.

What determines power

Effect size · sample size · variability. With a true effect of 3 hours, Smart Mix had only ~55% power — the team was somewhat lucky.

Live demo: what determines power?

Course book, §4.8 — change the true effect, the users per group, and α.

https://wu-rds.github.io/MA2026/04-experiments.html#sec-exp-power

Halve the true effect. How many more users do you need for the same power?

Where does the true effect come from?

In the widget, you set the true effect — in practice, you never know it (otherwise: no experiment needed). Power analysis uses an assumed effect:

  • the smallest effect that would still matter for the decision
  • evidence from earlier experiments (with caution)

No “post-hoc power”: computing power after the experiment with the observed effect adds nothing — it is just a transformation of the p-value. Power belongs to the planning stage; afterwards, look at the confidence interval.

Coding block 1: a newsletter A/B test (25 min)

The case. A streaming service tests a new subject line for its weekly newsletter: 8,000 subscribers, randomly split — 4,000 get the old subject line, 4,000 the new one. Outcome: did the subscriber click (1) or not (0)?

Data: newsletter_test.csv — section “Coding block 1” in 04-experiments.R

Laptops open — alone or with your neighbor.

Tasks (same steps as the Premium example)

  1. Compute the click rate per version with its 95% confidence interval, and draw the bar chart with intervals
  2. Run prop.test(): is the difference significant? Report it in one sentence — effect, uncertainty, test
  3. Sample size: with the old click rate as the baseline, how many subscribers per version would a follow-up test need to detect a 10% relative increase with 80% power?

At the end: one group presents its numbers.

4.9 More than two groups and other tests

More than two groups: the setup

Three versions of Smart Mix, tested at once:

  • No mix (control) · Weekly mix (updated once a week) · Daily mix (updated every day)
  • 450 users, randomly assigned: 150 per version → a between-subjects design with three groups
  • Outcome: listening hours in four weeks

The product team asks: does the update frequency matter — and if so, which version is better than which?

Before any test: look at the data

  • 150 users per version
  • Large overlap; the means (red) rise from no mix to daily mix
  • Right-skewed in all groups, a few heavy listeners; similar spread
  • Same three lines of code as for two groups:
ggplot(mix_test, aes(x = version, y = hours)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(width = 0.15, alpha = 0.3)

More than two groups: why not several t-tests?

Three versions → three pairwise tests, each with a 5% false-alarm risk:

\text{family-wise error rate} = 1 - (1 - \alpha)^k

  • 3 tests: 14% · 10 tests (5 groups): 40%

Two steps: (1) Is there any difference? → ANOVA. (2) Which groups differ? → corrected pairwise comparisons.

Where the F comes from: three sums of squares

Total = model + residual: SS_T = SS_M + SS_R

135,122 = 3,367 + 131,755

F = \dfrac{SS_M / (k - 1)}{SS_R / (N - k)} = \dfrac{3{,}367 / 2}{131{,}755 / 447} = 5.71 · \eta^2 = SS_M / SS_T = 2.5%

Same formula, another world: the version explains a lot

Group means far apart (9.7 / 22.1 / 34.1 hours), users within a group similar → most of the total variation lies between the groups.

\eta^2 = 44,550 / 55,075 = 81% · F(2, 447) = 946, p < .001

… and a world where it explains nothing

Group means (almost) equal to the grand mean (22.1 / 20.8 / 22.2 hours) → the model panel is (almost) empty: SS_R \approx SS_T.

\eta^2 = 200 / 104,549 = 0.2% · F(2, 447) = 0.43, p = .65 — no evidence that the version matters

Step 1: the ANOVA

  • H_0: \mu_1 = \mu_2 = \mu_3 · H_1: at least one mean differs
  • Signal / noise again:

F = \frac{\text{variation between groups (per df)}}{\text{variation within groups (per df)}}

  • No effect → F \approx 1
  • Effect size \eta^2 = share of variation explained
mix_aov <- aov(hours ~ version, data = mix_test)
summary(mix_aov)
             Df Sum Sq Mean Sq F value Pr(>F)   
version       2   3367    1683    5.71 0.0036 **
Residuals   447 131755     295                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ss <- summary(mix_aov)[[1]]$`Sum Sq`
ss[1] / sum(ss)   # eta squared
[1] 0.02492

F(2, 447) = 5.71, p = .004 — at least one version differs; but the versions explain only 2.5% of the variation.

Step 2: corrected pairwise comparisons

Uncorrected (each test at 5%):

pairwise.t.test(mix_test$hours, mix_test$version,
                p.adjust.method = "none")$p.value
              No mix Weekly mix
Weekly mix 0.1910654         NA
Daily mix  0.0008673    0.04158

Bonferroni-corrected:

pairwise.t.test(mix_test$hours, mix_test$version,
                p.adjust.method = "bonferroni")$p.value
             No mix Weekly mix
Weekly mix 0.573196         NA
Daily mix  0.002602     0.1247

Bonferroni, step by step: 3 comparisons, family-wise \alpha = 5%

  • Test each comparison at \alpha / k = 0.05 / 3 = 0.0167 …
  • … or, equivalently, multiply each p by k = 3 and compare with 0.05 (R does this)
  • Daily vs. weekly: raw p = 0.042 → × 3 = 0.125 — not significant any more

Only daily vs. no mix differs (p = .003). Alternatives: Holm (R’s default, equally safe, more powerful), Tukey’s HSD (TukeyHSD(mix_aov)).

Reporting an ANOVA

Mean listening time differed between the three versions of Smart Mix (no mix: 19.1 hours, weekly mix: 21.7, daily mix: 25.7; one-way ANOVA: F(2, 447) = 5.71, p = .004, \eta^2 = .025). Bonferroni-corrected pairwise comparisons showed that users with the daily mix listened 6.6 hours more than users without a mix (p = .003); the weekly mix did not differ significantly from either of the other versions (both p > .12).

Means first, then the overall test with df, p and effect size, then which groups differ (corrected).

Coding block 2: three versions of a price page (25 min)

The case. An online shop tests three versions of its checkout page: Standard, Discount banner, Bundle offer. 360 customers, randomly assigned (120 per version). Outcome: order value in euros.

Data: price_page.csv — section “Coding block 2” in 04-experiments.R

Laptops open — alone or with your neighbor.

Tasks (same steps as the Smart Mix example)

  1. Look at the data: boxplot with jitter
  2. Summarise the versions (n, mean, SD, 95% CI) and draw the bar chart with intervals
  3. Run the ANOVA: do the versions differ at all?
  4. Bonferroni pairwise comparisons: which versions differ?
  5. Report the result in two sentences

At the end: one group presents its numbers.

Non-parametric tests: ranks instead of values

  • Sort all values, use their ranks → extremes cannot dominate
  • For ordinal outcomes, or strong skew / outliers in small samples
  • Ask about the typical observation, not the average
  • Slightly less power when t-test assumptions hold
Design Parametric Non-parametric
2 groups Welch t-test Wilcoxon rank-sum
Same people Paired t-test Wilcoxon signed-rank
3+ groups ANOVA Kruskal–Wallis
wilcox.test(hours ~ group, data = ab_test)$p.value
[1] 0.07318

Smart Mix: t-test p = .031, Wilcoxon p = .073 — different questions: average (pulled up by heavy listeners) vs. typical user. Code for all three tests: “Under the hood” boxes in the book.

Choosing a test

Outcome Groups Design Test R
Metric 2 different people Welch t-test t.test(y ~ group)
Yes/no 2+ different people proportions / chi-square prop.test(), chisq.test()
Metric 2 same people paired t-test t.test(x1, x2, paired = TRUE)
Metric 3+ different people ANOVA + corrected post-hoc aov(), pairwise.t.test()
Ordinal / extreme skew, small n 2 different people Wilcoxon rank-sum wilcox.test(y ~ group)
Ordinal / extreme skew, small n 2 same people Wilcoxon signed-rank wilcox.test(x1, x2, paired = TRUE)
Ordinal / extreme skew, small n 3+ different people Kruskal–Wallis kruskal.test(y ~ group)

Choosing a test: a decision tree

flowchart LR
  A["Outcome?"] -->|Metric| Q["Assumptions<br/>in doubt?"]
  A -->|Yes/no| C["prop.test()<br/>chisq.test()"]
  A -->|Ordinal| N["Groups?"]
  Q -->|No| B["Groups?"]
  Q -->|"Yes (small n, extreme<br/>skew / outliers)"| N
  B -->|Two| D["Same people?"]
  B -->|3+| E["ANOVA +<br/>post-hoc"]
  D -->|No| F["Welch t-test"]
  D -->|Yes| G["Paired t-test"]
  N -->|"Two, different people"| H["Wilcoxon<br/>rank-sum"]
  N -->|"Two, same people"| I["Wilcoxon<br/>signed-rank"]
  N -->|3+| J["Kruskal–Wallis"]

A starting point, not a recipe: the right analysis follows from the research question and the design — not from walking down a tree.

4.10 Using p-values responsibly

What a p-value is — and what it is not

p = P(data | H_0)

“If there were no effect, how likely would data like ours be?”

Not: P(H_0 | data)

P(runny nose | cold) ≠ P(cold | runny nose)

p = 0.031. True or false?

  1. 3.1% probability that Smart Mix has no effect
  2. 96.9% probability that Smart Mix works
  3. The effect is important

Significant ≠ important · not significant ≠ no effect

  • Significance depends on n: with millions of users, almost everything is “significant”
  • Absence of evidence ≠ evidence of absence: the Premium test was not significant, but compatible with +3 points
Everyday comparison d n per group (80%)
Men taller than women 1.85 6
Spicy-food fans like Indian food more 0.80 26
Men weigh more than women 0.59 46
Science fans name more planets 0.07 3,669

Nothing special happens at p = 0.05: 0.049 is no stronger evidence than 0.051. Report the exact p, the effect size, and the CI — as leading journals (e.g., JM, JMR) now ask authors to do.

Simmons, Nelson & Simonsohn (2013), survey of 697 US participants; Wasserstein & Lazar (2016), “The ASA Statement on p-Values”, The American Statistician.

Peeking destroys the p-value

Checking the dashboard every day and stopping at p < 0.05 turns a 5% false-alarm rate into 30–40%. Fix the sample size in advance; evaluate once — or use sequential testing.

Live demo: the danger of peeking

Course book, §4.10 — 200 A/B tests without any effect; the analyst stops at the first p < 0.05.

https://wu-rds.github.io/MA2026/04-experiments.html#sec-exp-nhst

What happens to the false-alarm rate if the analyst checks more often, or lets the test run longer?

Many metrics, many segments, many tests

  • 20 metrics or segments, no true effect anywhere: 1 - 0.95^{20} = 64% chance of at least one “significant” result
  • Reporting only the hits = p-hacking
  • Paying attention only to “successes” = publication bias
  • Remedy: pre-registration — hypotheses, outcome, n, and analysis recorded before data collection (AsPredicted, OSF); now common practice in science, incl. marketing

van Zwet & Cator (2021), Statistica Neerlandica, CC BY-NC-ND 4.0

Good practice for experiments

  1. Before: outcome, hypothesis, smallest relevant effect, sample size — written down (pre-registration)
  2. During: no early stopping because the result looks good (or bad)
  3. After: effect size + confidence interval + exact p — planned outcome first, everything else labeled exploratory
  4. Decide with more than the p-value: size, uncertainty, costs, benefits

Assignment 2: analyzing experiments

  • Your personal experiment data (based on your student ID): an A/B test of a new onboarding flow + a three-version follow-up test
  • Tasks: describe · t-test · effect size · shares · sample size · ANOVA
  • Deadline: Group A Sun, Nov 8 · Group B Wed, Nov 11
  • Debrief at the start of the following session

10 points: report 7 + debrief 3. Report effect sizes and confidence intervals — not just p-values. Your results may well be non-significant — interpret them correctly.

Learning check

  1. A checkout test: +2.40 €, 95% CI [−0.30 €; 5.10 €], p = 0.08. Significant? One correct sentence for the head of e-commerce?
  2. A new ad creative on 5 million users: CTR 0.410% → 0.415%, p < 0.001. Roll it out?
  3. A colleague stops the test on the first day with p < 0.05. What is wrong?
  4. Which test? (a) Conversion rates of three newsletter versions (b) Ratings (1–7) of the same 40 customers for two prototypes (c) Basket size, discount banner vs. none, 3,000 customers per group

Next session

Module 5 · Observational data I — What if we cannot randomize?

  • Confounding, revisited — with data
  • Regression as adjustment
  • From correlation to (careful) causal claims