Business Analytics & Data Science

B04 · Intermediate

Descriptive and Inferential Statistics

10 lessons

B04 · Module 3, lesson 2 · Lesson 8 of 10

Comparing two means

Compare two means the way the data were collected: with a paired t test when the same units are measured twice, and with Welch’s t test when the groups are separate. Run both by hand, with T.TEST and with the Analysis ToolPak, put an interval and an effect size on the difference, and check the conditions before trusting any of it.

About 80 minutes

Before you start

You will be able to

  • Choose between a paired and an independent-samples test from how the data were collected, and explain why pairing can reveal a difference that a two-sample test misses.
  • Calculate Welch’s and the pooled two-sample t statistic, degrees of freedom and p-value by hand and with T.TEST types 1 to 3, and explain why Welch’s test is the safer default.
  • Read the Analysis ToolPak’s three t-test outputs, including the one- and two-tail rows and the rounded degrees of freedom of the unequal-variances tool.
  • Construct and interpret a confidence interval for a difference in means and for a mean difference, and report an effect size with Cohen’s d.
  • Assess independence, normality or sample size, and outliers before a comparison, and recognise when a rank test such as Mann–Whitney or Wilcoxon’s is worth considering.

Review first

Fictional case A fictional coffee business founded by Ana Lim. It starts as a catering and barista-training service, opens its own cafés and an online shop for beans, and plans a canned cold brew.

The idea

Fictional case

In October Ana ran a two-hour latte-art workshop for 12 trainee baristas. A senior barista scored each trainee’s pour out of 20 before the workshop and again after it. The trainees averaged 10.00 points before and 11.58 after. Before she adds the workshop to Lantern’s staff training plan, Ana wants to know whether the 1.58-point rise is more than the ups and downs of a dozen pours.

Two samples, or one sample of pairs?

The scores look like two samples, a column of 12 before and a column of 12 after, and the In depth section’s two-sample test compares two columns’ means. Run on these columns it finds nothing: Welch’s t test gives t = 0.99 and p = 0.33. The trainees differ so much from one another, with standard deviations of 3.54 points before and 4.23 after, that a 1.58-point rise in the average is lost in the noise.

But the columns are not two separate groups: they are the same 12 people measured twice. Trainee 3 scored 16 both times; trainee 5 scored 4 before and 3 after. What matters is each person’s change. Subtract each trainee’s before score from the after score and the 24 numbers become 12 differences: 2, 2, 0, 5, −1, 3, 1, 1, 1, 1, 2 and 2. Ten trainees improved, one stayed the same and one slipped by a point.

Left: each trainee’s before and after scores joined by a line. The scores run from 3 to 17 points, but nearly every line rises. Right: the 12 differences, after minus before, run from −1 to 5 points around their mean, 1.583, with a standard deviation, sd, of only 1.505 points.

The paired t test

With the differences in hand, the question becomes a one-sample question from the previous lesson: is the mean difference μd\mu_d zero? Ana tests H0:μd=0H_0: \mu_d = 0 against H1:μd≠0H_1: \mu_d \ne 0, two-sided because a workshop that confused trainees would matter too. The differences have mean dˉ=1.583\bar{d} = 1.583 and standard deviation sd=1.505s_d = 1.505, so:

t=dˉsd/n=1.5831.505/12=1.5830.4345≈3.64t = \dfrac{\bar{d}}{s_d / \sqrt{n}} = \dfrac{1.583}{1.505 / \sqrt{12}} = \dfrac{1.583}{0.4345} \approx 3.64

with n − 1 = 11 degrees of freedom. The test needs independent pairs and roughly normal differences: the trainees were scored one at a time, and the 12 differences have no extreme value (the largest, 5, is 2.3 standard deviations above their mean). The two-sided p-value, =T.DIST.2T(3.644,11), is 0.0039: strong evidence that the scores rose. Same data, same question, and p = 0.004 instead of p = 0.33.

This is the paired t test. In Excel it is =T.TEST(C2:C13,B2:B13,2,1), with the before scores in B and the after scores in C: the last argument, type 1, means paired.

Why pairing helps

Both tests divide the same 1.58-point rise by a standard error; they differ in which one. The two-sample test’s standard error, 1.59 points, contains all the differences between trainees, beginners and good pourers alike. The paired test’s, 0.43 points, contains only how much the trainees’ changes vary, because subtracting a trainee’s before score from the after score cancels whatever makes that trainee good or bad.

The cancelling works because before and after scores are strongly correlated: trainees who scored high before scored high after, with r = 0.94. The variance of the differences is s12+s22−2rs1s2=17.90+12.55−2×0.9403×4.231×3.542≈2.27s_1^2 + s_2^2 - 2 r s_1 s_2 = 17.90 + 12.55 - 2 \times 0.9403 \times 4.231 \times 3.542 \approx 2.27, so sds_d = 1.505, against standard deviations of 4.23 and 3.54 for the scores themselves. The stronger the correlation, the more pairing gains.

