Lab Topic: Using SPSS Special Contrasts Part 1: Repeated Measures ANOVA Picking up on last week’s RM ANOVA, we ran a two-way repeated measures ANOVA where subjects rated a course they liked on four dimensions and a course they disliked on four dimensions. We found that the two-way interaction evidently had something to do with more variability for courses that were disliked, across dimensions (simple main effects analysis). Picking up from here, we can use SPSS syntax, specifically the MMATRIX subcommand, to help further isolate the source of the interaction. Looking at the graph below (and legend denoting which numbers on the x-axis correspond to which dimensions), we might first want to test whether, for disliked courses, course value is significantly different from the other three dimensions. The contrast (null hypothesis) would look something like this: Dvalue*3 drapport*-1 dgrading*-1 dorganize*-1 = 0. If this were significant, we might want to also test rapport vs. grading, rapport vs. organization, and grading vs. organization to find out whether the three means previously grouped together differ significantly among one another. Using the MMATRIX subcommand in SPSS, we can test these directly by adding the following syntax (just above the WSDESIGN subcommand) /MMATRIX = 'd-value v othr' dvalue 3 drapport -1 dgrading -1 dorganize -1; 'd-rapport v grade' drapport 1 dgrading -1; 'd-rapport v org' drapport 1 dorganize -1; 'd-grade v org' dgrading 1 dorganize -1 Note that each hypothesis contains a brief label (in tick marks) and each contrast is separated by a semi-colon. The full syntax will run the overall ANOVA. TITLE 'SETE Dimension by Course - Two-Way RM ANOVA'. GLM rapport drapport grading dgrading organize dorganize value dvalue /WSFACTOR = dimens 4 Polynomial course 2 Polynomial /METHOD = SSTYPE(3) /PLOT = PROFILE( dimens*course ) /EMMEANS = TABLES(OVERALL) /EMMEANS = TABLES(dimens) /EMMEANS = TABLES(course) /EMMEANS = TABLES(dimens*course) /PRINT = DESCRIPTIVE ETASQ OPOWER /CRITERIA = ALPHA(.05) /MMATRIX = 'd-value v othr' dvalue 3 drapport -1 dgrading -1 dorganize -1; 'd-rapport v grade' drapport 1 dgrading -1; 'd-rapport v org' drapport 1 dorganize -1; 'd-grade v org' dgrading 1 dorganize -1 /WSDESIGN = dimens course dimens*course . Estimated Marginal Means of MEASURE_1 course 1 2 Estimated Marginal Means 5 4 3 2 1 2 3 4 dimension Within-Subjects Factors Measure: MEASURE_1 course 1 2 dimension 1 Dependent Variable rapport 2 grading 3 value 4 organize 1 drapport 2 dgrading 3 dvalue 4 dorganize Part 2: Groups x Trials (Randomized x Repeated, Split Plot Factorial, etc.): Now we’ll use an example taken from class. This is where people are assigned to read one of three types (genre) of books, and the number of books read over three months serves as the DV. The data yield a significant genre*time interaction, which can be seen in the plot below. It appears that the pattern for science fiction is much different than the one for mystery and romance, which seem very similar. Thus, let’s check to see whether science fiction differs from mystery and romance combined, for each of the three months. To do this, we need to incorporate a between subjects matrix, which in SPSS is the “L” matrix (M Matrix is for repeated measures designs). The easiest way to do this is to specify the GLM the way you want it, requesting all the options you wish, then pasting and adding “GEF” to the /PRINT subcommand. This prints the “general estimable function”, which gives you a clue as to how SPSS is treating the between subjects variable. Estimated Marginal Means of MEASURE_1 genre 7.00 science fiction mystery romance Estimated Marginal Means 6.00 5.00 4.00 3.00 2.00 1.00 1 2 3 month The output for GEF gives us a number of things we don’t care about, but the following table is important as it tells us that genre=1 (science fiction) is in the first position in the LMATRIX, genre=2 (mystery) is in the second, etc. General Estimable Function(a) Contrast Parameter Intercept L1 L2 L3 1 0 0 [genre=1.00] 0 1 0 [genre=2.00] 0 0 1 [genre=3.00] 1 -1 -1 a Design: Intercept+genre Within Subjects Design: month We now have what we need to construct our contrast. We’ll begin with month one. We use the following two lines of syntax to construct our contrast. /LMATRIX = "genre @ m1" genre 2 -1 -1 /MMATRIX = 'w-in m1' month1 1 month2 0 month3 0; This tells SPSS that we want to contrast science fiction (coefficient of 2) against mystery and romance together (each getting a coefficient of -1). The second part, MMATRIX tells it that we want to do it for month1, and that month2 and 3 are to be left out of the test (because they get coefficients of zeros). Hopefully people will recognize that we could do something more complicated here, by, say comparing science fiction to the other two genres for months 1 & 2 combined, if we so desired. Once we have done this, we can run it and go back and change the MMATRIX line to read: /MMATRIX = 'w-in m1' month1 0 month2 1 month3 0; And again to… /MMATRIX = 'w-in m1' month1 0 month2 0 month3 1; To test both the 2nd and third months respectively. Since the first month isn’t significant, we would likely just test the third month and be finished. The main point here is that the LMATRIX and MMATRIX commands work together to perform the contrast we are looking for. The full syntax looks as follows (depending upon which options were chosen): GLM month1 month2 month3 BY genre /WSFACTOR = month 3 Polynomial /METHOD = SSTYPE(3) /PLOT = PROFILE( month*genre ) /EMMEANS = TABLES(OVERALL) /EMMEANS = TABLES(genre) /EMMEANS = TABLES(month) /EMMEANS = TABLES(genre*month) /PRINT = PARAMETER GEF /CRITERIA = ALPHA(.05) /WSDESIGN = month /LMATRIX = "genre @ m1" genre 2 -1 -1 /MMATRIX = 'w-in m1' month1 1 month2 0 month3 0; /DESIGN = genre . Note, I have not figured out a way to test all three contrasts in one run. It only uses the final one each time, but I am sure there is a way and I just didn’t crack the code yet. Part 3: Between Subjects Contrasts We will now return to the drug interaction example from a few weeks ago in lab. For this example, we had drug A and drug B, with three levels each, and we were testing to see whether there was an interaction between the two. The plot of the resultant interaction follows. Again, we have to use the LMATRIX subcommand and we can add a statement to the /PRINT subcommand to get some basic information. Adding “TEST(LMATRIX)” to the end of the existing /PRINT statement gives us several additional tables. We are interested in three matrices, FACTORA, FACTORB, and FACTORA x FACTORB. Factor A and Factor B matrices are straight forward, they have three elements, 1, 2 & 3, each which correspond to how our data are entered (three levels of each drug). The interaction matrix is more important and is pasted below. Estimated Marginal Means Estimated Marginal Means of anxiety 20.00 FactorB 18.00 1.00 2.00 3.00 16.00 14.00 12.00 10.00 8.00 6.00 1.00 2.00 3.00 FactorA FactorA * FactorB Contrast Parameter Intercept L8 L9 L11 L12 0 0 0 0 [FactorA=1.00] 0 0 0 0 [FactorA=2.00] 0 0 0 0 [FactorA=3.00] 0 0 0 0 [FactorB=1.00] 0 0 0 0 [FactorB=2.00] 0 0 0 0 [FactorB=3.00] 0 0 0 0 [FactorA=1.00] * [FactorB=1.00] 1 0 0 0 [FactorA=1.00] * [FactorB=2.00] 0 1 0 0 [FactorA=1.00] * [FactorB=3.00] -1 -1 0 0 [FactorA=2.00] * [FactorB=1.00] 0 0 1 0 [FactorA=2.00] * [FactorB=2.00] 0 0 0 1 [FactorA=2.00] * [FactorB=3.00] 0 0 -1 -1 [FactorA=3.00] * [FactorB=1.00] -1 0 -1 0 [FactorA=3.00] * [FactorB=2.00] 0 -1 0 -1 [FactorA=3.00] * [FactorB=3.00] 1 1 1 1 The default display of this matrix is the transpose of the corresponding L matrix. Based on Type III Sums of Squares. We aren’t interested in the contrasts L8, L9, etc. We are interested in the elements with asterisk signs (which actually appear in the SPSS output). Because we have a 3x3 design, we have 9 elements in this matrix, one for each cell. The entries with asterisks tell us the order. The first element is Factor AB11, followed by AB12, then AB13. Looking at the graph, we probably want to look at contrasts involving level 3 of A and all levels of B (within A3). Thus, with our first contrast, let’s compare level 1 & 3 of factor B (the two points furthest apart) with each other, ignoring AB23 for now. The following /LMATRIX subcommand accomplishes this. /LMATRIX = "B1 vs B3 at A3" FactorB 1 0 -1 FactorA*FactorB 0 0 0 0 0 0 1 0 -1; Note that with the first line I provide a label, with the second line I tell it we are contrasting level 1 & 3 of FactorB, and with the third line, I further tell it that this contrast is limited to level 3 of FactorA. To understand this, note that the first six entries are zeros. Consulting the AxB table above (looking at entries with asterisks), we see that the first six entries of the LMATRIX for AxB correspond to levels 1 & 2 of FactorA. The last three entries correspond to B1, B2, & B3 for A3, or AB31, AB32, and AB33. Since AB31 is assigned a 1, and AB33 a -1, and AB32 a zero, we are contrasting just AB31 vs. AB33. The result is that all three means are significantly different from each other at the highest dose of FactorA. As an exercise here, one might wish to compare the next biggest difference, AB12, versus AB13 & AB11 combined to see if that difference is significant. The full syntax for this particular run is as follows: TITLE 'two-way anova for drug interaction with LMATRIX Contrasts'. UNIANOVA anxiety BY FactorA FactorB /LMATRIX = "B1 vs B3 at A3" FactorB 1 0 -1 FactorA*FactorB 0 0 0 0 0 0 1 0 -1; /LMATRIX "B1 vs B2 at A3" FactorB 1 -1 0 FactorA*FactorB 0 0 0 0 0 0 1 -1 0; /LMATRIX "B2 vs B3 at A3" FactorB 0 1 -1 FactorA*FactorB 0 0 0 0 0 0 0 1 -1; /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /POSTHOC = FactorA FactorB ( QREGW ) /PLOT = PROFILE( FactorA*FactorB ) /EMMEANS = TABLES(OVERALL) /EMMEANS = TABLES(FactorA) /EMMEANS = TABLES(FactorB) /EMMEANS = TABLES(FactorA*FactorB) /PRINT = DESCRIPTIVE ETASQ OPOWER HOMOGENEITY TEST(LMATRIX) /CRITERIA = ALPHA(.05) /DESIGN = FactorA FactorB FactorA*FactorB .