2-Sample t Test (independent samples t-test)

Compare the means of two independent groups such as supplier A and B or an old and a new line. A group table, a test summary and 5 charts show the size of the difference together with the shape of the distributions.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

22-Sample t Test Options

Data input
Variance assumption

How to run a 2-sample t test

  1. Copy a group name column together with a measurement column, or two columns already split by group.
  2. Choose the data input mode and set the response and group column (exactly 2 levels) or the group 1 and group 2 columns. Keep Welch as the variance assumption unless you have a reason not to.
  3. Press Analyze and check the p-value and the confidence interval of the mean difference in the test summary.

Worked example with sample data

The sample data are tensile strengths of the same grade of material from two suppliers (A and B), 15 measurements each (380.7 to 422.6 MPa). The supplier column is the group column and the tensile strength column is the response column.

Box plot by group from the 2-sample t test of tensile strength for suppliers A and B
Box plot by group from the 2-sample t test of tensile strength for suppliers A and B

The means are 409.6 MPa for supplier A and 399.9 MPa for supplier B, a difference of 9.773 MPa. Welch's t test gives t = 2.766 with 25.7 degrees of freedom and a p-value of 0.01036, below 0.05, so the mean strengths of the two suppliers differ.

The 95% confidence interval of the mean difference, 2.507 to 17.04 MPa, does not contain 0 but is wide. The true difference could be around 2.5 MPa or around 17 MPa, so collect more data if the size of the difference matters.

The standard deviations differ (11.04 for B, 8.086 for A), so Welch's test, which does not assume equal variances, is the right choice (the pooled test on the same data gives p=0.009927). In the box plot, supplier B's box spreads further down, and supplier A has one IQR outlier (391.9 MPa).

Welch vs pooled

Welch's t test allows the two groups to have different variances; its degrees of freedom come from the Welch-Satterthwaite formula and are usually fractional. The pooled (equal variance) test assumes equal variances and uses the pooled variance with n1+n2-2 degrees of freedom. When the two standard deviations differ a lot, Welch is safer.

Group order and reference difference

With a group column, the group names are sorted and the first becomes group 1. The mean difference is group 1 - group 2; entering a non-zero reference difference tests whether the mean difference differs from that value.

Result panels

You get a group table (N, mean, standard deviation), the test summary, a box plot by group, a violin plot, an individual value plot (points spread sideways, ◆ marks the mean), the mean + confidence interval of each group and an overlaid histogram.

How to read the 2-sample t test result

  • A p-value below 0.05 means the two group means differ, and the interpretation tells you which group is higher and by how much.
  • If the confidence interval of the mean difference does not contain 0, the difference is significant. Its two ends show roughly the smallest and largest plausible difference.
  • Even when the difference in means is significant, heavily overlapping distributions in the box and violin plots mean individual parts are hard to tell apart.

Frequently asked questions

Is it the same as Excel's T.TEST?

Excel's T.TEST(range1, range2, 2, 3) is the two-sided Welch p-value, so it matches when Welch is selected; type 2 matches the pooled (equal variance) test.

What about before/after data on the same items?

If the same items were measured twice, use the paired t test. The 2-sample t test is for two groups made of different items.

What if there are 3 or more groups?

Compare 3 or more groups with one-way analysis of variance (ANOVA), and find which groups differ with post hoc tests.

Other chart tools