What the test shows is that the scores rose by more than chance would produce. It doesn’t show that the workshop caused the rise: trainees pouring later in the day might have improved with practice anyway, and a trainee who poured unusually badly before is likely to score nearer their usual level afterwards, which is regression to the mean. Answering “did the workshop cause it?” needs a control group of trainees scored twice without the workshop, ideally assigned at random, as in an A/B test.

In depth

Independent samples and Welch’s t test

When the two samples are separate groups, such as hires from two bike stations or calls handled with two scripts, they are independent samples, and the question is whether the population means μ1\mu_1 and μ2\mu_2 differ. The null hypothesis is H0:μ1−μ2=0H_0: \mu_1 - \mu_2 = 0 (or a stated difference Δ0\Delta_0, “delta-nought”), against a one- or two-sided alternative. The estimate is the difference in sample means, and its standard error combines the two samples’ standard errors:

SE=s12n1+s22n2\text{SE} = \sqrt{\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}}

A two-sample t test divides the difference by this standard error. Welch’s t test compares the result with a t distribution whose degrees of freedom come from the Welch–Satterthwaite formula in the Formulas section. Its result always lies between the smaller of n₁ − 1 and n₂ − 1 at the low end and n₁ + n₂ − 2 at the high end. It is usually not a whole number, and it falls towards the low end when one sample is much noisier or much smaller than the other. The simple example runs the test on two bike-hire stations.

The pooled test, and why Welch is the safer default

The older pooled t test, Student’s two-sample t test, assumes the two populations have the same variance. It averages the two sample variances, weighted by their degrees of freedom, into a pooled variance sp2s_p^2, uses sp1/n1+1/n2s_p\sqrt{1/n_1 + 1/n_2} as the standard error, and has n1+n2−2n_1 + n_2 - 2 degrees of freedom. When the variances really are equal it is slightly more powerful. With equal sample sizes the two tests give the same t, and only their degrees of freedom differ.

When the variances differ and the sample sizes differ too, the pooled test can mislead. If the smaller sample has the larger variance, pooling understates the standard error and the test raises too many false alarms; if the larger sample has the larger variance, it misses real differences. The challenging example shows a pooled p-value of 0.0066 beside Welch’s 0.071 for the same calls. Delacre, Lakens and Leys (2017) show that Welch’s test controls false alarms better when variances differ and loses little when they are equal, and recommend it by default; this course follows them.

It is tempting to choose by testing the variances first. Excel’s F.TEST(array1, array2) returns the two-tailed p-value of the F test for equal variances, which is based on the ratio of the two sample variances. Using it as a gate is a poor idea: the F test is very sensitive to departures from normality (OpenStax), and Delacre and colleagues argue that choosing between the pooled and Welch tests by a preliminary test of equal variances often gives the wrong answer. Use F.TEST, if at all, to describe how different the spreads look.

T.TEST in Excel

T.TEST(array1, array2, tails, type) returns the p-value of a two-sample or paired t test, and only the p-value. Tails is 1 or 2, and type chooses the test:

T.TEST’s three types (Microsoft’s names) and the matching ToolPak tools
TypeTest performedTest in this lessonToolPak tool
1PairedPaired t testt-Test: Paired Two Sample for Means
2Two-sample equal variance (homoscedastic)Pooled t testt-Test: Two-Sample Assuming Equal Variances
3Two-sample unequal variance (heteroscedastic)Welch’s t testt-Test: Two-Sample Assuming Unequal Variances

Microsoft’s page says T.TEST works from a non-negative t statistic: with tails = 2 it returns the probability of a larger |t| if the two means are equal, and with tails = 1 half of that, the tail in whichever direction the data point. So a one-tailed T.TEST never exceeds 0.5 and never tells you the direction. If your one-sided alternative says μ₁ > μ₂ and the sample means say the opposite, the p-value for your alternative is 1 minus T.TEST’s: check the means before you read a one-tailed result.

A paired T.TEST (type 1) returns #N/A if the two ranges hold different numbers of values, and it pairs the values by position, so both columns must be in the same order. For the t statistic and the degrees of freedom, calculate them from the formulas or run the ToolPak.

The Analysis ToolPak’s t-tests

Data > Data Analysis offers the three tests by the names in the table above; B03 explains loading the Analysis ToolPak. Each asks for a Variable 1 Range and a Variable 2 Range, a Hypothesized Mean Difference (usually 0), whether the ranges include Labels, Alpha and an output location. The output is values, not formulas, so rerun the tool when the data change. Here is the paired tool’s output for the workshop, with the after scores as Variable 1:

