Marketing Analytics

Chapter 3 · Uncertainty

Nils Wlömert

Vienna University of Economics and Business (WU)

November 2026

Before we start

Paper quiz on Chapter 2 (10 min)

  • Individual, closed book
  • Counts toward participation

Assignment 1 is running

  • Deadline: Group A Mon, Oct 26 · Group B Wed, Oct 28
  • Debrief at the start of next session
  • Questions? → forum on Canvas

Today’s session

Part A — Uncertainty (this deck)

3.1 Is the difference real?
3.2 Populations and samples
3.3 Sampling variation
3.4 The standard error
3.5 The central limit theorem
3.6 Confidence intervals
3.7 Shares and the margin of error
3.8 Uncertainty in R

Part B — Experiments I (next deck)

Comparing two groups: is the difference larger than sampling variation alone would produce?

Driving question: How sure can I be? Every number from a sample is an estimate — today we learn to say how good an estimate it is.

3.1 Is the difference real?

An A/B test at a streaming service

  • New feature Smart Mix: a personalized daily mix on the home screen
  • 400 randomly selected users, randomly split: 200 see Smart Mix, 200 the usual home screen
  • Outcome: listening hours in the four weeks after the start
  • The dashboard shows the two group means →

Would you roll it out? What would you want to know before deciding?

Look at the data

  • 200 users per group, each dot one user
  • The two clouds overlap almost completely
  • A few heavy listeners on the right pull each mean up — the medians (16.4 vs. 19.2) sit below the means

Same 3.2-hour difference — but now we see how many users, how dispersed they are, and that the means are pulled by outliers. Would you still roll it out? Could 3.2 hours be the luck of the draw?

Real effect — or luck of the draw?

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

    Welch Two Sample t-test

data:  hours by group
t = 2.1617, df = 386.96, p-value = 0.03125
alternative hypothesis: true difference in means between group Smart Mix and group Control is not equal to 0
95 percent confidence interval:
 0.293571 6.196096
sample estimates:
mean in group Smart Mix   mean in group Control 
               23.21980                19.97497 

With another 400 users, would the difference be the same? Could Smart Mix do nothing at all? What do t, the p-value, and the “95 percent confidence interval” tell us?

Why statistical inference?

  • The team observed 400 users — the decision concerns all users (millions)
  • 400 users = sample; all users = population
  • The group means — and their difference — are estimates: another random sample, another number

Randomization makes the comparison fair (§1.6).

Statistical inference tells us whether it is precise enough to tell a real effect from the noise of sampling.

Thought experiment 1: what if the sample were larger?

2,000 users per group instead of 200 — with exactly the same group means:

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

    Welch Two Sample t-test

data:  hours by group
t = 6.8057, df = 3960.5, p-value = 0.00000000001157
alternative hypothesis: true difference in means between group Smart Mix and group Control is not equal to 0
95 percent confidence interval:
 2.310072 4.179595
sample estimates:
mean in group Smart Mix   mean in group Control 
               23.21980                19.97497 

Same difference of 3.2 hours — but t = 6.8 instead of 2.2, p = 0.00000000001 instead of 0.03, and the interval shrinks from [0.3; 6.2] to [2.3; 4.2]. More users → less uncertainty about the same difference.

Thought experiment 2: what if users were more similar?

The same 400 users, each pulled halfway toward their group mean — means unchanged, spread halved:

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

    Welch Two Sample t-test

data:  hours by group
t = 4.3234, df = 386.96, p-value = 0.00001957
alternative hypothesis: true difference in means between group Smart Mix and group Control is not equal to 0
95 percent confidence interval:
 1.769202 4.720465
sample estimates:
mean in group Smart Mix   mean in group Control 
               23.21980                19.97497 

Same means, same n — but t = 4.3, p = 0.00002, interval [1.8; 4.7]. Less spread within the groups → less uncertainty about the same difference.

Two ingredients of uncertainty

Users per group Spread (SD) t p
Original test 200 16 / 14 2.2 0.03
Larger sample 2,000 16 / 14 6.8 < 0.001
More similar users 200 8 / 7 4.3 < 0.001

