Introduction to SPSS for
the PC: Within Subject Analyses
Part 2: Within
Subject Analyses
Within SPSS, analyses are generated using either menu
selections or command syntax. Below is a description of how to run
some common within subject analyses using menu selections. Following
each description is the command syntax used to generate the same analyses
along with a brief explanation of the commands (For more help on using
syntax see: Tips
for SPSS Syntax). To generate the results utilized in these examples
you will need to enter the Raw Data
set below.
I. Two-sample
Correlated t-test
II. Repeated
Measures ANOVA
III. Mixed
Factorial ANOVA
VI. Two-sample Correlated t-test
Sample question: Do rates of smoking decrease
from pre-intervention to post-intervention? To answer this question,
you can run a two-sample correlated t-test comparing the preintervention
smoking rates to post-intervention rates.
-
Select Analyze > Compare Means > Paired-Samples T test
on the menu bar. This will open a window called Paired-Samples T Test.
-
The pre- and post-intervention smoking rates represent the
within subject variable. Highlight pre. You will see
that pre now appears as Variable 1 in the Current Selection box.
Now highlight post. You will see that post now appears
as Variable 2 in the Current Selection box. Use the arrow
button to move the selection to the Paired Variable(s) box.
-
Click on OK to run the analysis.
-
The first table of the printout contains descriptive statistics
while the second table contains inferential statistics. Study the printout
below and make sure you can identify n, M, and SD for each
group, as well as t, df, and p (p is in the column
labeled "Sig. (2-tailed)"). In this case, the mean number of cigarettes
smoked prior to the intervention programs was significantly higher than
the number of cigarettes smoked after the intervention programs, t(29)
= 18.57,
p = .001.

Command Syntax for Two-sample Correlated t-test:
T-TEST
PAIRS= pre WITH post (PAIRED).
T-TEST
PAIRS= pre WITH post (PAIRED). - The "pairs=" subcommand
identifies which pair of variables you want to correlate for your t-test.
In this case we type pre WITH post (PAIRED).
Back to Within Subject
Analyses list
II. Repeated Measures Analysis of Variance (ANOVA)
Sample question: Do rates of smoking decrease
across the four data collection periods. That is, does smoking not
only decrease from pre-intervention to post-intervention but also does
the rate continue to decrease during a 6-month and 12-month follow up?
To answer this question you can run a repeated measures ANOVA, comparing
all four time periods for all smokers.
-
Select Analyze > General Linear Model > Repeated Measures
from the menu bar to open the Repeated Measures Define Factors window.
-
In the Within Subject Factor Name box designate a
name for the repeated measure factor. In this case, let's call it
rate.
In the Number of Levels window type in the number of time periods
measured. In this case it is 4. Click on Add and then
Define.
A
Repeated
Measures box will appear.
-
Highlight your first time variable, pre, from the
list of variables on the left, and click on the upper arrow button
to move it into the Within Subject Variables window. Add the
remaining three time variables, post, follow6, and follow12,
in the same fashion.
-
Click on the Options button. An Options
window will appear. Click on the square next to the word Descriptive
(a check will now appear in the box). This will cause descriptive statistics
to print out along with your ANOVA results. (If you don't do this, the
printout will only tell you if the overall ANOVA is significant, but it
will not tell you the means of each group.)
-
While still in the Options window, highlight rate
in
the Factor(s) and Factor Interaction box. Click on the arrow
button and click on the square next to the word Compare main effects.
This will produce multiple pairwise comparisons that can be interpreted
if the omnibus test is significant.
-
Click on Continue to return to the Repeated Measures
window.
-
Click on OK to run the analysis. Selected results
are printed below.


