SPSS FAQ
How can I do repeated measures ANOVA with covariates in SPSS?

SPSS provides several ways to analyze repeated measures ANOVA that include covariates. This FAQ page will look at ways of analyzing data in either wide form, i.e., all of the repeated measures for a subject are in one row of the data, or in long form where each of the repeated values are found on a separate row of the data.

There are two kinds of covariates found in repeated measures analyses; 1) time-invariant covariates or 2) time-varying covariates. With time-invariant covariates there is just one value that is used for all the repeated observations for a given subject. Time-varying covariates, on the other hand, can take on a different value for each of the repeated observations. Time-invariant covariates can be analyzed with either wide data or long data. However, time-varying covariates require the data to be in the long form.

Here is an example of what one subject's data with a time-varying covariate looks like in wide form.

sub group dv1 dv2 dv3 cv1 cv2 cv3
 1    1    3   4   7   3   1   2
And here is what the same data for the same subject looks like in long form.

sub group trial  dv   cv
 1    1     1     3    3 
 1    1     2     4    1
 1    1     3     7    2
Now we can begin by reading in the example data in wide form.

data list list
  / sub group dv1 dv2 dv3 cv1 cv2 cv3.
begin data.
1 1  3  4  7  3 1 2
2 1  6  8 12  9 3 1
3 1  7 13 11 11 8 4
4 1  0  3  6  6 2 1
5 2  5  6 11  7 8 3
6 2 10 12 18 15 9 5
7 2 10 15 15 14 8 6
8 2  5  7 11  9 2 8 
end data.
Model 1

We will begin by using the glm procedure keeping the data in the wide form. We will use cv1 as the time-invariant covariate. When the data are wide you cannot use a time-varying covariate. To include the covariate in the model we use the with term in the first line of the command. For the purposes of this FAQ page, we will display only the univariate ANOVA tables for within-subjects and between subjects effects.

glm dv1 dv2 dv3 by group with cv1
  /wsfactors=trial 3
  /wsdesign=trial
  /design=group cv1.
  
Tests of Within-Subjects Effects
Measure:MEASURE_1
Source Type III Sum of Squares df Mean Square F Sig.
trial Sphericity Assumed 16.325 2 8.163 4.439 .042
Greenhouse-Geisser 16.325 1.081 15.098 4.439 .084
Huynh-Feldt 16.325 1.697 9.620 4.439 .052
Lower-bound 16.325 1.000 16.325 4.439 .089
trial * group Sphericity Assumed 6.565 2 3.282 1.785 .217
Greenhouse-Geisser 6.565 1.081 6.071 1.785 .238
Huynh-Feldt 6.565 1.697 3.868 1.785 .225
Lower-bound 6.565 1.000 6.565 1.785 .239
trial * cv1 Sphericity Assumed 6.445 2 3.223 1.753 .223
Greenhouse-Geisser 6.445 1.081 5.961 1.753 .242
Huynh-Feldt 6.445 1.697 3.798 1.753 .230
Lower-bound 6.445 1.000 6.445 1.753 .243
Error(trial) Sphericity Assumed 18.388 10 1.839    
Greenhouse-Geisser 18.388 5.406 3.401    
Huynh-Feldt 18.388 8.485 2.167    
Lower-bound 18.388 5.000 3.678    

Tests of Between-Subjects Effects
Measure:MEASURE_1
Transformed Variable:Average
Source Type III Sum of Squares df Mean Square F Sig.
Intercept 1.466 1 1.466 .217 .661
group .635 1 .635 .094 .771
cv1 173.141 1 173.141 25.631 .004
Error 33.775 5 6.755    
Note that the output above includes the trial*cv1 interaction as part of the within-subjects effects. If this is what you want, fine. But if you don't want this interaction term you will need to run the model with a different procedure, the manova command.

Model 2

The manova command can only be run from syntax, it cannot be run using the pull-down menus. The manova command is much older than glm and its syntax is a bit fussier. For example, you have to declare the range of levels for each of the by factors and the covariate needs to be placed inside parentheses. Again, we will focus on the univariate between- and within-subject effects.

manova dv1 dv2 dv3 by group(1,2) with (cv1)
  /wsfactors trial (3)
  /wsdesign trial
  /design.


* * * * * * * * * * * * * * * * * A n a l y s i s   o f   V a r i a n c e -- Design   1 * * * * * * * * * * * * * * * * *

