SPSS Statistics Tutorials


SPSS Tutorials


Quick Reference Guides for SPSS, SAS and WINKS

BeSmartNotes (tm)



For quick and simple statistical analysis use WINKS SDA
Click for more info




Two-sample t-test Using SPSS

See www.stattutorials.com/SPSSDATA for files mentioned in this tutorial TexaSoft, 2008


These SPSS statistics tutorials briefly explain the use and interpretation of standard statistical analysis techniques for Medical, Pharmaceutical, Clinical Trials, Marketing or Scientific Research. The examples include how-to instructions for SPSS Software.


            This example is adapted from information in Statistical Analysis Quick Reference Guidebook (2007).



The two-sample (independent groups) t-test is used to determine whether the unknown means of two populations are different from each other based on independent samples from each population.  If the two sample means are sufficiently different from each other, then the population means are declared to be different.

The samples for a two-sample t-test can be obtained from a single population that has been randomly divided into two subgroups with each subgroup subjected to one of two treatments (e.g., two medications) or from two separate populations (e.g., male and female).  In either case, for the two-sample t-test to be valid, it is necessary that the two samples are independent, i.e. unrelated to each other.

Design considerations for a two-sample t-test

The characteristics of the t-tests in the above examples are:

  • A two sample t-test compares means: In an experiment designed to use the two-sample t-test, you want to compare means from a quantitative variable such as height, weight, amount spent, or grade. In other words, it should make sense to calculate the mean of the observations.
  • You are comparing independent samples:  The two groups contain subjects (or objects) that are not paired or matched in any way.
  • The t-test assumes normality: A standard assumption for the t-test to be valid when you have small sample sizes is that the outcome variable measurements are normally distributed.
  • Are the variances equal?  Another consideration that should be addressed before using the t-test is whether the population variances can be considered to be equal.

            The two-sample t-test is robust against moderate departures from the normality and variance assumption, but independence of samples must not be violated.


Hypotheses for a two-sample t-test 


Typical hypotheses for the comparison of the means in a two-sample t-test are as follows:

Ho: m1 = m 2   (In words:  The population means of the two groups are the same.)

Ha: m 1m 2   (The population means of the two groups are different.)

One-tailed tests: If your experiment is designed so that you are only interested in detecting whether one mean is larger than the other, you may choose to perform a one-tailed (sometimes called one-sided) t-test. Since SPSS always reports a two-tailed p-value you must modify the reported p-value to fit a one-tailed test by dividing it by 2.

Example - Two-sample t-test with equal variances

Describing the problem: A researcher wants to know whether one fertilizer (Brand 1) causes plants to grow faster than another brand of fertilizer (Brand 2). Starting with seeds, he grows plants in identical conditions and randomly assigns fertilizer “Brand 1” to 7 plants and fertilizer “Brand 2” to 6 plants. The data for this experiment are as follows where the outcome measurement is the height of the plant after 3 weeks of growth. The data are shown in the following table.


    Fertilizer Data

Fertilizer 1

  Fertilizer 2

51.0 cm

54.0 cm














Since either fertilizer could be superior, a two-sided t-test is appropriate. The hypotheses for this test are (in words):

Null Hypothesis eq1: The mean growth heights of the plants using the two different fertilizers are the same.

Alternative Hypothesis eq2: The mean growth heights of the plants using the two fertilizers are different.

Arranging the data for analysis: o perform the analysis for the fertilizer data using most statistical software programs (including SPSS), you must set up the data using two variables: a classification or group code and an observed (outcome/response) variable. Thus, the way the data are shown in the figure below:

SPSS T-test data

  • Select a grouping code to represent the two fertilizer types. This code could be numeric (i.e., 1, 2) or text (i.e., A, B or BRAND1, BRAND2.) For this example, use the grouping code named Type, where 1 represents Brand1 and 2 represents Brand2.


  • Name the outcome variable. The outcome (response) variable is the observed height and is designated with the variable named Height.


  • The grouping codes specify which observation belongs to which type of fertilizer. Thus, to set up the data for most statistics programs, place one observation per line, with each data line containing two variables: a fertilizer code (Type) and the corresponding response variable (Height.)


            The values 1 and 2 in the “type” column represent the two brands of fertilizer and the “height” variable is the outcome height measurement on the plants.  (The codes 1 and 2 in this data set were arbitrarily selected. You could have used 0 and 1 or any other set of binary codes.)