t-Test: Paired Two Sample for Means (latte-art scores, after as Variable 1, Alpha 0.05)
AfterBefore
Mean11.583310
Variance17.901512.5455
Observations1212
Pearson Correlation0.940266
Hypothesized Mean Difference0
df11
t Stat3.6443
P(T<=t) one-tail0.00192948
t Critical one-tail1.79588
P(T<=t) two-tail0.00385896
t Critical two-tail2.20099

Read it from the top. Pearson Correlation is the r that makes pairing pay. t Stat is dˉ÷(sd÷n)\bar{d} \div (s_d \div \sqrt{n}) for Variable 1 minus Variable 2, so its sign depends on which range you enter first. “P(T<=t) one-tail” is, whatever its label suggests, the one-tailed p-value in the direction of t, half the two-tail value. The two critical values, 1.796 and 2.201, are positive values at the Alpha you set: reject at 5% two-sided when |t Stat| exceeds t Critical two-tail, or equivalently when P(T<=t) two-tail is below 0.05.

The equal-variances tool adds a Pooled Variance row. The unequal-variances tool calculates Welch’s degrees of freedom, and Microsoft’s page explains: “Because the result of the calculation is usually not an integer, the value of df is rounded to the nearest integer to obtain a critical value from the t table.” The tool works its p-values from that rounded df too, while T.TEST with type 3 uses the unrounded df, so the two can disagree slightly: for the calls in the challenging example, 7.83 degrees of freedom become 8 and the two-tailed p-value moves from 0.0713 to 0.0706. Neither is wrong; say which you used.

Confidence intervals for a difference

Every test here has an interval to go with it. For independent samples it is (xˉ1−xˉ2)±t∗×SE(\bar{x}_1 - \bar{x}_2) \pm t^{*} \times \text{SE}, with t∗t^{*} from the t distribution with Welch’s degrees of freedom; for paired samples it is dˉ±t∗×sd÷n\bar{d} \pm t^{*} \times s_d \div \sqrt{n} with n − 1. In Excel the paired interval’s half-width is =CONFIDENCE.T(0.05,STDEV.S(D2:D13),COUNT(D2:D13)) on the column of differences, because a paired interval is a one-sample interval for the differences.

For two independent samples there is no single function: multiply =T.INV.2T(0.05,df) by the standard error. T.INV.2T truncates a fractional df to a whole number (16.69 becomes 16), which widens the interval very slightly; the simple example shows the size of the effect.

For the workshop the paired interval is 1.583 ± 2.201 × 0.4345, from 0.63 to 2.54 points: on average the trainees gained between about half a point and two and a half points. Treated wrongly as independent groups, the interval is −1.73 to 4.89 points and includes 0, matching the non-significant p of 0.33. A 95% interval for a difference excludes 0 exactly when the two-sided test at 5% rejects H₀.

Conditions

  • Independence. Values within each sample must be independent. For independent samples the two groups must be separate; for paired samples the pairs must be independent of one another, so that one trainee’s change doesn’t affect another’s. Random sampling lets you generalise to a population, and random assignment to the groups lets you talk about cause.
  • Normality, or large samples. The t tests assume each population is roughly normal (for a paired test, the population of differences). With larger samples the central limit theorem makes each mean’s sampling distribution close to normal even for skewed data, and how large is large enough depends on how skewed, as the sampling-distributions lesson showed with Lantern’s order values.
  • No dominating outliers. A t test compares means, and one extreme value can move a mean a long way. Look at the data first, in a box plot or a histogram, and if one value drives the result, report the test with and without it.

The applied example puts these conditions to work on Lantern’s spring orders, where web and app order values are compared and one web order of $1,512 dominates.

How big is the difference?

A p-value says whether a difference is likely to be chance, not how big it is, so report an effect size with it. The plainest is the difference in means with its interval, in the units of the problem: 1.58 points out of 20, 95% interval 0.63 to 2.54. To compare effects measured on different scales, analysts also use Cohen’s d, the difference in means divided by the pooled standard deviation, d=(xˉ1−xˉ2)÷spd = (\bar{x}_1 - \bar{x}_2) \div s_p.

Cohen suggested 0.2, 0.5 and 0.8 as small, medium and large, and OpenStax stresses that these labels are only indicative; what counts as large depends on the field and the decision. For the workshop, sp=(17.90+12.55)÷2=3.90s_p = \sqrt{(17.90 + 12.55) \div 2} = 3.90 and d=1.583÷3.90≈0.41d = 1.583 \div 3.90 \approx 0.41: the average gain is about two-fifths of the spread between trainees. Some analysts divide a paired mean difference by sds_d instead, which gives 1.05 here; the two measure different things, so say which you used.