-
The printout from SPSS shows the Within Subject Factor, Descriptive
Statistics, A Multivariate Test, A Mauchly's test for Sphericity, Test
of Within-Subject Effects, Test of Within-Subject Contrasts, Test of Within-Subject
Effects Averaged, Marginal Means, and Pairwise Comparisons. Only
those outputs, relevant to the basic repeated measures analysis are presented
above. First, be sure you can identify n, M, and SD for
each of the four time periods in the descriptive statistics output.
Second, examine Mauchly's test of Sphericity to determine if the homogeniety
of variance assumption is met. If the p-value is significant
(look under Sig.) then the the assumption has been violated. This
will determine which values you interpret on the ANOVA table (Tests of
Within-Subject Effects). Third, examine the Tests of Within-Subject
Effects table (ANOVA table) to determine the significance of your omnibus
test. When the Sphericity assumption is not violated, you can interpret
the top set of values (i.e., Sum of Squares, df, Mean Sum of Squares,
F,
and p (Sig.)). When the Sphericity assumption is violated,
you can interpret the values associated with Huynh-Feldt test. In
this case, there is a significant difference in smoking rates across the
time periods, F(1.31, 38.09) = 256.85, p = .001. Since
the results of the repeated measures ANOVA are significant, you will want
to examine the post-hoc tests to determine between which time periods significant
differences are occurring by using the Multiple Comparison table.
-
The Multiple Comparisons table provides detailed information
concerning the post-hoc results. This table shows all possible comparisons
between the four time periods. In the first row, the pre-intervention
smoking rates is compared to the post-intervention smoking rates.
The mean difference for this comparison is 25.1000 (i.e., the average smoking
rate for pre-intervention, 30.5333, is subtracted from the average post-intervention
smoking rate, 5.4333). To determine whether this mean difference
is statistically significant examine the "Sig. Column" which represents
the
p-value. The p-value is .000 suggesting that the groups
are significantly different from one another. This is also supported
by the 95% confidence interval which indicates that zero is within the
lower and upper bounds. Following this comparison, a comparison is made
between the pre-intervention smoking rates and smoking rates at a six month
follow-up which shows a significant difference between the two groups,
p = .000. You will notice that SPSS places a star next to mean difference
scores that differ significantly. The remaining rows provide the
results for the other comparisons. One deficit of SPSS is that it
only tells you between which groups you have significant differences and
the p-levels, but it does not give you the exact values of the post-hoc
tests. In this case, all time periods are significantly different
from one another with the exception of the follow up at six months and
12 months.
Command Syntax for Repeated Measures ANOVA:
GLM
pre post follow6 follow12
/WSFACTOR = rate 4
/EMMEANS = TABLES(rate) COMPARE ADJ(LSD)
/PRINT = DESCRIPTIVE
/WSDESIGN = rate .
GLM
pre post follow6 follow12 - This statement indicates all
the time variables to be examined.
/WSFACTOR = rate 4 - This statement indicates that the above
variables should be treated as a within subject factor. The title
of the factor is "rate" which has "4" time variables.
/EMMEANS = TABLES(rate) COMPARE ADJ(LSD) - This command will generate
estimated marginal means and conduct a post hoc test (in this case the
least significance difference test).
/PRINT = DESCRIPTIVE - The "/print=" subcommand allows the user
to print several descriptive and inferential statistical tests that may
be important to examine when running a repeated measures ANOVA. To
get a complete list of the statistics offered for the Repeated Measures
ANOVA refer to the help menu in SPSS (i.e., Select Help > Topics on the
menu bar which will open the Help Topics window. Click on the Index
tab. Type "GLM" in the box. GLM Repeated Measures will appear
in the second box. Highlight Options under GLM Repeated Measures.
Click on the Display button.).
/WSDESIGN = rate. - The "/wsdesign=" subcommand identifies the main
and interaction effects to be analyzed using a within subject design.
Back to Within Subject Analyses
list
III. Mixed Factorial ANOVA
Sample question: Do the smoking rates differ across
the three types of smoking cessation program over time? That is,
does one program lead to greater reductions in smoking rates among smokers?
To answer this question you can run a Mixed Factorial ANOVA, with pre-
and post intervention smoking rates as the within subject variable and
smoking cessation program as the independent variable.
-
Select Analyze > General Linear Model > Repeated Measures
from the menu bar to open the Repeated Measures Define Factors window.
-
In the Within Subject Factor Name box designate a
name for the repeated measure factor. In this case, let's call it
time.
In the Number of Levels window type in the number of time periods
measured. In this case it is 2. Click on Add and then
Define.
A
Repeated
Measures box will appear.
-
Highlight your first time variable, pre, from the
list of variables on the left, and click on the upper arrow button
to move it into the Within Subject Variables window. Add the
remaining time variable, post, in the same fashion.
-
Highlight program and click on the arrow button
in front of the Between-Subjects Factor(s) box.
-
Click on the Options button. An Options
window will appear. Click on the square next to the word Descriptive
(a check will now appear in the box). This will cause descriptive statistics
to print out along with your ANOVA results. (If you don't do this, the
printout will only tell you if the overall ANOVA is significant, but it
will not tell you the means of each group.)
-
While still in the Options window, highlight time
in
the Factor(s) and Factor Interaction box. Click on the arrow
button and click on the square next to the word Compare main effects.
This will produce multiple pairwise comparisons that can be interpreted
if the main effect is significant and the interaction effect is found to
not be significant. Note: This command does not need to be
executed if there are only two time periods. Click on Continue
to return to the Repeated Measures window.
-
Click on the Post Hoc... button at the bottom of the
screen. This opens a window in which you can select which post hoc test(s)
you want to run for your between subjects factor. Highlight program
in the Factor(s) box. Click on the arrow button to
move program to the Post Hoc tests for: box. Select a test,
i.e., click on the box in front of one of the tests, in this case Tukey.
-
Click on Continue to return to the Repeated Measures
window.
-
Click on OK to run the analysis. Selected results
are printed below.


