How can I do ANOVA contrasts in SPSS?

How can I do ANOVA contrasts in SPSS?

ANOVA contrasts in SPSS refer to a statistical analysis method used to compare the means of three or more groups. This technique allows researchers to determine if there are significant differences between the means of the groups being studied. To perform ANOVA contrasts in SPSS, one must first input the data into the software and specify the groups to be compared. Next, the appropriate ANOVA test must be selected and the desired contrast options must be specified. SPSS will then calculate the contrast values and provide the necessary statistical output for interpretation. This process can be useful in various research settings, such as comparing the effectiveness of different treatments or identifying significant differences between demographic groups. Overall, ANOVA contrasts in SPSS are a valuable tool for understanding and analyzing group differences in a systematic and rigorous manner.

How can I do ANOVA contrasts in SPSS? | SPSS FAQ

Let’s use an example dataset, crf24.sav, adapted from Kirk (1968, First Edition).

get file 'c:tempcrf24.sav'.

These data are from a 2×4 factorial design but the same data can also be used for one-way ANOVA examples.  The variable y is the dependent variable.  The variable a is an independent variable with two levels, while b is an independent variable with four levels.

Using the contrast command in a one-way ANOVA

glm y by b.
Between-Subjects Factors
N
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model194.500(a)364.83344.276.000
Intercept924.5001924.500631.366.000
B194.500364.83344.276.000
Error41.000281.464
Total1160.00032
Corrected Total235.50031
a R Squared = .826 (Adjusted R Squared = .807)
means tables = y by b
 / cells mean.
Case Processing Summary
Cases
IncludedExcludedTotal
NPercentNPercentNPercent
Y * B32100.0%0.0%32100.0%
Report
Mean
BY
12.75
23.50
36.25
49.00
Total5.38

It is quite clear that there is a significant overall F for the independent variable b
(F(3, 28) = 44.276, p = .000).  Now, let’s devise some contrasts that we can test:
1) group 3 versus group 4
2) the average of groups 1 and 2 versus the average of groups 3 and 4
3) the average of groups 1, 2, and 3 versus group 4

glm y by b
 /contrast(b)=special (0 0 1 -1).
Between-Subjects Factors
N
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model194.500(a)364.83344.276.000
Intercept924.5001924.500631.366.000
B194.500364.83344.276.000
Error41.000281.464
Total1160.00032
Corrected Total235.50031
a R Squared = .826 (Adjusted R Squared = .807)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-2.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-2.750
Std. Error.605
Sig..000
95% Confidence Interval for DifferenceLower Bound-3.989
Upper Bound-1.511
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast30.250130.25020.659.000
Error41.000281.464

This contrast is statistically significant
(F(1, 28) = 20.659, p = .000).

glm y by b
 /contrast(b)=special (1 1 -1 -1).
Between-Subjects Factors
N
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model194.500(a)364.83344.276.000
Intercept924.5001924.500631.366.000
B194.500364.83344.276.000
Error41.000281.464
Total1160.00032
Corrected Total235.50031
a R Squared = .826 (Adjusted R Squared = .807)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-9.000
Hypothesized Value0
Difference (Estimate – Hypothesized)-9.000
Std. Error.856
Sig..000
95% Confidence Interval for DifferenceLower Bound-10.753
Upper Bound-7.247
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast162.0001162.000110.634.000
Error41.000281.464

This contrast is also statistically significant (F(1, 28) = 110.634, p =
.000).

glm y by b
 /contrast(b)=special (1 1 1 -3).
Between-Subjects Factors
N
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model194.500(a)364.83344.276.000
Intercept924.5001924.500631.366.000
B194.500364.83344.276.000
Error41.000281.464
Total1160.00032
Corrected Total235.50031
a R Squared = .826 (Adjusted R Squared = .807)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-14.500
Hypothesized Value0
Difference (Estimate – Hypothesized)-14.500
Std. Error1.482
Sig..000
95% Confidence Interval for DifferenceLower Bound-17.536
Upper Bound-11.464
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast140.1671140.16795.724.000
Error41.000281.464

This contrast is also statistically significant (F(1, 28) = 95.724, p =
.000).

Note that you can enter multiple contrasts in
a single subcommand, as shown below.  Each contrast must be separated by a comma.  While you get the significance
tests for each individual test,
you do not get the t-value.  To obtain the t-value, you will have to divide the contrast estimate by the
std. error in the Contrast Results (K Matrix)

table.

glm y by b
 /contrast(b)=special (0 0 1 -1, 1 1 -1 -1,  1 1 1 -3).
Between-Subjects Factors
N
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model194.500(a)364.83344.276.000
Intercept924.5001924.500631.366.000
B194.500364.83344.276.000
Error41.000281.464
Total1160.00032
Corrected Total235.50031
a R Squared = .826 (Adjusted R Squared = .807)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-2.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-2.750
Std. Error.605
Sig..000
95% Confidence Interval for DifferenceLower Bound-3.989
Upper Bound-1.511
L2Contrast Estimate-9.000
Hypothesized Value0
Difference (Estimate – Hypothesized)-9.000
Std. Error.856
Sig..000
95% Confidence Interval for DifferenceLower Bound-10.753
Upper Bound-7.247
L3Contrast Estimate-14.500
Hypothesized Value0
Difference (Estimate – Hypothesized)-14.500
Std. Error1.482
Sig..000
95% Confidence Interval for DifferenceLower Bound-17.536
Upper Bound-11.464
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast192.250296.12565.646.000
Error41.000281.464

Using the contrast command in a two-way ANOVA

Now let’s try the same contrasts on b but in a two-way ANOVA.