The difference was 3.2 hours in all three cases. What changed is how sure we can be about it — and that depends on only two things: how many users, and how different they are from each other.

Today’s chapter shows where this comes from: the standard error, \sigma / \sqrt{n} — spread divided by the square root of the sample size (§3.4).

The plan for this chapter

The A/B test stays with us. Its outcome is continuous → the uncertainty of a mean:

  • 3.3 How much does a sample mean vary?
  • 3.4 Measuring it: the standard error
  • 3.5 Why the normal distribution keeps showing up
  • 3.6 From an estimate to a confidence interval

Then the same question for shares (converted / not, voted for / not):

  • 3.7 The margin of error of an election poll
  • 3.8 Everything in R — and the A/B test output stops being a mystery

One question throughout: if we had drawn a different sample, how different could our number have been — and how far could it be from the truth?

3.2 Populations and samples

From the sample to the population

  • Population: the whole group we want to learn about (all voters, all customers, all WU students)
  • Census: data from every member — rare, expensive, often impossible
  • Sample: a subgroup we actually observe
  • Statistical inference: generalizing from the sample to the population
Sample (statistic) Population (parameter)
Size n N
Mean \bar{x} \mu
Standard deviation s \sigma
Share \hat{p} p

Parameters: what we want to know. Statistics: what we can compute.

How the sample is drawn matters

Probability sampling Non-probability sampling
Principle Known chance of selection; random Convenience or researcher’s judgment
Techniques Simple random · stratified · cluster · systematic Convenience · quota · judgmental · snowball
Uncertainty Can be quantified Cannot be quantified reliably

Typical sources of selection bias: under-coverage (not in the sampling frame) · non-response (non-respondents differ) · voluntary response (only the strongly opinionated answer)

Your group project uses a convenience sample — fine for learning, but be honest about it. The good news: your experiment is still fair, because conditions are randomized within the sample (§1.6).

Two kinds of error

Random error (sampling variation)

  • Each sample is a slightly different mix of people
  • Quantifiable — and shrinks with larger samples
  • The margin of error is about this kind

Systematic error (bias)

  • The sample differs from the population systematically
  • A larger sample does not help — “more confidently wrong” (§1.6)

Under-coverage, non-response, voluntary response → systematic error. In the A/B test, randomization rules out bias in the comparison — random error remains.

3.3 Sampling variation

A world in which we know the truth

Monthly listening time of all 25,000 WU students — simulated, so we know the true values. In reality we never do: that is why we sample.

One sample, then another

Sampling variation: each random sample of 100 students gives a slightly different mean. Not a mistake — the unavoidable price of looking at a part instead of the whole. The question is only: how large is it?

Live demo: the sampling machine

Course book, §3.3 — draw 1, then 100, then 1,000 samples and watch the means pile up.

https://wu-rds.github.io/MA2026/03-uncertainty.html#sec-unc-sampling

Before clicking “1,000 samples”: where will the sample means pile up — and how far from the true mean will the most extreme ones be?

The sampling distribution

The means of many samples:

  1. Centered on the truth — no over- or underestimation on average
  2. A known width — the standard error
  3. A known shape — normal (even for non-normal data, §3.5)

We only ever have one sample — but these three properties tell us how much to trust it.

3.4 The standard error

How precise is a sample mean?

The width of the sampling distribution:

\sigma_{\bar{x}} = \frac{\sigma}{\sqrt{n}}

  • \sigma: variability in the population
  • n: sample size

Our example: 10 / \sqrt{100} = 1.00 hours

Square-root law: four times the sample, half the standard error — diminishing returns. This is why polls survey ~1,000 people, not 10,000.

What drives the standard error

Larger samples → sample means cluster more tightly. More variable populations → sample means scatter more.

Live demo: what drives the standard error?

Course book, §3.4 — move the sliders for n and σ.

https://wu-rds.github.io/MA2026/03-uncertainty.html#sec-unc-se

Your sample of 100 students gives a standard error of 1 hour per month. Your boss wants half an hour. How many students do you need?

Standard deviation vs. standard error

SD: how much individuals differ. A property of the data — does not shrink with more data.

SE: how much sample means would differ. The precision of the estimate — shrinks with \sqrt{n}.

