Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Two-Group Comparisons

Compare two independent treatment groups by connecting hypotheses, effect estimates, standard errors, and uncertainty. Start with Experimental Design to check what counts as an independent experimental unit.

At a Glance

Pooled test
Welch test

Use the common-variance model when its assumptions are justified. Pool the two variance estimates and use the corresponding residual degrees of freedom.

Simple Comparative Experiments

A simple comparative experiment has one design factor with two levels: treatment vs. control, list vs. tile layout, or low vs. high ad frequency.

For the independent-group quantitative-response model,

Yij∼indN(μi,σi2),i=1,2,j=1,…,ni.Y_{ij}\overset{\mathrm{ind}}{\sim}N(\mu_i,\sigma_i^2),\qquad i=1,2,\quad j=1,\ldots,n_i.
SymbolMeaning
YijY_{ij}Response of unit jj in treatment group ii.
nin_iNumber of independent units in group ii.
μi\mu_iPopulation mean response under treatment ii.
σi2\sigma_i^2Population response variance under treatment ii.
Δ=μ1−μ2\Delta=\mu_1-\mu_2Mean difference of interest.
Δ^=Yˉ1−Yˉ2\widehat\Delta=\bar Y_1-\bar Y_2Estimated mean difference.

The basic model assumes independent observations within and between groups. It does not account for pairing, blocks, or clusters. Those designs require an analysis that preserves their dependence structure.

Hypotheses & Evidence

Let Δ0\Delta_0 be the hypothesized difference, usually 0.

Scientific questionNull hypothesisAlternative hypothesis
Is there a difference?H0:Δ=Δ0H_0:\Delta=\Delta_0HA:Δ≠Δ0H_A:\Delta\ne\Delta_0
Is group 1 larger?H0:Δ≤Δ0H_0:\Delta\leq\Delta_0HA:Δ>Δ0H_A:\Delta>\Delta_0
Is group 1 smaller?H0:Δ≥Δ0H_0:\Delta\geq\Delta_0HA:Δ<Δ0H_A:\Delta<\Delta_0

Choose the direction before looking at outcomes. One-sided tests are calibrated at the null boundary Δ=Δ0\Delta=\Delta_0.

Test Statistic

T=estimated effect−null effectestimated standard error.T=\frac{\text{estimated effect}-\text{null effect}}{\text{estimated standard error}}.

The numerator measures the observed departure from the null. The denominator measures ordinary sampling variability. A difference of 2 units can be weak or strong evidence depending on its standard error.

Under H0H_0, we need a known reference distribution, exact or approximate, that lets us evaluate the statistic without unknown nuisance parameters.

What a pp-Value Means

The pp-value is the probability, under the null model, of a test statistic at least as extreme as observed, in the direction(s) specified by HAH_A.

  • Small pp: the observed result is unusual under H0H_0.

  • It is not P(H0∣data)P(H_0\mid\text{data}) and is not the probability that the result is “due to chance.”

  • At a preselected significance level α\alpha, reject when p≤αp\leq\alpha.

  • Failure to reject means insufficient evidence against H0H_0; it does not establish equality.

Type I Error, Type II Error & Power

DecisionH0H_0 trueH0H_0 false
Reject H0H_0Type I errorCorrect detection
Do not reject H0H_0Correct non-rejectionType II error
α=P(reject H0∣H0 true),β(Δ)=P(do not reject H0∣Δ is the specified alternative).\alpha=P(\text{reject }H_0\mid H_0\text{ true}),\qquad \beta(\Delta)=P(\text{do not reject }H_0\mid\Delta\text{ is the specified alternative}).
Power⁡(Δ)=1−β(Δ).\operatorname{Power}(\Delta)=1-\beta(\Delta).

For composite nulls, α\alpha is the controlled upper bound on rejection probability. Power depends on the true effect, variance, sample size, and test. Increasing sample size generally increases power; lowering α\alpha at fixed sample size generally reduces it.

