In the Evidence worksheet, we did the following t-test:

t.test(cpsdata$income ~ cpsdata$sex)

Welch Two Sample t-test

data:  cpsdata$income by cpsdata$sex
t = -3.6654, df = 9991.3, p-value = 0.0002482
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-14518.10  -4400.64
sample estimates:
mean in group female   mean in group male
82677.29             92136.66 

Here’s a more detailed explanation of the output of that test – we’ll go through each bit:

What you did

Welch - There’s more than one way to do a t-test. R uses the method recommended by Welch. The Welch method is always a better choice than doing the standard (a.k.a. “Student”) t-test.

Two Sample t-test - It’s two sample because you have two different groups (“samples”) of people being compared in the test – females and males.

data: cpsdata$income by cpsdata$sex - This just reminds you what data you’re analyzing, it’s basically a copy of what you told it to do, i.e. cpsdata$income ~ cpsdata$sex

alternative hypothesis: true difference in means is not equal to 0 - This is a way of saying that, before looking at the data, you made no assumptions about whether men would earn more than women, or vice versa. This is sometimes called a two-tailed test - see below if you can safely assume a direction before looking at your data (also called a one-tailed test).

What you found

t = -3.6654 - This is the t value – the output of a t-test. It’s a bit like an effect size, except it’s harder to interpret, because its value is also affected by the sample size (larger samples mean larger t values, other things being equal). A t value isn’t at all useful on its own but along with the degrees of freedom (see below), we can use it to calculate the p value (also see below). The t-value is negative for the reason explained in the one-tailed tests section, below. Generally speaking, psychologists ignore the minus sign when reporting t values in their papers, although people differ on this.

df = 9991.3 - df is short for degrees of freedom. In a “Student” t-test, the degrees of freedom is the sample size, minus the number of means you’ve calculated from that sample. In a Welch t-test, this number is corrected to deal with some of the problems with the Student’s t-test. This correction makes the Welch t-test more accurate than the Student’s t-test.

p-value = 0.0002482 - The is the p value of the t-test. It’s the probability of your data, under the assumption there is no difference between groups (sometimes called the null hypothesis). You need the t value and the degrees of freedom to be able to calculate the p value … but R does those calculations for you.

Group means

Although you can get these in other ways, for convenience the t.test command gives you the mean for each group:

sample estimates:
mean in group female   mean in group male
82677.29             92136.66