SPSS step-by-step: Two-sample t-test with equal variances

To run the two-sample t-test on the FERTILIZER.SAV data, follow these steps:

  1. Open the dataset FERTILIZER.SAV and select Analyze/Compare Means/Independent Samples T Test … .  (Or create the data set using the data shown above)
  2. Select Height as the Test Variable and Type as the Grouping Variable.
  3. Click on the Define Groups button and define the group values as 1 and 2.
  4. Click Continue and OK and the tables appear shown in Table 3.4 are displayed.
  5. To display the boxplot select Graphs/Boxplot and choose Simple Boxplot and then Define. Select Height as the Variable and Type as the Category Axis..

The boxplot is a way to examine the assumptions of normality and equality of variances.

SPSS box plots

From the listing of the data and boxplot notice that the sample sizes are small with only 7 observations in group 1 and 6 observations in group 2. Also note that the distributions of both groups are relatively symmetric and the variances appear to be fairly similar. There is no evidence of any sizeable outliers. Here is the information in the SPSS output you need to perform the t-test.

SPSS t-test output

First notice the results of the F-test (Levene’s test) for evaluating the equality of variance.  There it can be seen that the p-value is 0.79 which indicates that the variances are not significantly different. You now have two pieces of information that indicate the variances are similar (the boxplot and Levene’s test).

Therefore, the appropriate t-test is the one that assumes equal variances.  However, if you choose to go with the conservative approach, you will use the “Equal variances not assumed” t-test. In this case your final decision for the significance of the t-test would not be different.

The following information discusses methods of interpreting the output from “Independent Samples Test” table.


Making a decision based on the p-value: The p-value for the equal variances t-test is p = 0.269. Since this p-value is greater than 0.05, the decision would be that there is no significant difference between the two groups. (Do not reject the null hypothesis.) Thus, there is not enough evidence to conclude that the mean heights are different.


Making a decision based on the confidence interval: The 95% confidence intervals for the difference in means are given in the last two columns of Table 3.4.  The interval associated with the assumption of equal variances is (-3.41 to 1.05) while the confidence interval when equal variances are not assumed is (-3.39 to 1.03).  Since these intervals include 0 (zero) we again conclude that there is no significant difference between the means using either assumption regarding the variances.  Thus, you would make the same decisions discussed in the p-value section above. 

Reporting the results of a (non-significant) two-sample t-test

The following sample write-ups illustrate how you might report this two-sample t-test in publication format.  For purposes of illustration, we use the “Equal variance” t-test for the remainder of this example:

Narrative for the Methods Section:

“A two-sample Student’s t-test assuming equal variances using a pooled estimate of the variance was performed to test the hypothesis that the resulting mean heights of the plants for the two types of fertilizer were equal.”

Narrative for the Results Section:

 “The mean heights of plants using the two brands of fertilizer were not significantly different, t(11) = -1.17, p =0.27.”

or to be more complete,

“The mean height of plants using fertilizer Brand 1 (M = 53.07, SD =1.91, N=7) was not significantly different from that using fertilizer Brand 2 (M = 54.25, SD = 1.71 N=6), t(11) = -1.17, p =0.27.”  

A description of the confidence interval would read:

A 95% confidence interval on the difference between the two population means using a Student’s t distribution with 11 degrees of freedom is (-3.41, 1.05) which indicates that there is not significant evidence that the fertilizers produce different mean growth heights.”

For more details on the process see Statistical Analysis Quick Reference Guidebook with SPSS Example, Elliott and Woodward, Sage Publications.

  See www.stattutorials.com/SPSSDATA for files mentioned in this tutorial TexaSoft, 2008

End of tutorial

See http://www.stattutorials.com/SPSS


Stat book coverAlso, we recommend this book: Statistical Analysis Quick Reference Guidebook: With SPSS Examples is a practical "cut to the chase" handbook that quickly explains the when, where, and how of statistical data analysis as it is used for real-world decision-making in a wide variety of disciplines. In this one-stop reference, the authors provide succinct guidelines for performing an analysis, avoiding pitfalls, interpreting results, and reporting outcomes.
Paperback. Sage Publishers
ISBN: 1412925606
Order book from Amazon


WINKS Numbers






Get the SPSS BeSmartNotes Quick Reference Guide


| Send comments | Back to Tutorial Menu | TexaSoft |

Copyright TexaSoft, 1996-2008

This site is not affiliated with SPSS(r)