Statistical significance asks about evidence. Practical significance asks whether the effect is large enough to matter. Report the estimated difference and its uncertainty alongside the test.

Comparing Two Independent Means

Sample Summaries

Yˉi=1ni∑j=1niYij,si2=1ni−1∑j=1ni(Yij−Yˉi)2.\bar Y_i=\frac{1}{n_i}\sum_{j=1}^{n_i}Y_{ij},\qquad s_i^2=\frac{1}{n_i-1}\sum_{j=1}^{n_i}(Y_{ij}-\bar Y_i)^2.

Estimating the group mean leaves ni−1n_i-1 degrees of freedom for its variance.

Independence gives

Var⁡(Yˉ1−Yˉ2)=σ12n1+σ22n2.\operatorname{Var}(\bar Y_1-\bar Y_2)=\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}.

This identity explains both versions of the two-sample tt test.

Student’s Pooled Two-Sample tt Test

Use a pooled estimate when a common population variance, σ12=σ22=σ2\sigma_1^2=\sigma_2^2=\sigma^2, is justified.

sp2=(n1−1)s12+(n2−1)s22n1+n2−2.s_p^2=\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}.

This is a degrees-of-freedom weighted average of the two sample variances, not generally their simple average.

SE⁡p=sp1n1+1n2,Tp=(Yˉ1−Yˉ2)−Δ0SE⁡p.\operatorname{SE}_{p}=s_p\sqrt{\frac1{n_1}+\frac1{n_2}},\qquad T_p=\frac{(\bar Y_1-\bar Y_2)-\Delta_0}{\operatorname{SE}_{p}}.

Under independent normal observations with a common variance,

Tp∣H0∼tn1+n2−2.T_p\mid H_0\sim t_{n_1+n_2-2}.

Welch’s Two-Sample tt Test

Welch’s method estimates each variance separately:

SE⁡W=s12n1+s22n2,TW=(Yˉ1−Yˉ2)−Δ0SE⁡W.\operatorname{SE}_{W}=\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}},\qquad T_W=\frac{(\bar Y_1-\bar Y_2)-\Delta_0}{\operatorname{SE}_{W}}.

Its reference distribution is approximately tνt_\nu, with Welch-Satterthwaite degrees of freedom

ν=(s12/n1+s22/n2)2(s12/n1)2n1−1+(s22/n2)2n2−1.\nu= \frac{\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}}.
  • ν\nu can be non-integer; use it directly in software.

  • It is not generally equal to min⁡(n1,n2)−1\min(n_1,n_2)-1.

  • Welch does not require equal variances. It still requires an appropriate independent-group design and a reasonable sampling approximation.

Which Test Fits?

SituationAnalysis
Independent groups; common variance supported by the model/designPooled two-sample tt.
Independent groups; unequal or uncertain variancesWelch two-sample tt.
Same units measured twice or matched pairsAnalyze within-pair differences; do not use an independent-group standard error.
Blocks or clustersInclude that structure in the model.
Binary individual outcomesUse a binary-response/proportions analysis.

Check independence from the design, and examine outliers, skewness, and group spreads from the data. Normality makes the pooled test exact; large-sample approximations can help with non-normal data, but do not fix dependence or severe data problems.

tt-Test Tails & Confidence Intervals

Let tobst_{\mathrm{obs}} be the observed statistic and GνG_\nu the CDF of the chosen tt reference distribution.

Alternativepp-value
Δ≠Δ0\Delta\ne\Delta_02[1−Gν(∣tobs∣)]2[1-G_\nu(\lvert t_{\mathrm{obs}}\rvert)]
Δ>Δ0\Delta>\Delta_01−Gν(tobs)1-G_\nu(t_{\mathrm{obs}})
Δ<Δ0\Delta<\Delta_0Gν(tobs)G_\nu(t_{\mathrm{obs}})

A one-sided pp-value is half the two-sided value only when the observed effect points in the chosen alternative’s direction. An effect strongly in the opposite direction gives a one-sided pp-value near 1.