Rank tests in outline

When samples are small and skewed, or an outlier dominates, a rank test is an alternative. The Mann–Whitney U test, also called the Wilcoxon rank-sum test, replaces the values of two independent samples by their ranks in the combined data and asks whether values in one group tend to be larger than in the other. The Wilcoxon signed-rank test does the same for paired differences, using the ranks of their sizes. Neither assumes normality, and an extreme value counts only as the largest rank.

They answer a slightly different question from a t test, whether one group tends to have larger values rather than whether the means differ. Excel has no function for either, and the ToolPak has no rank test (its Rank and Percentile tool only ranks values); statistical software runs them. For right-skewed values such as order totals, a log transformation (B02’s skewed-data lesson) is another option: a t test on the logs compares geometric means.

Formulas

Welch’s two-sample t statistic

t=(xˉ1−xˉ2)−Δ0s12/n1+s22/n2t = \dfrac{(\bar{x}_1 - \bar{x}_2) - \Delta_0}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}
xˉ1,xˉ2\bar{x}_1, \bar{x}_2
The two sample meansunits of x
s1,s2s_1, s_2
The two sample standard deviationsunits of x
n1,n2n_1, n_2
The two sample sizes
Δ0\Delta_0
The difference under the null hypothesis, usually 0units of x
tt
Test statistic

Assumes. Two independent random samples from populations that are roughly normal, or samples large enough for the central limit theorem; the variances need not be equal.

Excel: T.TEST(array1, array2, tails, 3) returns its p-value.

Welch–Satterthwaite degrees of freedom

df=(s12/n1+s22/n2)2(s12/n1)2n1−1+(s22/n2)2n2−1\text{df} = \dfrac{\left(s_1^2/n_1 + s_2^2/n_2\right)^2}{\dfrac{(s_1^2/n_1)^2}{n_1 - 1} + \dfrac{(s_2^2/n_2)^2}{n_2 - 1}}
s12,s22s_1^2, s_2^2
The two sample variances (VAR.S)units of x squared
n1,n2n_1, n_2
The two sample sizes
df\text{df}
Degrees of freedom, usually not a whole number

The ToolPak’s unequal-variances tool rounds this to the nearest whole number; T.TEST type 3 doesn’t.

Pooled variance and the pooled t statistic

sp2=(n1−1)s12+(n2−1)s22n1+n2−2,t=(xˉ1−xˉ2)−Δ0sp1/n1+1/n2s_p^2 = \dfrac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}, \qquad t = \dfrac{(\bar{x}_1 - \bar{x}_2) - \Delta_0}{s_p\sqrt{1/n_1 + 1/n_2}}
sp2s_p^2
Pooled variance (the ToolPak’s Pooled Variance row)units of x squared
s12,s22s_1^2, s_2^2
The two sample variancesunits of x squared
n1,n2n_1, n_2
The two sample sizes
xˉ1,xˉ2\bar{x}_1, \bar{x}_2
The two sample meansunits of x
Δ0\Delta_0
The difference under the null hypothesisunits of x
tt
Test statistic, with n₁ + n₂ − 2 degrees of freedom

Assumes. As for Welch’s test, plus equal population variances.

Excel: T.TEST type 2.

Confidence interval for a difference in means

(xˉ1−xˉ2)±t∗s12/n1+s22/n2(\bar{x}_1 - \bar{x}_2) \pm t^{*} \sqrt{s_1^2/n_1 + s_2^2/n_2}
xˉ1−xˉ2\bar{x}_1 - \bar{x}_2
Difference in sample meansunits of x
t∗t^{*}
The t value with α/2 in each tail and Welch’s degrees of freedom (2.11 for 95% and 16.7 df)
s1,s2s_1, s_2
Sample standard deviationsunits of x
n1,n2n_1, n_2
Sample sizes

It excludes 0 exactly when Welch’s two-sided test at the matching level rejects H₀.

Paired t test and interval

t=dˉ−Δ0sd/n,dˉ±t∗ sdnt = \dfrac{\bar{d} - \Delta_0}{s_d/\sqrt{n}}, \qquad \bar{d} \pm t^{*}\,\dfrac{s_d}{\sqrt{n}}
dˉ\bar{d}
Mean of the differences (after minus before)units of x
sds_d
Standard deviation of the differencesunits of x
nn
Number of pairs
Δ0\Delta_0
Mean difference under the null hypothesis, usually 0units of x
t,t∗t, t^{*}
Test statistic, and the t value for the interval, with n − 1 degrees of freedom

Assumes. Independent pairs; the differences roughly normal, or many pairs.

Excel: T.TEST(array1, array2, tails, 1); CONFIDENCE.T(α, STDEV.S(differences), COUNT(differences)) is the interval’s half-width.

