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¶
Use the common-variance model when its assumptions are justified. Pool the two variance estimates and use the corresponding residual degrees of freedom.
Allow separate population variances. Use the Welch standard error and approximate 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,
| Symbol | Meaning |
|---|---|
| Response of unit in treatment group . | |
| Number of independent units in group . | |
| Population mean response under treatment . | |
| Population response variance under treatment . | |
| Mean difference of interest. | |
| Estimated 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 be the hypothesized difference, usually 0.
| Scientific question | Null hypothesis | Alternative hypothesis |
|---|---|---|
| Is there a difference? | ||
| Is group 1 larger? | ||
| Is group 1 smaller? |
Choose the direction before looking at outcomes. One-sided tests are calibrated at the null boundary .
Test Statistic¶
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 , we need a known reference distribution, exact or approximate, that lets us evaluate the statistic without unknown nuisance parameters.
What a -Value Means¶
The -value is the probability, under the null model, of a test statistic at least as extreme as observed, in the direction(s) specified by .
Small : the observed result is unusual under .
It is not and is not the probability that the result is “due to chance.”
At a preselected significance level , reject when .
Failure to reject means insufficient evidence against ; it does not establish equality.
Type I Error, Type II Error & Power¶
| Decision | true | false |
|---|---|---|
| Reject | Type I error | Correct detection |
| Do not reject | Correct non-rejection | Type II error |
For composite nulls, 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 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¶
This identity explains both versions of the two-sample test.
Student’s Pooled Two-Sample Test¶
Use a pooled estimate when a common population variance, , is justified.
This is a degrees-of-freedom weighted average of the two sample variances, not generally their simple average.
Under independent normal observations with a common variance,
Welch’s Two-Sample Test¶
Welch’s method estimates each variance separately:
can be non-integer; use it directly in software.
It is not generally equal to .
Welch does not require equal variances. It still requires an appropriate independent-group design and a reasonable sampling approximation.
Which Test Fits?¶
| Situation | Analysis |
|---|---|
| Independent groups; common variance supported by the model/design | Pooled two-sample . |
| Independent groups; unequal or uncertain variances | Welch two-sample . |
| Same units measured twice or matched pairs | Analyze within-pair differences; do not use an independent-group standard error. |
| Blocks or clusters | Include that structure in the model. |
| Binary individual outcomes | Use 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.
-Test Tails & Confidence Intervals¶
Let be the observed statistic and the CDF of the chosen reference distribution.
| Alternative | -value |
|---|---|
A one-sided -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 -value near 1.
A two-sided confidence interval for is
Use the matching standard error and degrees of freedom: pooled or Welch. Here is the quantile of .
An interval excluding 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 Test¶
This test asks whether population variances are equal. It does not test equality of means.
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 -Value¶
Let be the CDF. The usual equal-tail two-sided calculation is
Equivalently, reject if or .
For a preselected alternative , use the upper-tail probability with fixed group labels. For , 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.
| Item | Approximate reported summary |
|---|---|
| Group 1 | Lower ad frequency; mean duration approximately 4.9. |
| Group 2 | Higher ad frequency; mean duration approximately 3.0. |
| Sample sizes | 500 observations per condition. |
| Variance ratio | Approximately 0.9376. |
| Two-sided variance-test | Approximately 0.472. |
| Pooled mean-test statistic | Approximately 30. |
| Two-sided mean-test result | Extremely small -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 , 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 .
A large positive statistic is in the wrong direction for that alternative, so its one-sided -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.