A two-sided 100(1−α)%100(1-\alpha)\% confidence interval for Δ\Delta is

Δ^ ± t1−α/2,νSE⁡(Δ^).\widehat\Delta\ \pm\ t_{1-\alpha/2,\nu}\operatorname{SE}(\widehat\Delta).

Use the matching standard error and degrees of freedom: pooled or Welch. Here tq,νt_{q,\nu} is the qq quantile of tνt_\nu.

  • An interval excluding Δ0\Delta_0 corresponds to rejection by the matching two-sided test.

  • A 95% procedure covers the fixed true difference in 95% of repeated samples under its assumptions.

  • Including 0 does not establish that effects are negligible; inspect the entire interval.

This cell uses the same illustrative summaries. sf evaluates the upper tail directly; std expects standard deviations, not variances.

Comparing Two Variances: The FF Test

This test asks whether population variances are equal. It does not test equality of means.

H0:σ12=σ22,HA:σ12≠σ22.H_0:\sigma_1^2=\sigma_2^2,\qquad H_A:\sigma_1^2\ne\sigma_2^2.

For independent normal samples, keeping the group labels fixed,

F=s12s22,F∣H0∼Fn1−1,n2−1.F=\frac{s_1^2}{s_2^2},\qquad F\mid H_0\sim F_{n_1-1,n_2-1}.

The first degrees of freedom belong to the numerator; the second belong to the denominator. If the ratio is inverted, swap the degrees of freedom too.

Two-Sided pp-Value

Let Hd1,d2H_{d_1,d_2} be the FF CDF. The usual equal-tail two-sided calculation is

p=min⁡{1, 2min⁡[Hd1,d2(fobs), 1−Hd1,d2(fobs)]}.p=\min\left\{1,\ 2\min\left[H_{d_1,d_2}(f_{\mathrm{obs}}),\ 1-H_{d_1,d_2}(f_{\mathrm{obs}})\right]\right\}.

Equivalently, reject if fobs<Fα/2,d1,d2f_{\mathrm{obs}}<F_{\alpha/2,d_1,d_2} or fobs>F1−α/2,d1,d2f_{\mathrm{obs}}>F_{1-\alpha/2,d_1,d_2}.

For a preselected alternative σ12>σ22\sigma_1^2>\sigma_2^2, use the upper-tail probability with fixed group labels. For σ12<σ22\sigma_1^2<\sigma_2^2, use the lower tail.

The classical variance-ratio test is sensitive to non-normality. A nonsignificant result should not automatically select a pooled mean test. Welch avoids requiring a common variance when equality is uncertain.

Example: Ad Frequency & Visit Duration

An ad-frequency experiment compares one ad every eight posts with one ad every five posts, using visit duration as the response.

ItemApproximate reported summary
Group 1Lower ad frequency; mean duration approximately 4.9.
Group 2Higher ad frequency; mean duration approximately 3.0.
Sample sizes500 observations per condition.
Variance ratioApproximately 0.9376.
Two-sided variance-test ppApproximately 0.472.
Pooled mean-test statisticApproximately 30.
Two-sided mean-test resultExtremely small pp-value, reported below 10-16.

These are rounded reported results, not a recomputation from raw data. The available summaries do not specify the time unit or whether repeated visits from a user were treated as independent; the model depends on the assignment and measurement design.

With Δ=μlower ads−μhigher ads\Delta=\mu_{\text{lower ads}}-\mu_{\text{higher ads}}, the observed difference is positive. Therefore:

  • The two-sided comparison provides strong evidence of a mean difference under the stated model.

  • “Higher ad frequency increases duration” corresponds to HA:Δ<0H_A:\Delta<0.

  • A large positive statistic is in the wrong direction for that alternative, so its one-sided pp-value is near 1.

The reported data point toward shorter visits with more frequent ads. Causal interpretation additionally requires valid randomized assignment and an analysis that respects the experimental units.