Why pairing helps: the variance of a difference

sd2=s12+s22−2 r s1s2s_d^2 = s_1^2 + s_2^2 - 2\,r\,s_1 s_2
sd2s_d^2
Variance of the paired differencesunits of x squared
s1,s2s_1, s_2
Standard deviations of the two sets of measurementsunits of x
rr
Correlation between the paired measurements (the ToolPak’s Pearson Correlation)

A strong positive correlation makes the differences far less variable than either set of measurements.

Cohen’s d

d=xˉ1−xˉ2spd = \dfrac{\bar{x}_1 - \bar{x}_2}{s_p}
xˉ1−xˉ2\bar{x}_1 - \bar{x}_2
Difference in meansunits of x
sps_p
Pooled standard deviation, the square root of the pooled varianceunits of x
dd
Effect size in standard deviations

0.2, 0.5 and 0.8 are Cohen’s rough labels for small, medium and large effects.

F statistic for two variances (F.TEST)

F=s12s22F = \dfrac{s_1^2}{s_2^2}
s12,s22s_1^2, s_2^2
The two sample variancesunits of x squared
FF
Ratio, compared with the F distribution with n₁ − 1 and n₂ − 1 degrees of freedom

Assumes. Both populations normal: the test is very sensitive to departures from normality.

F.TEST returns the two-tailed p-value. Don’t use it to choose between the pooled and Welch tests.

Worked examples

A first example: Welch’s test: hire lengths at two bike stations

Fictional figures

Fairweather Bikes hires bikes from two stations. To plan servicing, it took a random sample of September hires from each and recorded their length in minutes. Harbour station (B2:B11): 58, 71, 49, 66, 80, 55, 62, 74, 52 and 63; Park station (C2:C13): 41, 52, 47, 38, 55, 60, 44, 49, 36, 51, 58 and 45. Do the stations’ mean hire lengths differ? Use Welch’s test at α = 0.05.

  1. Design and hypotheses: different hires at different stations, so independent samples. H0:μH−μP=0H_0: \mu_H - \mu_P = 0 against H1:μH−μP≠0H_1: \mu_H - \mu_P \ne 0, two-sided because servicing plans would change either way.
  2. Summaries: Harbour n₁ = 10, x̄₁ = 63.0, s₁ = 9.94 (variance 98.89); Park n₂ = 12, x̄₂ = 48.0, s₂ = 7.62 (variance 58.00). Neither sample has an outlier or strong skew.
  3. Standard error: 98.89÷10+58.00÷12=9.889+4.833=14.722=3.837\sqrt{98.89 \div 10 + 58.00 \div 12} = \sqrt{9.889 + 4.833} = \sqrt{14.722} = 3.837, so t=(63.0−48.0)÷3.837≈3.91t = (63.0 - 48.0) \div 3.837 \approx 3.91.
  4. Degrees of freedom: 14.7222÷(9.8892÷9+4.8332÷11)=216.74÷(10.866+2.124)≈16.6914.722^2 \div (9.889^2 \div 9 + 4.833^2 \div 11) = 216.74 \div (10.866 + 2.124) \approx 16.69.
  5. P-value: =T.TEST(B2:B11,C2:C13,2,3) = 0.0012. Interval: the t value for 16.69 df is 2.113, so 15.0 ± 2.113 × 3.837 runs from 6.9 to 23.1 minutes. =T.INV.2T(0.05,16.69) truncates to 16 df and returns 2.120, which would move each end by 0.03 minutes.

Answer. Reject H₀: Harbour hires are 15.0 minutes longer on average (t ≈ 3.91, df ≈ 16.7, p ≈ 0.0012; 95% interval 6.9 to 23.1 minutes).

What it means. Harbour bikes are out about a quarter of an hour longer per hire, so on hire time alone they need servicing sooner. With small samples the interval is wide: the gap could be anything from about 7 to 23 minutes. Cohen’s d is 15.0 ÷ 8.74 ≈ 1.7, large by any label. The pooled test agrees here (p = 0.0007), because the variances and the sample sizes are not very different.

A harder example: When pooling misleads: two call scripts

Fictional figures