-
The printout from SPSS shows the Within Subject Factor, Between
Subject Factor, Descriptive Statistics, A Multivariate Test, A Mauchly's
test for Sphericity, Test of Within-Subject Effects, Test of Within-Subject
Contrasts, Test of Within-Subject Effects Averaged, Marginal Means, and
Pairwise Comparisons. Only those outputs relevant to the basic analysis
will be presented here. First, be sure you can identify n, M,
and
SD for each of the two time periods across the three interventions
using the descriptive statistics output. Second, examine the Tests
of Within-Subject Effects table (ANOVA table) to determine the significance
of your omnibus test. The interaction effect should be examined first
to determine if it is significant. In this case, the interaction
effect is significant, F(1, 27) = 3.398, p = .05 (used the
top set of values - refer to Repeated Measures ANOVA to determine when
the top set of values should be used.). This suggests that there
is a significant difference in the interventions programs across time.
To determine where the significant differences lie, separate hand calculated
t-tests must be conducted for each set of values. For example, a
comparison between the mean number of cigarettes smoked in the standard
intervention program and the behavioral counseling intervention program
at post intervention should be compared. All possible comparisons
are calculated. Since the interaction is significant, the main effect
for time should not be interpreted. If the interaction was not significant,
the main effect for time and program could be examined. The main
effect for time is found in the Tests of Within-Subjects Effects.
The main effect for program is found in the Tests of Within-Subject Effects
Averaged (see third table above). This is interpreted similar to
a one-way ANOVA. That is, you interpret the main effect for program
while ignoring the effect for time. If this result is significant
(in this case it is not), you can interpret the Post Hoc tests (see the
Multiple Comparison table). Refer to the Repeated Measures ANOVA
for a directions on how to interpret a significant post hoc test.
Command Syntax for Mixed Factorial ANOVA:
GLM
pre post BY program
/WSFACTOR = time 2
/POSTHOC = program ( TUKEY )
/EMMEANS = TABLES(time) COMPARE ADJ(LSD)
/PRINT = DESCRIPTIVE
/WSDESIGN = time
/DESIGN = program .
GLM
pre post BY program - This statement indicates the between
subject and with subject factors to be utilized when conducting the Mixed
ANOVA. The within subject variable is listed first followed by the
between subject variable with "By" separating the two.
/WSFACTOR = time 2 - This statement indicates that the above
variables should be treated as a within subject factor. The title
of the factor is "time" and there "2" time variables.
/POSTHOC = TUKEY - The "/posthoc=" subcommand will generate
the post hoc test listed after the equal sign (in this case Tukey's) for
the between subject variable(s). For a complete list of post hoc
tests refer to the GLM Repeated Measures Options in the SPSS help files.
/EMMEANS = TABLES(time) COMPARE ADJ(LSD) - This command will generate
estimated marginal means and conduct a post hoc test (in this case
the least significance difference test) for the within subject variable(s).
/PRINT = DESCRIPTIVE - The "/print=" subcommand allows the
user to print several descriptive and inferential statistical tests that
may be important to examine when running a Mixed ANOVA. To get a
complete list of the statistics offered refer to the help menu in SPSS
(i.e., Select Help > Topics on the menu bar which will open the Help Topics
window. Click on the Index tab. Type "GLM" in the box.
GLM Repeated Measures will appear in the second box. Highlight Options
under GLM Repeated Measures. Click on the Display button.).
/WSDESIGN = time. - The "/wsdesign=" subcommand identifies the main
and interaction effects to be analyzed related to within subject factor(s).
/DESIGN = program. - The "/design=" subcommand identifies
the main and interaction effects to be analyzed related to between subject
factor(s).
Back to Within Subject
Analyses list
Raw Data
To illustrate how to conduct within subject analyses we will use
the following hypothetical data set based on examining the effectiveness
of smoking cessation programs among heavy smokers who are also recovering
alcoholics. The description of the variables are given below the
data set. Please refer to Setting
Up Data Files to define variables and enter data into SPSS.
|
id
|
gender
|
program
|
pre
|
post
|
follow6
|
follow12
|
|
1
|
1
|
1
|
31
|
15
|
18
|
19
|
|
2
|
2
|
1
|
28
|
0
|
0
|
0
|
|
3
|
1
|
1
|
26
|
12
|
15
|
15
|
|
4
|
2
|
1
|
38
|
0
|
0
|
1
|
|
5
|
2
|
1
|
19
|
7
|
9
|
8
|
|
6
|
1
|
1
|
24
|
0
|
5
|
6
|
|
7
|
2
|
1
|
26
|
7
|
10
|
11
|
|
8
|
1
|
1
|
32
|
16
|
14
|
15
|
|
9
|
2
|
1
|
29
|
8
|
10
|
9
|
|
10
|
2
|
1
|
25
|
5
|
8
|
7
|
|
11
|
2
|
2
|
37
|
0
|
6
|
6
|
|
12
|
1
|
2
|
21
|
0
|
4
|
5
|
|
13
|
2
|
2
|
28
|
10
|
13
|
13
|
|
14
|
2
|
2
|
27
|
5
|
5
|
4
|
|
15
|
1
|
2
|
35
|
0
|
0
|
0
|
|
16
|
2
|
2
|
34
|
11
|
10
|
9
|
|
17
|
1
|
2
|
38
|
0
|
0
|
0
|
|
18
|
2
|
2
|
32
|
0
|
6
|
7
|
|
19
|
2
|
2
|
36
|
4
|
7
|
8
|
|
20
|
1
|
2
|
29
|
0
|
0
|
0
|
|
21
|
1
|
3
|
30
|
7
|
10
|
12
|
|
22
|
1
|
3
|
27
|
0
|
0
|
0
|
|
23
|
1
|
3
|
39
|
13
|
15
|
16
|
|
24
|
2
|
3
|
41
|
16
|
19
|
23
|
|
25
|
2
|
3
|
29
|
0
|
7
|
7
|
|
26
|
2
|
3
|
36
|
0
|
0
|
2
|
|
27
|
2
|
3
|
33
|
9
|
14
|
16
|
|
28
|
1
|
3
|
32
|
18
|
17
|
18
|
|
29
|
2
|
3
|
27
|
0
|
0
|
0
|
|
30
|
2
|
3
|
27
|
0
|
11
|
9
|
| Variable Name |
Description and Coding |
| id |
participant identification number |
| gender |
1 = female, 2 = male |
| program |
1 = Standard ALA program pus nicotine anonymous program, 2 = Behavioral
counseling plus exercise program, 3 = Behavioral counseling plus nicotine
gum |
| pre |
Mean # of cigarettes smoked per day Pre-intervention |
| post |
Mean # of cigarettes smoked following intervention |
| follow6 |
Mean # of cigarettes smoked at six month follow up |
| follow12 |
Mean # of cigarettes smoked at 12 month follow up |
© 2004 Bates College. All rights reserved.
Maintained by Brian Pfohl