# t-Tests in SPSS

SPSS allows you to conduct one-sample, independent samples, and paired samples \(t\)-tests. This page demonstrates how to perform each using SPSS. The data used in this tutorial can be downloaded from this GitHub repository. The one-sample and independent samples examples will use the `iq_long.sav`

data, and the paired samples example will use `iq_wide.sav`

.

## One Sample \(t\)-Test

Say we have data from 200 subjects who have taken an IQ test. We know in the general population the mean IQ is 100. We want to test the hypothesis that our sample comes from a different population, e.g. one that is more gifted than the general population. We will test the null hypothesis that our sample comes from a population where \(\mu \ne 100\). In SPSS, we click on **Analyze** \(\rightarrow\) **Compare Means** \(\rightarrow\) **One-Sample T Test**.

A window will pop-up with all of the possible variables in a box on the left. For this example, it has `id`

, `gender`

, and `iq`

. We will select `iq`

, since that is what we want to test, and click the arrow button to move it into the test variables box. Finally we enter the test value, which is what we are comparing the mean against (in this case 100), and click OK.

SPSS will open a new window with the output, and we can look at the results there.

The output gives us two tables. The first table contains the sample statistics.

`N`

is the sample size, which is 200`Mean`

is the sample mean, which is 105.0351`Std. Deviation`

in the sample standard deviation (s) which is 15.78354`Std. Error Mean`

is \(s/\sqrt{n}\), which is 1.11606

The second table contains the test results.

- The \(t\) column gives the \(t\)-statistic, which is 4.511
- \(df\) gives the degree of freedom, which is 199
`Sig. (2-tailed)`

gives the \(p\)-value, which is <0.001`Mean Difference`

for a one-sample test is the sample mean, which is 105.0351- The 95% Confidence Interval of the Difference is [102.8343, 107.2359]

Since the \(p\)-value that we found is less than 0.05, and the 95% confidence interval does not include 100, we reject the null hypothesis.

## Independent Samples \(t\)-Test

Say we wanted to test whether there is a significant difference in the IQs of males and females in our sample of 200 subjects. To perform this \(t\)-test, we will go to **Analyze** \(\rightarrow\) **Compare Means** \(\rightarrow\) **Independent-Samples T Test**.

A window will pop-up with all of the possible variables in a box on the left. We will select `iq`

, since that is what we want to test, and click the arrow button to move it into the test variables box. Then, we must select a grouping variable. Since we are comparing the means of male vs. female IQs, we will select gender as our grouping variable, and define the groups based on our variable names for male and female (1 and 2). Finally we click OK.

SPSS will open a new window with the output, and we can look at the results there.

The output gives us two tables. The first is summary statistics for each sample. For males, we had a sample of \(n = 95\) with a mean IQ of 103.56, a standard deviation of 13.88 and a standard error mean of 1.42. For females, we had a sample size of \(n = 104\) with a mean IQ of 106.4, a standard deviation of 17.31, and a standard error mean of 1.7.

The second table is the result of the \(t\)-test. Note that an assumption for the independent samples \(t\)-test is that the two groups have equal variance, but that assumption is often violated. The Levene’s test for equality of variances allows us to check the assumption. The null hypothesis is that the assumption is met, so a significant result (\(p<0.05\)) means that the assumption is violated. When this is the case, there is a version of the \(t\)-test that adjusts for the unequal variance, which is also displayed.

- The \(t\) column gives the \(t\)-statistic which is -1.275 (-1.286 unequal variances)
- \(df\) gives the degrees of freedom which is 198 (194.268 unequal variances)
`Sig. (2-tailed)`

gives the \(p\)-value which is 0.204 (0.200 unequal variances)`Mean Difference`

gives the difference between the two sample means, which is -2.84`The Std. Error Difference`

is 2.23042 (2.21101 unequal variances)- The 95% Confidence Interval of the Difference is [-7.24196, 1.55488], or [-7.20421, 1.51713] with unequal variances.

We will assume equal variances. If we use unequal variances, the results are treated the same, but a slightly different formula is used to calculate the values.

When evaluated against a \(t\)-distribution with 198 degrees of freedom, we get a \(p\)-value of 0.204. This is greater than 0.05, so we fail to reject the null-hypothesis of no difference. We also see that the 95% confidence interval around the mean difference is [-7.204, 1.517]. Because this includes zero (equivalent to $p 0.05 $), we do not reject the null.

## Paired Samples \(t\)-Test

Finally, say we have IQ data collected on 100 individuals at two points in time. We want to know if an intervention that occurs in between the measures - say forming a test study group - increases IQ scores. The null hypothesis is that the mean change (\(IQ_{t2}-IQ_{t1}\)) is zero. To conduct a dependent (or paired) samples \(t\)-test in r, the data must be in wide format. That is, the \(t_1\) measures are in one column, the \(t_2\) measures are in another, and each row represents one subject. To perform the test, go to **Analyze** \(\rightarrow\) **Compare Means** \(\rightarrow\) **Paired-Samples T Test**.

A window will pop-up with all of the possible variables in a box on the left. We will select `IQ at Time 1`

and `IQ at Time 2`

, and click the arrow button to move them into the paired variables box under Variable 1 and Variable 2. Then we click OK.

SPSS will open a new window with the output, and we can look at the results there.

There are three output tables. The first is summary statistics for each variable. IQ at time 1 consists of a sample with size equal to 100, mean of 103.2734, standard deviation of 17.10415, and a standard error mean of 1.71041 (\(s/ \sqrt{n}\)). IQ at time 2 consists of a sample with size equal to 100, mean of 106.7968, standard deviation of 14.21037, and standard error mean of 1.42104. The second table gives the correlation between the two samples, and the degree of significance. The paired sample size is give as \(n\) = 100, the correlation is -0.036, and the significance is 0.725.

The third table gives the results of the \(t\)-test.

`Mean`

is the mean of the difference between the samples, which is 3.52340`Std. Deviation`

is the standard deviation of the difference, which is 22.62317`Std. Error Mean`

is \(s/ \sqrt{n}\), which is 2.62317- The 95% Confidence Interval of the Difference is [-0 .96553,8.01233]
- The \(t\) column gives the \(t\)-statistic, which is 1.557
- \(df\) gives the degrees of freedom, which is 99
`Sig. (2-tailed)`

gives the \(p\)-value, which is 0.123

We see that the difference in means is 3.52, which results in a \(t\)-statistic equal to 1.56. Evaluating this against a \(t\)-distribution with 99 degrees of freedom, we get a (two-sided) \(p\)-value of 0.123, not enough to be statistically significant. The 95% confidence interval around the estimated mean difference is [-0.966, 8.012]. Since this interval includes zero, and because \(p \gt 0.05\), we do not reject the null hypothesis.

Still have questions? Contact us!