Clearwater Contact Centre is trialling a new call script. Calls were assigned to scripts at random: 8 calls with Script A, the new one, and 20 with Script B, the current one. Handling times in minutes, A: 9.8, 6.1, 12.4, 8.0, 5.9, 11.7, 7.3, 10.2; B: 7.1, 6.4, 8.9, 5.8, 7.6, 6.9, 7.3, 8.2, 5.2, 6.6, 7.8, 7.0, 6.1, 8.5, 6.8, 7.4, 5.9, 7.7, 6.3, 7.5. A supervisor runs the pooled test and reports that Script A makes calls significantly longer. Is that right?

  1. Summaries: A has n₁ = 8, x̄₁ = 8.925, s₁ = 2.473 (variance 6.114); B has n₂ = 20, x̄₂ = 7.050, s₂ = 0.946 (variance 0.895). The difference is 1.875 minutes, and the smaller sample has the far larger spread: s₁ is 2.6 times s₂. Neither sample has an outlier, though 8 values are too few to judge A’s shape.
  2. Pooled test: sp2=(7×6.114+19×0.895)÷26=2.300s_p^2 = (7 \times 6.114 + 19 \times 0.895) \div 26 = 2.300; SE =2.300×(1/8+1/20)=0.634= \sqrt{2.300 \times (1/8 + 1/20)} = 0.634; t=1.875÷0.634≈2.96t = 1.875 \div 0.634 \approx 2.96 with 26 df; =T.TEST(B2:B9,C2:C21,2,2) = 0.0066.
  3. Welch’s test: SE =6.114÷8+0.895÷20=0.7642+0.0448=0.8994= \sqrt{6.114 \div 8 + 0.895 \div 20} = \sqrt{0.7642 + 0.0448} = 0.8994; t=1.875÷0.8994≈2.08t = 1.875 \div 0.8994 \approx 2.08; df =0.80902÷(0.76422÷7+0.04482÷19)≈7.83= 0.8090^2 \div (0.7642^2 \div 7 + 0.0448^2 \div 19) \approx 7.83; =T.TEST(B2:B9,C2:C21,2,3) = 0.071.
  4. Why they differ: pooling gives the 20 steady B calls most of the weight, so sps_p = 1.52 understates the noise in the 8 A calls. The pooled standard error is about 30% too small (0.634 against 0.899), and its degrees of freedom too generous (26 against 7.8).
  5. The ToolPak’s unequal-variances tool reports df = 8 (7.83 rounded) and P(T<=t) two-tail = 0.0706, slightly different from T.TEST’s 0.0713. =F.TEST(B2:B9,C2:C21) = 0.0008 confirms the spreads differ, but Welch’s test was the right choice before looking at it.

Answer. No. Welch’s test gives t ≈ 2.08 with about 7.8 degrees of freedom and p ≈ 0.071: no significant difference at 5%. The pooled p-value of 0.0066 comes from pooling a small noisy sample with a large steady one.

What it means. Script A may lengthen calls (the 95% interval for the difference runs from −0.21 to 3.96 minutes), but 8 calls that vary this much are too few to say. Clearwater should collect more Script A calls, and find out why their times vary so much: a script that some agents follow and others don’t can produce exactly this spread.

Applied: a business decision: Do app customers spend more per order?

Fictional figures

Ana wonders whether app customers spend more per order than website customers. B03’s 231 spring orders include 132 web orders and 99 app orders. Compare the channels’ mean order values with Welch’s test, check the conditions, and say what she can report.

Order values by channel, spring 2026
OrdersnMeanMedianSDLargest
Web132$41.21$19.50$131.12$1,512.00
App99$36.93$30.60$30.04$191.00
Web without LC-10144131$29.98$19.50$23.60$133.00
  1. Design: different orders through different channels, so independent samples; H1:μweb≠μappH_1: \mu_{\text{web}} \ne \mu_{\text{app}}, two-sided.
  2. Welch’s test on every order: the difference is $41.21 − $36.93 = $4.28, SE = $11.80, t ≈ 0.36 with about 149 df, p ≈ 0.72; 95% interval −$19.05 to $27.61.
  3. Conditions: both samples are large, but the web column holds LC-10144, the $1,512 office order, about 78 times the web median. That one order lifts the web mean by $11.23 and the web standard deviation from $23.60 to $131.12. A t test compares means, and this mean is largely one order.
  4. Without the office order: the web mean is $29.98 and the difference −$6.95 (app higher); Welch’s t ≈ −1.90 with about 181 df, p ≈ 0.059; 95% interval −$14.16 to $0.27. The medians, $19.50 for web and $30.60 for app, point the same way.
  5. On a log scale (B02), the geometric means are $25.23 for web and $29.02 for app, and Welch’s test on the logs gives p ≈ 0.12.

Answer. With every order there is no evidence of a difference (p ≈ 0.72), and one order decides which channel’s mean is higher. Without it, app orders average $6.95 more (95% interval −$14.16 to $0.27, p ≈ 0.059): suggestive, not significant at 5%.

What it means. Ana can report that typical app orders look larger (median $30.60 against $19.50) but that the spring data don’t establish a difference in mean order value, and that one office order decides the direction of the means. Even a clear difference wouldn’t show that the app makes people spend more: app orders are more often subscriptions (57 of 99, against 47 of 132 on the web), so the kind of order, a confounding variable, may drive any gap, and 231 orders from one spring are not a random sample of customers. The proportions-and-chi-square lesson tests the link between channel and subscription.