glm y by a b.
Between-Subjects Factors
N
A116
216
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model217.000(a)731.00040.216.000
Intercept924.5001924.5001199.351.000
A3.12513.1254.054.055
B194.500364.83384.108.000
A * B19.37536.4588.378.001
Error18.50024.771
Total1160.00032
Corrected Total235.50031
a R Squared = .921 (Adjusted R Squared = .899)
glm y by a b
/contrast(b)=special (0 0 1 -1).
Between-Subjects Factors
N
A116
216
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model217.000(a)731.00040.216.000
Intercept924.5001924.5001199.351.000
A3.12513.1254.054.055
B194.500364.83384.108.000
A * B19.37536.4588.378.001
Error18.50024.771
Total1160.00032
Corrected Total235.50031
a R Squared = .921 (Adjusted R Squared = .899)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-2.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-2.750
Std. Error.439
Sig..000
95% Confidence Interval for DifferenceLower Bound-3.656
Upper Bound-1.844
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast30.250130.25039.243.000
Error18.50024.771
glm y by a b
 /contrast(b)=special (1 1 -1 -1).
Between-Subjects Factors
N
A116
216
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model217.000(a)731.00040.216.000
Intercept924.5001924.5001199.351.000
A3.12513.1254.054.055
B194.500364.83384.108.000
A * B19.37536.4588.378.001
Error18.50024.771
Total1160.00032
Corrected Total235.50031
a R Squared = .921 (Adjusted R Squared = .899)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-9.000
Hypothesized Value0
Difference (Estimate – Hypothesized)-9.000
Std. Error.621
Sig..000
95% Confidence Interval for DifferenceLower Bound-10.281
Upper Bound-7.719
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast162.0001162.000210.162.000
Error18.50024.771
glm y by a b
 /contrast(b)=special (1 1 1 -3).
Between-Subjects Factors
N
A116
216
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model217.000(a)731.00040.216.000
Intercept924.5001924.5001199.351.000
A3.12513.1254.054.055
B194.500364.83384.108.000
A * B19.37536.4588.378.001
Error18.50024.771
Total1160.00032
Corrected Total235.50031
a R Squared = .921 (Adjusted R Squared = .899)
Contrast Results (K Matrix)
Dependent Variable
B Special ContrastY
L1Contrast Estimate-14.500
Hypothesized Value0
Difference (Estimate – Hypothesized)-14.500
Std. Error1.075
Sig..000
95% Confidence Interval for DifferenceLower Bound-16.719
Upper Bound-12.281
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast140.1671140.167181.838.000
Error18.50024.771

Note that the F-ratios in these contrasts are larger than the F-ratios in the one-way ANOVA example.  This is
because the two-way ANOVA has a smaller mean square residual than the one-way ANOVA.

SPSS has a number of built-in contrasts that you can
use, of which special (used in the above examples) is only one.  Below is a table listing those contrasts with an
explanation of the contrasts that they make and an example of how the syntax works.  The repeated
contrast compares group 1 with 2,
2 with 3, and 3 with 4 as shown in the Contrast Results (K Matrix)
table in the results.

Name of contrastComparison made
SimpleCompares each level of a variable to the last level (or
whichever level is specified)
DeviationCompares deviations from the grand mean
DifferenceCompares levels of a variable with the mean of the previous
levels of the variable
HelmertCompare levels of a variable with the mean of the subsequent
levels of the variable
PolynomialOrthogonal polynomial contrasts
RepeatedAdjacent levels of a variable
SpecialUser-defined contrast
glm y by a b
 /contrast(b)=repeated.
Between-Subjects Factors
N
A116
216
B18
28
38
48
Tests of Between-Subjects Effects
Dependent Variable: Y
SourceType III Sum of SquaresdfMean SquareFSig.
Corrected Model217.000(a)731.00040.216.000
Intercept924.5001924.5001199.351.000
A3.12513.1254.054.055
B194.500364.83384.108.000
A * B19.37536.4588.378.001
Error18.50024.771
Total1160.00032
Corrected Total235.50031
a R Squared = .921 (Adjusted R Squared = .899)
Contrast Results (K Matrix)
Dependent Variable
B Repeated ContrastY
Level 1 vs. Level 2Contrast Estimate-.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-.750
Std. Error.439
Sig..100
95% Confidence Interval for DifferenceLower Bound-1.656
Upper Bound.156
Level 2 vs. Level 3Contrast Estimate-2.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-2.750
Std. Error.439
Sig..000
95% Confidence Interval for DifferenceLower Bound-3.656
Upper Bound-1.844
Level 3 vs. Level 4Contrast Estimate-2.750
Hypothesized Value0
Difference (Estimate – Hypothesized)-2.750
Std. Error.439
Sig..000
95% Confidence Interval for DifferenceLower Bound-3.656
Upper Bound-1.844
Test Results
Dependent Variable: Y
SourceSum of SquaresdfMean SquareFSig.
Contrast194.500364.83384.108.000
Error18.50024.771

For more information on coding contrasts,
please see How can I use the lmatrix subcommand to understand a three-way interaction
in ANOVA? .

References

Kirk, Roger E. (1968) Experimental Design: Procedures for the Behavioral Sciences.
Monterey, California: Brooks/Cole Publishing.

Cite this article

stats writer (2024). How can I do ANOVA contrasts in SPSS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-do-anova-contrasts-in-spss/

stats writer. "How can I do ANOVA contrasts in SPSS?." PSYCHOLOGICAL SCALES, 30 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-do-anova-contrasts-in-spss/.

stats writer. "How can I do ANOVA contrasts in SPSS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-do-anova-contrasts-in-spss/.

stats writer (2024) 'How can I do ANOVA contrasts in SPSS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-do-anova-contrasts-in-spss/.

[1] stats writer, "How can I do ANOVA contrasts in SPSS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I do ANOVA contrasts in SPSS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top