In practice: estimate σ with s

We never know \sigma — so we use the sample standard deviation s:

SE_{\bar{x}} = \frac{s}{\sqrt{n}}

Our first sample: s = 10.44 → SE = 1.04 hours (true value: 1.00).

Which one to report? Describe how customers differ → SD. Describe how precisely you estimated the mean → SE or a confidence interval. Error bars in charts must say which one they show.

3.5 The central limit theorem

What if the data are not normal?

Marketing data are rarely normal: sales, visits, streams, revenue — most customers a little, a few a lot.

Sample means become normal anyway

Central limit theorem: whatever the shape of the population, the means of samples become normally distributed as n grows — centered on \mu, with width \sigma / \sqrt{n}.

Live demo: the central limit theorem

Course book, §3.5 — choose a population shape, increase n step by step.

https://wu-rds.github.io/MA2026/03-uncertainty.html#sec-unc-clt

Why it matters: we do not need normal data — we need a normal sampling distribution. “n ≥ 30” is a rule of thumb, not a law: for extremely skewed data (streams!) you need much more.

3.6 Confidence intervals

From a point to an interval

Point estimate: “the average listening time is 49.2 hours”

Interval estimate: “… between 47.2 and 51.3 hours”

Casting a net: we cannot see the true mean — but we can throw a net around our estimate that catches it most of the time.

\text{CI} = \text{estimate} \pm \underbrace{\text{critical value}}_{\text{how sure we want to be}} \times \underbrace{\text{standard error}}_{\text{how much the estimate wobbles}}

Net metaphor after Radziwill (2015), Statistics (The Easier Way) with R.

Constructing a 95% confidence interval

  • Sample means are normal around \mu with SD = SE → 95% lie within ± 1.96 SE
  • Turned around: \bar{x} \pm 1.96 \times SE catches \mu in 95% of all samples

Our sample: 49.24 ± 1.96 × 1.04 = [47.19; 51.29] hours

True mean: 49.93 — inside. This time.

What “95% confidence” means

The confidence refers to the method: of all intervals constructed this way, ~95% contain the true mean.

Not quite right: “95% probability that μ is in this interval” — a specific interval either contains μ or not. Fine in practice: “we are 95% confident that …” — remembering that ~1 in 20 such intervals is wrong.

Live demo: how often does the net catch the truth?

Course book, §3.6 — draw batches of 100 intervals; change n and the confidence level.

https://wu-rds.github.io/MA2026/03-uncertainty.html#sec-unc-ci

What happens to the width and to the number of misses when you (a) increase n, (b) switch from 95% to 99%?

Confidence level vs. width

  • More confidence → wider net (99%: 2.58 instead of 1.96)
  • Narrow and reliable → only via larger n
n 10 30 100 ∞
t value (95%) 2.26 2.05 1.98 1.96

Small samples: t-distribution — R does it automatically

3.7 Shares and the margin of error

“Plus or minus 3.1 percentage points”

“The poll was conducted Sept. 13–17 and surveyed 1,000 registered voters nationally. The margin of error is plus or minus 3.1 percentage points.”

— NBC News, September 2024

The same question for a share: more than 150 million people voted. How can 1,000 respondents tell us anything? Where does ± 3.1 come from — and why not survey 10,000?

Many polls, one truth

Polls taken in the same week come to different results — each one is a different random sample. Most of them stay within ± 3 points of the truth. That is what the margin of error describes.

And then the polls were wrong

  • 2016: state polls in several Midwestern states underestimated Trump’s support by more than their margins of error
  • Post-election analyses: late deciders; voters without a college degree underrepresented and not corrected for
  • The margin of error did not warn — because it only covers random error, not the systematic error of 3.2

Kennedy et al. (2018), “An Evaluation of the 2016 Election Polls in the United States”, Public Opinion Quarterly, 82(1), 1–33.

Decoding “± 3.1 percentage points”

Standard error of a share:

SE_{\hat{p}} = \sqrt{\frac{\hat{p}\,(1-\hat{p})}{n}}

Margin of error = 1.96 \times SE_{\hat{p}}, largest at \hat{p} = 50%:

1.96 \times \sqrt{\tfrac{0.5 \times 0.5}{1{,}000}} = \mathbf{0.031}

The margin of error of the lead is roughly twice as large: even the 5-point lead in this poll is not a safe lead.

How many respondents do you need?

Your group project (~120 respondents): a share of ~50% comes with ± 9 points. Think twice before interpreting a 5-point difference.

Live calculator: course book, §3.7

https://wu-rds.github.io/MA2026/03-uncertainty.html#sec-unc-proportions

3.8 Uncertainty in R

A confidence interval for a mean

set.seed(6789)
population <- rgamma(25000, shape = 2, scale = 10)      # the "unknown" population
listening  <- tibble(hours = sample(population, size = 100))
n    <- nrow(listening)
xbar <- mean(listening$hours)
se   <- sd(listening$hours) / sqrt(n)
crit <- qt(0.975, df = n - 1)
c(mean = xbar, lower = xbar - crit * se, upper = xbar + crit * se)
    mean    lower    upper 
19.77946 16.82950 22.72943 
t.test(listening$hours)$conf.int
[1] 16.82950 22.72943
attr(,"conf.level")
[1] 0.95

qt(0.975, …): 2.5% in each tail. t.test() does it all in one line.

Back to the A/B test: intervals per group

ab_test |>
  group_by(group) |>
  summarise(n = n(), mean = mean(hours), se = sd(hours) / sqrt(n),
            lower = mean - qt(0.975, n - 1) * se,
            upper = mean + qt(0.975, n - 1) * se)
# A tibble: 2 × 6
  group         n  mean    se lower upper
  <fct>     <int> <dbl> <dbl> <dbl> <dbl>
1 Smart Mix   200  23.2 1.15   21.0  25.5
2 Control     200  20.0 0.968  18.1  21.9

The bar chart from the start of the session — now with intervals. The two intervals overlap — no effect? Not necessarily: the decision depends on the uncertainty of the difference, which has its own standard error. The interval t.test() reported (0.29 to 6.20 hours) is exactly that → Experiments I.

A confidence interval for a share

Back to the poll: 1,000 voters, 49% Harris, 44% Trump

n_poll <- 1000
p_hat  <- c(Harris = 0.49, Trump = 0.44)
se_p   <- sqrt(p_hat * (1 - p_hat) / n_poll)
cbind(share = p_hat,
      lower = p_hat - 1.96 * se_p,
      upper = p_hat + 1.96 * se_p)
       share     lower     upper
Harris  0.49 0.4590159 0.5209841
Trump   0.44 0.4092336 0.4707664

The same with prop.test():

prop.test(x = 490, n = 1000)$conf.int
[1] 0.4586166 0.5214612
attr(,"conf.level")
[1] 0.95

Each share ± about 3 points — the “± 3.1” from the news report, now computed. prop.test() takes the number of “successes” and the sample size; its interval differs slightly from the hand calculation (it uses the Wilson score interval, more reliable for small samples and shares near 0 or 1). Sample size planning follows in Chapter 4.

What confidence intervals do not tell you

Three limits

  1. Random error only. A biased sample gives a precise but wrong estimate — a larger biased sample, a more precise and equally wrong one (2016 polls; §1.6; §2.5)
  2. Precision, not spread. A narrow interval for the average does not mean customers are alike
  3. A statement about a procedure. ~1 in 20 intervals misses — compute many, and some will

Next: back to Smart Mix — +3.2 hours: larger than sampling variation alone would produce? The difference has its own standard error — the logic of today carries over one to one, and we read the complete t-test output.

Learning check

  1. Smart Mix users listened about 3 hours more. Why does this difference alone not show that Smart Mix increases listening among all users?
  2. A poll of 1,000 voters reports ± 3.1 points. How is this number calculated? Name one error it does not cover.
  3. You double your survey from 400 to 800 respondents. By what factor does the standard error change?
  4. Random sample of 180 users: mean listening time 7.34 hours/week, SD 6.87. Compute the 95% CI (critical value 1.96).
  5. Your website survey (anyone can answer) has 20,000 responses and a very narrow CI. Why might it still mislead?