Explore

The ToolPak’s output for the workshop scores, with the after scores as Variable 1. Switch between the paired tool and the two independent-samples tools: the means, the variances and the 1.58-point difference are the same, but the paired P(T<=t) two-tail is 0.0039 and the others about 0.33. Set Hypothesized Mean Difference to 1 to ask whether the average gain beats one point.

Loading the interactive…

Clearwater’s calls in the unequal- and equal-variances tools. Compare the df rows (8 against 26) and the P(T<=t) two-tail rows (0.0706 against 0.0066), and find the Pooled Variance row that only the equal-variances tool prints.

Loading the interactive…

The workshop scores with each trainee’s difference in column D and T.TEST in all three types. Swap the after scores of trainees 1 and 3 by typing 16 in C2 and 10 in C4: the columns hold the same numbers, so the two independent-samples p-values don’t move, but the paired p-value rises from 0.004 to about 0.13 because the pairs no longer match. Reset, then turn on Show formulas.

Loading the interactive…

Common mistakes

  • “Before and after are two columns, so I used a two-sample test.”

    When each value in one column belongs with one in the other, the data are pairs. A two-sample test on the workshop scores gives p = 0.33, because the trainees differ from one another by far more than the workshop changed them; the paired test removes those differences and gives p = 0.004. Use T.TEST type 1 or the paired ToolPak tool.

  • “F.TEST found no significant difference in variances, so I pooled.”

    Not finding a difference in variances doesn’t show they are equal, least of all in small samples, and the F test is very sensitive to non-normal data. Welch’s test costs little when the variances are equal and protects you when they aren’t: make it the default.

  • “=T.TEST(B2:B9,C2:C21,1,3) is 0.036, so Script A shortens calls.”

    A one-tailed T.TEST returns the tail in whichever direction the data point. Script A’s calls are longer on average, so 0.036 is the p-value for “A is longer”; for “A is shorter” it is 1 − 0.036 = 0.964. Compare the means before reading a one-tailed T.TEST.

  • “The ToolPak and T.TEST disagree, so one of them is wrong.”

    The unequal-variances tool rounds Welch’s degrees of freedom to a whole number (7.83 becomes 8) and works its p-value from that; T.TEST type 3 keeps 7.83. Small differences are expected. Check too that both use the same ranges, in the same order, and the same number of tails.

  • “The paired test proves the workshop works.”

    It shows the scores rose by more than chance would produce. Without a comparison group, practice and regression to the mean could explain some of the rise. A causal claim needs a control group, ideally with trainees assigned to it at random.

  • “Order values aren’t normal, so a t test is useless.”

    With 99 and 132 orders, the means’ sampling distributions are close to normal unless one value dominates. Here one does, so report the test with and without it and look at the medians, the logs or a rank test. Skew in large samples is a reason to check, not automatically a reason to abandon the t test.

Guided practice

Work through these with hints when you need them. Every hint and every worked solution is there to be used.

Loading four questions…

On your own

No hints this time. Answer, check, and read the feedback; the solution appears once you have answered or if you ask for it. Your first answers count toward mastery.

Loading six questions…

In practice

Fictional case

Ana’s note for the staff training plan: “Twelve trainees were scored out of 20 before and after the two-hour latte-art workshop. Their scores rose by 1.58 points on average (95% interval 0.63 to 2.54; paired t test, p = 0.004), and 10 of the 12 improved. We didn’t score a comparison group, so some of the rise may be practice rather than the workshop. Next time I will also score six trainees twice without the workshop.”

Her note follows the habits of a good comparison. She chose the test from the design, reported the size of the change with its interval as well as the p-value, gave the count of trainees who improved, and named what the design can’t show. Analysts comparing two groups work in the same order: decide paired or independent from how the data were collected; look at the data; use Welch’s test for independent samples unless there is a reason to pool; check outliers and report with and without them; and give the difference, its interval and an effect size.

A comparison is only as fair as its groups. A two-sample test on observational data, such as customers who chose the app against those who chose the website, compares people who differ in many ways besides the label, and any gap may come from a confounding variable. Pairing and random assignment are the two main ways to make a comparison fair; when neither is possible, the report should say so plainly.

Knowledge check

Six questions, one attempt each, no hints. Score 80% or more to complete the lesson; you can take it again at any time.

Loading six questions…