Tests of Between-Subjects Effects.

 Tests of Significance for T1 using UNIQUE sums of squares
 Source of Variation          SS      DF        MS         F  Sig of F

 WITHIN+RESIDUAL           33.78       5      6.76
 REGRESSION               173.14       1    173.14     25.63      .004
 group                       .64       1       .64       .09      .771

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Regression analysis for WITHIN+RESIDUAL error term
 --- Individual Univariate .9500 confidence intervals
 Dependent variable .. T1

 COVARIATE               B           Beta      Std. Err.        t-Value      Sig. of t     Lower -95%     CL- Upper

 Tcv1          .8415132924    .9098200606         .16622        5.06274           .004         .41424        1.26879

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

* * * * * * * * * * * * * * * * * A n a l y s i s   o f   V a r i a n c e -- Design   1 * * * * * * * * * * * * * * * * *

Tests involving 'TRIAL' Within-Subject Effect.


 Mauchly sphericity test, W =      .36971
 Chi-square approx. =             4.97514 with 2 D. F.
 Significance =                      .083

 Greenhouse-Geisser Epsilon =      .61339
 Huynh-Feldt Epsilon =             .81855
 Lower-bound Epsilon =             .50000

AVERAGED Tests of Significance that follow multivariate tests are equivalent to
univariate or split-plot or mixed-model approach to repeated measures.
Epsilons may be used to adjust d.f. for the AVERAGED results.

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

* * * * * * * * * * * * * * * * * A n a l y s i s   o f   V a r i a n c e -- Design   1 * * * * * * * * * * * * * * * * *

Tests involving 'TRIAL' Within-Subject Effect.

 AVERAGED Tests of Significance for dv using UNIQUE sums of squares
 Source of Variation          SS      DF        MS         F  Sig of F

 WITHIN+RESIDUAL           24.83      12      2.07
 TRIAL                    126.58       2     63.29     30.58      .000
 group BY TRIAL             3.25       2      1.63       .79      .478

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The t-test for for cv1 is 5.06274 and is found on the row beginning with Tcv1.

Model 3

We used glm and manova with data in the wide form. It is also possible to analyze these two models with data in the long form using the mixed command. In fact, if you want to include time-varying covariates you will need to use mixed. The varstocases command below will handle the data conversion from wide to long but before we run the command we will create a new variable, cvone, that we will use in the models with a time-invariant covariate.

compute cvone=cv1.

varstocases
 /make dv from dv1 dv2 dv3
 /make cv from cv1 cv2 cv3
 /index = trial.
For Model 3, we will use the mixed command to duplicate the analysis from Model 1. The first line of the command looks very much like the glm command. The fixed subcommand lists all of the fixed effects including the trial*cvone interaction. The repeated line declares the name of the repeated effect while the subject() option is used for the subject identifier. To reproduce the glm output we also include the covtype(cs) option which select the compound symmetry covariance structure.
mixed dv by group trial with cvone
  /fixed= group trial group*trial cvone trial*cvone
  /repeated= trial | subject(sub) covtype(cs).
 
Type III Tests of Fixed Effectsa
SourceNumerator dfDenominator dfFSig.
Intercept15.217.661
group15.094.771
trial210.0004.439.042
group * trial210.0001.785.217
cvone1525.631.004
trial * cvone210.0001.753.223
a. Dependent Variable: dv.
Model 4

Next, to reproduce the results from Model 2, the manova command with wide data, we will run the same model as Model 3 but drop the trial*cvone interaction term. The F-ration for cvone of 25.631 is the same as the t-value squared for cv1 from Model 2, i.e., 5.06274^2 = 25.631336.

mixed dv by group trial with cvone
  /fixed= group trial group*trial cvone
  /repeated= trial | subject(sub) covtype(cs).
 
Type III Tests of Fixed Effectsa
SourceNumerator dfDenominator dfFSig.
Intercept15.217.661
group15.094.771
trial212.00030.584.000
group * trial212.000.785.478
cvone1525.631.004
Model 5

Our final example shows how to analyze the repeated measures ANOVA with a time-varying covariate. The covariate cv has a different value for each of the repeated trials.

mixed dv by group trial with cv
  /fixed= group trial group*trial cv
  /repeated= trial | subject(sub) covtype(cs).
 
Type III Tests of Fixed Effectsa
SourceNumerator dfDenominator dfFSig.
Intercept112.80127.746.000
group15.8812.177.191
trial210.85812.708.001
group * trial210.287.704.517
cv112.235.081.780
The results from Models 1 and 3 are identical as are the results from Models 2 and 4. However, the results for Models 1 and 3 cannot be directly compared with the results from Models 2 and 4, Nor, can either of those be compared with Model 5. The models differ in the number of predictors and the type of covariate and so are not comparable.

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.