This handout will review how to do 2-way ANOVA, comparisons of marginal means, interaction contrasts, and simple effects analyses using SPSS. In addition, I will discuss how to perform non-orthogonal ANOVAs using SPSS.
Two general approaches will be used depending on the analysis. One involves the pull-down menus you see when you first enter SPSS. The second involves syntax files, in which the user enters commands similar to those that we have used for SAS. The former approach is best for relatively simple analyses but the latter offers the maximal number of options. Most of the analyses will be done using the Generalized Linear Model program in SPSS with the univariate option. However, at some points we will use the multivariate (MANOVA) option within the GLM program.
The Data I will assume that you know how to create a SPSS .sav file and to read it in using a GET statement if youre using the syntax editor. The data file used for this example is on the web site and named twoway.sav. It contains data from the biofeedback X drug group example used for the SAS two-way ANOVA programs. I should note that the particular data set used here is the one with 6 subjects per cell (36 in all) that was used for the SAS program demonstrating interaction contrasts and simple effects analysis. Part of the data file looks like this:
2
Two-way ANOVA To do the omnibus two-way ANOVA, it is probably easiest to just use the pull-down menu option. Click on Analyze >>> General Linear Model >> Univariate:
Then, indicate the dependent variable and the factors in the appropriate boxes.
3
I would also use the Options to generate marginal and cell means:
Then hit Continue and then OK and you will initiate the analysis. As youll see from the output, these steps also generate the following Syntax code (that you could use if you did this using the Syntax editor): UNIANOVA bp BY bio_gp drug_gp /METHOD=SSTYPE(3) /INTERCEPT=INCLUDE /EMMEANS=TABLES(bio_gp) /EMMEANS=TABLES(drug_gp) /EMMEANS=TABLES(bio_gp*drug_gp) /CRITERIA=ALPHA(.05) /DESIGN=bio_gp drug_gp bio_gp*drug_gp.
In fact, not all these statements are necessary if you wanted to reproduce the pull-down menu. You could get away with just:
UNIANOVA bp BY bio_gp drug_gp /EMMEANS=TABLES(bio_gp) /EMMEANS=TABLES(drug_gp) /EMMEANS=TABLES(bio_gp*drug_gp)
The output is as follows:
4
Univariate Analysis of Variance
Tests of Between-Subjects Effects Dependent Variable:bp Source Type III Sum of Squares Df Mean Square F Sig. Corrected Model 6552.000 a 5 1310.400 9.593 .000 Intercept 1340964.000 1 1340964.000 9816.720 .000 bio_gp 1296.000 1 1296.000 9.488 .004 drug_gp 4104.000 2 2052.000 15.022 .000 bio_gp * drug_gp 1152.000 2 576.000 4.217 .024 Error 4098.000 30 136.600 Total 1351614.000 36
Corrected Total 10650.000 35 a. R Squared = .615 (Adjusted R Squared = .551)
You will note that the ANOVA output and means are identical to the omnibus SAS output in the program demonstrating simple effects analyses and interaction contrasts. You can disregard the intercept source above (representing modeling of the effect of grand mean). The key effects here are the two main effects for bio_gp and drug_gp and the bio_gp*drug_gp interaction term.
Main Effect Comparisons: Pairwise Comparisons There are several different ways to do main effect comparisons in SPSS, some of which can be surprisingly tedious and complex. Pairwise comparisons, though, are pretty simple.
Individual Pairwise Comparisons (Unadjusted for Multiplicity) Lets start with comparisons un-adjusted for multiplicity (e.g., if you were just doing one contrast). One good way for you to go is to use the syntax editor. Specify the contrast as part of the EMMEANS option. For example, lets say we want to do all pairwise comparisons among the 3 drug groups. Your code would look like this:
GLM bp by bio_gp drug_gp /EMMEANS TABLES (drug_gp) COMPARE(drug_gp).
6
Youll see in the output the results of pairwise comparisons among the three drug groups:
Pairwise Comparisons Dependent Variable:bp (I) drug_ gp (J) drug_ gp Mean Difference (I- J) Std. Error Sig. a
*. The mean difference is significant at the .050 level.
a. Adjustment for multiple comparisons: Least Significant Difference (equivalent to no adjustments).
You can see that drug group 1 (i.e., drug X) differs significantly from group 2(Y) and 3 (Z) but that groups 2 and 3 dont differ.
Theres another way to do this too. You could just use the pull-down menu, go to post-hoc contrasts (I know this sounds weird), specify LSD contrasts but just ignore the results of the overall ANOVA. The idea here is to just get out the results of individual contrasts with an individual per comparison type 1 error rate of .05. The key strokes are Analyze >> General Linear Models >> Univariate >> Enter DV and Fixed Factors if you havent done so >> Post Hoc >> LSD >>Continue >> Continue
Multiple Pairwise Comparisons Pairwise comparisons corrected for multiplicity are easy. Just use the pull-down menu. The key strokes are Analyze >> General Linear Models >> Univariate >> Enter DV and Fixed Factors if you havent done so >> Post Hoc. Then you will see this menu:
7
Click on the factor of interest (here drug_gp) and indicate the post-hoc tests you want (e.g., Bonferroni, Tukey, Scheffe). Then hit Continue, and then OK and you will get the MC results in addition to the results of the ANOVA. You should be able to interpret the output clearly. For example, below is the output of the Tukey test for these data:
3 1 21.0000 * 4.77144 .000 9.2371 32.7629 2 -3.0000 4.77144 .806 -14.7629 8.7629 Based on observed means. The error term is Mean Square(Error) = 136.600.
*. The mean difference is significant at the 0.05 level.
Homogeneous Subsets bp Tukey HSD drug_gp N Subset 1 2 1 12 178.0000 3 12 199.0000 2 12
202.0000 Sig. 1.000 .806 Means for groups in homogeneous subsets are displayed. Based on observed means. The error term is Mean Square(Error) = 136.600. As you can see group 1 differs from groups 2 and 3 but the latter two dont differ from each other. Main Effect Comparisons: Complex Comparisons Individual Complex Comparisons Specifying complex comparisons with SPSS is harder than you might expect. There are two main ways to do this and theyre both pretty tricky. Let me show you the method I think will be easiest for you. Im not going to explain why this works this is simply a how-to, cookbook approach (though I certainly DO assume you know comparisons at well more than a cookbook level). Really understanding why this works probably requires a class in linear models and/or multivariate analysis.
Lets say we wanted to do the complex contrast comparing the mean of drug groups 1 and 2 to drug group 3. Our contrast coefficients could be 1 1 -2. I would do this using the MANOVA command in the syntax editor. The key thing is to use the CONTRAST option and to specify 9
what SPSS calls a SPECIAL contrast because its not one of their standard defaults. The key thing here is that you have to create a square matrix of coefficients with the numbers of rows and columns equal to the number of marginal means associated with the factor of interest. Here that number = 3. So you need a 3 X 3 matrix. The first row of this matrix must be all 1s (NOT the contrast youre interested in). Make the second row the coefficients of the contrast youre interested in. Make the third row the coefficients of an additional contrast (often the best choice here is a contrast thats orthogonal to the first but that need not be the case). Obviously if you have a second contrast of interest then use it for row 3. If you have 4 groups you need to enter a 4 X 4 matrix with all rows being 1s, then put three contrasts in rows 2-4 and make sure one of them is the contrast youre interested in.
The overall syntax here is this:
MANOVA bp by bio_gp (1,2) drug_gp (1,3) /ERROR = W /Contrast(drug_gp) = SPECIAL (1 1 1 1 1 -2 1 -2 1).
As you can see, were using the MANOVA command that denotes the dv and the two factors (including information about the levels of each factor (i.e., from 1 to 2 and from 1 to 3). Put ERROR=W to make sure the MSW is used as the error term. Then put in the Contrast statement. Note how row 2 is our contrast of interest (1 1 -2). I put in a second complex contrast in the third row as well. If you run this you get the following output:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Here its kind of hard to find what you want. However, the key thing here are the parameters for drug_gp. The first one shown (# 3 in bold) is the one for our contrast of interest. In fact, if you use the contrast coefficients of 1, 1, and -2 and the marginal means, you will find that the value of the contrast is -18. You will see the associated t statistic and p value.
Multiple Complex Comparisons. You can use the general approach noted above when you have multiple complex comparisons or a combination of complex and pairwise comparisons. Note here that your typical alternatives will be Bonferroni or Scheffe. If its Bonferroni, just use the general approach described above (you might have to run more than one MANOVA to get all the contrasts in) and note the critical per comparison t and alpha levels youre shooting for. If youre doing Scheffes, take the t value shown in the SPSS output and square it to get your observed F. Then compare it to the Scheffe critical value = (df for the main effect of interest) X critical F for that effect for the overall ANOVA at alpha = .05.
Simple Effects Analyses Its fairly easy to run simple effects analyses using SPSS. Again use the syntax editor. Lets say we want to estimate the simple effects of drug at biofeedback. That is, we want to compare the three drug groups at biofeedback present and absent. To do this, use the following code:
GLM bp by bio_gp drug_gp /EMMEANS Tables (bio_gp*drug_gp) Compare(drug_gp).
11
At the bottom of the output, youll see the simple effects F tests:
Univariate Tests Dependent Variable:bp bio_gp Sum of Squares Df Mean Square F Sig. 1 Contrast 3924.000 2 1962.000 14.363 .000 Error 4098.000 30 136.600 2 Contrast 1332.000 2 666.000 4.876 .015 Error 4098.000 30 136.600 Each F tests the simple effects of drug_gp within each level combination of the other effects shown. These tests are based on the linearly independent pairwise comparisons among the estimated marginal means. This result is identical to what we computed by hand and via SAS. Interaction Contrasts To do interaction contrasts in SPSS, I would again use the syntax editor and use a specification thats similar to what you would use with SAS. Below is the syntax for specifying the interaction contrast between drugs x and y and biofeedback. The key thing here is to note something similar that I noted for SAS. Note how in the GLM statement bio_gp appears first. This means that it moves more slowly. So that the six cells in order in the LMATRIX portion are bio present/X, bio present/Y, bio-present Z, bio_absent/X, bio_absent Y, bio_absent Z.
GLM bp by bio_gp drug_gp /LMATRIX = 'x vs y by biofeedback interaction contrast' bio_gp*drug_gp 1 -1 0 -1 1 0.
The key thing here is to note something similar that I noted for SAS. Note how in the GLM statement bio_gp appears first. This means that it moves more slowly. So that the six cells in order in the LMATRIX portion are bio present/X, bio present/Y, bio-present Z, bio_absent/X, bio_absent Y, bio_absent Z. Another way to think of this that might be easier because it retains the 2-dimensional row X column format is that biofeedback conditions constitute the rows (because they come first in the by statement and drug_gp constitutes the columns. For example, we could rewrite the LMATRIX statement above in the following manner:
GLM bp by bio_gp drug_gp /LMATRIX = 'x vs y by biofeedback interaction contrast' bio_gp*drug_gp 1 -1 0 -1 1 0.
Either way will work. The output is as follows:
12
Contrast Results (K Matrix) a
Contrast Dependent Variable bp L1 Contrast Estimate -24.000 Hypothesized Value 0 Difference (Estimate - Hypothesized) -24.000 Std. Error 9.543 Sig. .017 95% Confidence Interval for Difference Lower Bound -43.489 Upper Bound -4.511 a. Based on the user-specified contrast coefficients (L') matrix: x vs y by biofeedback interaction contrast
Test Results Dependent Variable:bp Source Sum of Squares df Mean Square F Sig. Contrast 864.000 1 864.000 6.325 .017 Error 4098.000 30 136.600
The results for this contrast are identical to what we observed for SAS. Non-orthogonal ANOVA Remember that for non-orthogonal ANOVAs you will have the choice of Type 1 or Type 3 SS approaches. The default in SPSS will be Type 3 SS. If you want to use Type 1, just use the pull- 13
down menu. The key strokes are Analyze >> General Linear Models >> Univariate Enter DV and Fixed Factors if you havent done so >> Model. You will see the following menu:
Just enter Type 1 in the SS box. Then hit Continue and OK. This would be equivalent to the following statements in the syntax editor:
Theorell, T., & Karasek, R. A. (1996) - Current Issues Relating To Psychosocial Job Strain and Cardiovascular Disease Research. Journal of Occupational Health Psychology, 1 (1), 9-26.
Auditors' Behaviour in An Audit Conflict Situation A Research Note On The Role of Locus of Control and Ethical Reasoning 1996 Accounting, Organizations and Society