Summary

  • The design chooses the test: paired when each value in one sample belongs with one in the other (the same unit measured twice, or matched pairs), independent when the groups are separate.
  • A paired t test is a one-sample t test on the differences, t = d̄ ÷ (s_d ÷ √n) with n − 1 df. Pairing removes the variation between units, so it can find effects an independent test misses (p = 0.004 against 0.33 for the workshop).
  • For independent samples, Welch’s t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂), with Welch–Satterthwaite df, is the safer default; the pooled test assumes equal variances and misleads when variances and sample sizes both differ. Don’t choose between them with F.TEST.
  • =T.TEST(array1,array2,tails,type) returns only the p-value: type 1 paired, 2 pooled, 3 Welch. A one-tailed T.TEST is the tail in the direction of the data.
  • The ToolPak’s t-test tools print the means, variances, t Stat, one- and two-tail p-values and critical values; the unequal-variances tool rounds df to a whole number, so its p-value can differ slightly from T.TEST type 3.
  • Report the difference with its interval, (x̄₁ − x̄₂) ± t* × SE or d̄ ± t* × s_d ÷ √n, and an effect size such as Cohen’s d. An interval that excludes 0 matches a significant two-sided test.
  • Check independence, rough normality or large samples, and outliers. One dominating value can decide a comparison of means: report with and without it, and consider medians, logs or a rank test (Mann–Whitney, Wilcoxon signed-rank).

Key formulas

Terms introduced

Independent samples
Two samples whose values are unrelated, such as separate groups of customers or calls, so that nothing links a value in one sample to a particular value in the other.
Paired samples
Two sets of measurements in which each value in one belongs with one value in the other, such as the same people measured before and after, or units matched in pairs.
Two-sample t test
A test of whether two population means differ, from independent samples, using the difference in sample means divided by its standard error.
Welch’s t test
The two-sample t test that doesn’t assume equal population variances: its standard error is √(s₁²/n₁ + s₂²/n₂) and its degrees of freedom come from the Welch–Satterthwaite formula. Excel’s T.TEST type 3.
Pooled t test
The two-sample t test that assumes equal population variances and combines the two sample variances into one pooled variance, with n₁ + n₂ − 2 degrees of freedom. Also called Student’s two-sample t test; Excel’s T.TEST type 2.
Paired t test
A test of whether the mean of paired differences is zero (or a stated value): a one-sample t test on the differences, with n − 1 degrees of freedom. Excel’s T.TEST type 1.
F test for equal variances
A test of whether two population variances are equal, based on the ratio of the two sample variances; Excel’s F.TEST returns its two-tailed p-value. It is very sensitive to non-normal data.
Effect size
A measure of how large an effect is, as opposed to whether it is statistically significant: a difference in means in the problem’s units, or a standardised measure such as Cohen’s d.
Cohen’s d
The difference between two means divided by the pooled standard deviation, so that it is measured in standard deviations; 0.2, 0.5 and 0.8 are often called small, medium and large.
Mann–Whitney U test
A rank-based test for two independent samples, also called the Wilcoxon rank-sum test, that asks whether values in one group tend to be larger than in the other without assuming normality.
Wilcoxon signed-rank test
A rank-based test for paired data that asks whether the differences tend to be positive or negative, using the ranks of their sizes, without assuming normality.

Sources

  1. Holmes, A., Illowsky, B. & Dean, S. (2023). Introductory Business Statistics 2e, chapter 10, “Hypothesis Testing with Two Samples” (sections 10.1, “Comparing Two Independent Population Means”, and 10.2, “Cohen’s Standards for Small, Medium, and Large Effect Sizes”). OpenStax. openstax.org/books/introductory-business-statistics-2e/pages…
  2. Microsoft Support. “T.TEST function”. support.microsoft.com/en-US/excel/functions/t-test-function
  3. Microsoft Support. “Use the Analysis ToolPak to perform complex data analysis” (the t-Test and F-Test Two-Sample for Variances tools). support.microsoft.com/en-us/excel/use-the-analysis-toolpak-t…
  4. Microsoft Support. “F.TEST function”. support.microsoft.com/en-US/excel/functions/f-test-function
  5. Microsoft Support. “T.INV.2T function”. support.microsoft.com/en-US/excel/functions/t-inv-2t-functio…
  6. NIST/SEMATECH. e-Handbook of Statistical Methods, section 1.3.5.3, “Two-Sample t-Test for Equal Means”. itl.nist.gov/div898/handbook/eda/section3/eda353.htm
  7. Delacre, M., Lakens, D. & Leys, C. (2017). “Why psychologists should by default use Welch’s t-test instead of Student’s t-test”. International Review of Social Psychology, 30(1), 92–101. doi.org/10.5334/irsp.82
  8. Illowsky, B. & Dean, S. Introductory Statistics 2e, section 13.4, “Test of Two Variances”. OpenStax. openstax.org/books/introductory-statistics-2e/pages/13-4-tes…