Three-Way Analyses of Variance Containing One or More Repeated Factors We have already covered the one-way repeated measures design and the A x (B x S) design. I shall not present computation of the (A x B x S) totally within-subjects two-way design, since it is a simplification of the (A x B x C x S) design that I shall address. If you need to do an (A x B x S) ANOVA, just drop the Factor C from the (A x B x C x S) design. A X B X (C X S) ANOVA In this design only one factor, C, is crossed with subjects (is a within-subjects factor), while the other two factors, A and B, are between-subjects factors. Howell (page 470 of the 8th edition of Statistical Methods for Psychology) presented a set of data with two between-subjects factors (Gender and Group) and one within-subjects factor (Time). One group of adolescents attended a behavioral skills training (BST)program designed to teach them how to avoid HIV infection. The other group attended a traditional educational program (EC). The dependent variable which we shall analyze is a measure of the frequency with which the participants used condoms during intercourse. This variable is measured at four times: Prior to the treatment, immediately after completion of the program, six months after completion of the program, and 12 months after completion of the program. SAS Obtain the data file, MAN_1W2B.dat, from my StatData page and the program file, MAN_1W2B.SAS, from my SAS programs page. Note that the first variable is Gender, then Group number, then dependent variable scores at each level (pretest, posttest, 6 month follow-up, and 12 month follow-up) of the within-subjects factor, Time. “Group|Gender” factorially combines the two between-subjects factors, and “Time 4” indicates that the variables Pretest, Posttest, FU6, and FU12 represent the 4-level within-subjects factor, Time. By not specifying “NOUNI” I had SAS compute Group|Gender univariate ANOVAs on Pretest, Posttest, FU6, and FU12 . These provide the simple interaction tests of GroupGender at each level of Time that we might use to follow-up a significant triple interaction, but our triple interaction is not significant. However, our TimeGroup interaction is significant, so we can use these univariate ANOVAs for simple main effects tests of Group at each level of Time. Note that the groups differ significantly only at the time of the 6 month follow-up, when the BST participants used condoms more frequently (M = 18.8) than did the EC participants (M = 8.6). Mauchly’s criterion shows that we have no problem with the sphericity assumption. Both multivariate and univariate tests of within-subjects effects show that the only such effect which is significant is the Time x Group interaction, for which we have already inspected the simple main effects of group at each time. Among the between-subjects effects, only the main effect of gender is significant. Since this effect is across all levels of the time variable, we need to collapse across levels of time to get the appropriate means on which female participants differed from male participants. If you look in the data step, you will see that I used the MEAN(OF....) function to compute, for each participant, mean condom use across times. While we could use proc means by gender to compute the relevant means, I used PROC ANOVA instead, doing a Gender x Group ANOVA and asking for means. I did this to demonstrate to you that the test on gender in the earlier analysis was a test of the difference between genders on mean condom use collapsed across times. Notice that the F statistic for the Copyright 2013, Karl L. Wuensch - All rights reserved. MAN_RM3.docx Page 2 effect of gender on mean condom use, 6.73, is identical to that computed in the earlier analysis. The means show that male participants reported using condoms during intercourse more than did female participants. Although we followed the significant Time x Group interaction with an analysis of the simple main effects of group at each time, we could have chosen to test the simple main effects of time in each group. The last invocation of PROC ANOVA does exactly that, after sorting by group. Additionally, I requested contrasts between the pretest and each post-treatment measure. Using individual error terms, the omnibus analysis indicates that the use of condoms in the BST group did not change significantly across time. One could elect to ignore that analysis and look instead at the specific contrasts -- after all, if the treatment was effective and had a lasting effect, mean condom use at all three times after treatment should be higher than prior to treatment, but could be approximately equal to one another across those post-treatment times, diluting the effect of the time variable and leading to an omnibus effect that falls short of significance. Those contrasts show that condom use among the BST participants was significantly greater at the six month follow-up (M = 18.8) than at the time of the pretest (M = 13.45). Among the members of the EC control group, mean condom use did change significantly across time. The specific contrasts shows that mean condom use in this group at the time of the six month follow-up was significantly less (M = 8.6) than at the time of the pretest (M = 19.8). Here is an interaction plot of the changes in condom use across time for the two groups. Annotated SAS Output SPSS: Point and Click Obtain the SPSS data file MAN_1W2B.sav from my SPSS data page. Bring it into SPSS. Analyze, General Linear Model, Repeated Measures. Define repeated factor “Time(4)” with variables “pretest,” “posttest,” “fu6,” and “fu12.” Scoot “gender” and “group” into the “Between-Subjects Factor(s)” box. Click “Plots.” Scoot “Time” into the “Horizontal Axis” box and “group” into the “Separate Lines” box. Click “Add,” “Continue.” Click “Options.” Scoot “gender” and “group*Time” into the “Display means for” box. Click “Continue,” “OK.” As before, you will find a significant main effect of gender and a significant Time x Group interaction. Page 3 To test the simple main effect of the grouping variable at each level of time do this: Click “Analyze,” “General Linear Model,” “Univariate.” Scoot “pretest” into the “Dependent Variable” box and “gender” and “group” into the “Fixed Factor(s)” box. Click “OK.” Look only at the effect of groups – gender was included in the model only to remove its effect from what otherwise would be error variance. You will see that the groups did not differ significantly on the pretest. Now go back to the “Univariate” window and replace “pretest” with “posttest” and click “OK.” Again, the difference is not significant. Compare the groups on “fu6” (significant) and “fu12” (not significant) in the same way. To test the simple main effect of time within each group do this: Click “Data,” “Split File.” Select “Organize output by groups” and “Sort the file by grouping variables.” Scoot “group” into the “Groups Base on” box. Click “OK.” Click “Analyze,” “General Linear Model,” “Repeated Measures.” Click “Define.” Remove “group” and “gender” from the “Between Subjects Factor(s)” box. Click “Contrasts.” Change the contrast to “Simple,” with “First” being the reference category (to compare pretest scores with each of the other times). Click “Continue,” “OK.” Sphericity is not a problem in either group, so you are free to use the unadjusted univariate results. You will find that the changes across time fell short of statistical significance in the BST group but were significant in the ECU group (where frequency of use of condoms declined across time). To make pairwise comparisons within the ECU you could create the necessary difference scores and for each test the null that the mean difference score in the population is zero. If you are afraid of the Type I boogie man under the bed, you can apply a Bonferroni adjustment. SPSS MANOVA Syntax Obtain the SPSS data file MAN_1W2B.sav from my SPSS data page. Bring it into SPSS and then paste the following code into the syntax window and run the program: manova pretest to fu12 by gender(0,1) group(1,2) / wsfactors = time(4) / print=error(cor) homogeneity(boxm) / design . manova pretest to fu12 by gender(0,1) group(1,2) / wsfactors = time(4) / wsdesign = mwithin time(1) mwithin time(2) mwithin time(3) mwithin time(4) / design . manova pretest to fu12 by gender(0,1) group(1,2) / wsfactors = time(4) / wsdesign = time / design = mwithin group(1) mwithin group(2) . The first invocation of MANOVA reproduces the omnibus analysis we did earlier with SAS. The second invocation reproduces the simple main effects of group at each time. The third invocation tests the simple main effects of time within each group, using pooled error, but with the same disappointing results obtained by SAS. Our analysis does not, it seems, provide much support for the BST program’s effectiveness. A X (B X C X S) ANOVA In this design, factors B and C are crossed with Subjects (B and C are within-subjects factors) and Subjects is nested within factor A (A is a between-subjects factor). Our data are for the conditioned suppression experiment presented on page 486 of Howell (8th edition). The dependent variable is a measure of the frequency of bar pressing (for food) for an animal (rat?) in an experimental box. During the first phase of the experiment, each animal was placed in box A and, while the animal was bar pressing, a tone (or, in Group L-A-B a light) was presented and paired with shock during each of four cycles. During the second phase of the experiment, animals in Group L-AB and Group A-B were tested in a different box, where the tone stimulus was presented without the shock. It was expected that the tone would initially suppress bar pressing in these animals (but only somewhat in the group for which shock had been paired with a light rather than with a tone), but that they would learn, across cycles, that box B was safe, and the rate of bar pressing would rise. Group Page 4 A-A, however, was tested in box A during the second phase. It was expected that they would show low rates of bar pressing across the four cycles of the second phase of the experiment. SAS Obtain the data file, MAN_2W1B.DAT from my StatData page and the program file, MAN_2W1B.SAS, from my SAS programs page. Note that the first column of the data file contains the level of the Group variable (between-subjects) followed by subjects’ scores on Cycle-1/Phase-1, Cycle-1/Phase-2, Cycle-2/Phase 1, . . .Cycle-4/Phase-2. We have 4 x 2 = 8 cells in the matrix of repeated factors, represented by 8 dependent variables, C1P1 through C4P2, in the INPUT and MODEL statements. The REPEATED statement indicates that we have two within-subjects factors, CYCLE with 4 levels, PHASE with 2 levels. The comma separating one within-subject factor from another must be there. The order of the dependent variables is very important: The further to the right a repeated factor is in the REPEATED statement, the more rapidly its index values must change. Phase, the rightmore factor, changes more rapidly (1,2,1,2,1,2,1,2) than does Cycle, the leftmore factor (1,1,2,2,3,3,4,4). Check the “REPEATED MEASURES LEVEL INFORMATION” output page to assure that the within-subjects factors are properly defined. The output shows that there is no problem with the sphericity assumption for the Cycle effect, but there is for the Cycle x Phase interaction, so we need adjust the degrees of freedom for any effect that includes CyclePhase if we use the univariate approach. Since the Phase effect has only two levels, we have no sphericity assumption with respect to Phase. The main effect of the Group variable falls short of statistical significance, but all other effects are statistically significant with both univariate and multivariate tests (although for CyclePhase only if you accept Roy’s greatest root). Do note that the multivariate and univariate analyses return identical results for the one df Phase effect, F(1, 21) = 129.86, p < .0001. The multivariate approach analyzes a K-level within-subjects factor by creating K-1 difference-scores and doing a MANOVA on that set of difference-scores. With K = 2 there is only one difference-score variable, so the MANOVA simplifies to an ANOVA on that difference-score, and both simplify to a correlated t-test (t-squared equals F), a one-sample t-test of the null hypothesis that the mean difference-score is zero. For the Phase*Group effect both multivariate and univariate approaches simplify to a one-way ANOVA where IV = Group and DV = the difference score. Simple effects The significant three-way interaction would likely be further investigated by simple interaction analyses. With SAS you could sort by group and then do two-way ANOVAs involving the other two factors by level of group, doing three (A x B x S) ANOVAs. Below I show how to do simple effects analysis at levels of within-subjects factors with individual error terms. If you wanted pooled rather than individual error terms, you would need construct them yourself. With SPSS MANOVA, “MWITHIN” could be used to construct simple effects, as explained when we covered the A x (B x S) analysis. Howell chose to evaluate the simple Group x Cycle interaction at each level of Phase. Look at the program to see how I did this by dropping variables from the left side of the model statement. Notice that nothing is significant during the first phase. The prediction was that all groups would show high suppression on all cycles during the shock phase (1), but that during the non-shock phase (2) Group 2 (A-A) should show more suppression (lower scores) than the other groups, with the difference between Group 2 and the other groups increasing across cycles. Given this prediction, one expects no effects at all for the data from the first phase and a Cycle x Group interaction for the data from the second phase -- and that is exactly what we get. Page 5 Simple, simple main effects The following plot illustrates the change in bar pressing across cycles in the second phase of the experiment. As expected, the animals in Group A-A exhibited conditioned suppression of bar pressing across all four cycles, but the animals in Group A-B apparently learned that box B was safe, since their bar pressing ratio increased across cycles. Group L-A-B showed less conditioned suppression than the other groups, but also showed a recovery of bar pressing across cycles. This graph is probably more useful than the tests of simple, simple main effects, but the Gods of Hypothesis Testing demand that we kneel at the alter of significance and offer up some p values, so we shall. Knowing that the Group x Cycle simple interaction was significant during the second phase, I dropped “nouni” from the model statement to get simple, simple main effects of Group at each level of Cycle for the data from the second phase. I also asked for LSD pairwise comparisons. This analysis shows that the groups did not differ significantly on the first cycle, but they did on the remaining three cycles, with the mean for Group A-A being significantly lower than those of Groups A-B and L-A-B. An alternative, perhaps better, way to dissect the significant Group x Cycle interaction for the data from the second phase is to evaluate the simple, simple main effects of Cycle at each level of Group (after sorting the data by group). I have included such an analysis, and it shows exactly what was predicted, a significant increase in bar pressing across cycles in Groups A-B and L-A-B (with the univariate test), but not in Group A-A. I did no pairwise comparisons here, as I decided they would not add anything of value. Annotated SAS Output SPSS: Point and Click Bring into SPSS the data file MAN_2W1B.sav. Click Analyze, General Linear Model, Repeated Measures. In the “Within-Subject Factor Name” box, enter “cycle.” For “Number of Levels” enter “4.” Click Add. In the “Within-Subject Factor Name” box, enter “phase.” For “Number of Levels” enter “2.” Click Add and then Define. Select c1p1 through c4p2 and scoot them into the Page 6 “Within-Subjects Variables” box. Select group and scoot it into the “Between-Subjects Factor(s)” box. Click OK. You will find that you get the same basic statistics that we got with SAS, along with trend contrasts. Return to the main Repeated Measures dialog box. Remove phase as a factor. Define as the within-subjects variables c1p1, c2p1, c3p1, and c4p1. Leave group as a between-subjects factor. Click OK. Then return to the main Repeated Measures dialog box and Define as the within-subjects variables c1p2, c2p2, c3p2, and c4p2. Click OK. You now have the simple effects at each level of the phase variable. Click Analyze, Compare Means, One-Way ANOVA. Scoot into the Dependent List c1p2, c2p2, c3p2, and c4p2. Select group as the factor. Click Post Hoc, LSD, Continue, OK. You now have the simple, simple main effects of group at each level of cycle for the second phase. Go to the Data Editor and click Data, Split File, “Organize output by groups.” Select group for “Groups based on,” and sort the file by the grouping variables. Click OK. Click Analyze, General Linear Model, Repeated Measures. Remove group as a Between-Subjects Factor, but leave c1p2, c2p2, c3p2, and c4p2 as the Within-Subjects Variables. Click OK. You now have the simple main effects of cycle for each group during phase 2. SPSS: MANOVA Syntax If you prefer to do the analysis with MANOVA, here is the syntax to get you started: manova c1p1 to c4p2 by group(1,3) / wsfactors = cycle(4) phase(2) / print=error(cor) / design . (A X B X C X S) ANOVA In this design Subjects is crossed with all three independent variables. Our data are for the automobile driving experiment presented on page 511 of the 5th edition of Howell. The dependent variable is number of steering errors. Factor T is the time of testing, 1 for night and 2 for day. Factor C is type of course, 1 for a road racing track, 2 for city streets, and 3 for open highways. Factor S is size of car, 1 for small, 2 for medium, and 3 for large. SAS Obtain the program file, MAN_3W.SAS, from my SAS programs page. The data are within the program. I have labeled parts of the program with the letters A through L for easy reference. As in the A x (B x C x S) ANOVA we did earlier, the order of the repeated factors is important. Note that they are arranged with factors to the right changing index values faster than factors to their left. The omnibus analysis is done by part [ E ] of the program. The significant effects are time, course, size, and Time x Size. I eliminated my usual request for a test of the sphericity assumption, since there are too few subjects to conduct such tests. Also note that there are too few subjects to do a complete factorial multivariate analysis. SAS does do a complete univariate analysis. Since there was a significant main effect of course, we want to obtain the marginal means for course, and we may also want to make pairwise comparisons among those marginal means. The first three lines in part [A] were used to compute, for each subject, the mean number of steering errors on each type of course, collapsed across time and size. As an example, look carefully at the computing of “c1.” I computed the mean of all of the variables that included “C1” in its name (that is, which was a score from the road racing track). The last line in that section of the program computes three difference scores: One for comparing errors on the road course with those on the city streets, Page 7 another for road course versus open highway, and the third for city streets versus open highway. These will used to make pairwise comparisons among the marginal means In part [B] I computed, for each subject, mean number of errors for cars of each size and then the difference scores needed to make pairwise comparisons. In part [C] I computed, for each subject, the mean number of errors in each of the four cells for Time x Size. Below I have plotted the means of these means, to illustrate the significant Time x Size interaction. Parts [ F through H ] conduct the tests of the simple main effects of time at levels of size of the car. Each of the simple effects is significant, with more steering errors made at night than during the day. As shown in the plot, the effect of time of day is greater in the small and medium sized cars than in the large cars. Part [ I ] computes the marginal means for type of course and size of car, as well as the means for the plot above. Steering errors more most likely on the road course and least likely on the open highway. Errors were most likely in the small car and least likely in the large car. Parts [ J ] and [ K ] are included only for pedagogical purposes -- they show that we can obtain the tests of the significance of the main effects from the means we computed, for each subject, for type of course and size of car. Part [ L ] uses PROC MEANS to conduct correlated t tests for our pairwise comparisons between marginal means on the type of course and size of car variables. Every one of the pairwise comparisons is significant. Annotated SAS Output SPSS: Point and Click Bring MAN_3W.sav (from my SPSS data page) into SPSS. Click Analyze, General Linear Model, Repeated Measures. Create three within-subjects factors, “Time(2),” “Course(3),” and “Size(3).” Highlight “Time(2)” and click “Define.” In the “Repeated Measures” box, CTRL-A in the left pane to select all of the variables. Scoot them into the “Within-Subjects Variables” box. Click “Plots.” Scoot “Time” into the “Horizontal Axis Box” and “Size” into the “Separate Lines” box. Click “Add,” “Continue.” Page 8 Click “Options.” Ask for estimated marginal means for “Time,” “Course,” “Size,” and “Time*Size.” Check “Compare main effects” and select “LSD(none).” Click “Continue,” “OK.” To test the simple effects of Time for each size of car, do this: Click Analyze, General Linear Model, Repeated Measures. Select “Size(3)” and click “Remove.” Select “Time” and click “Define.” Click “Reset.” Enter into the “Within-Subjects Variables” box all of those variables ending in “s1,” as shown to the right. Click “Continue,” “OK.” Look only at the effect of Time. The output shows that this effect is significant for these small cars. For effect of time on medium-sized cars use variables that end in “s2,” and for the effect on large cars use variables that end in “s3.” You will find that the effect of Time is significant for each size of car. As shown by the plot, the effect of time is larger for small and medium-sized cars than for large cars. SPSS MANOVA Syntax Here is a short SPSS MANOVA program that will do the omnibus analysis and obtain the simple effects of time at each level of size. The data are in the file MAN_3W.sav on my SPSS data page. manova T1C1S1 to T2C3S3 / wsfactors = Time(2) Course(3) Size(3) / noprint=signif(multiv) / design . manova T1C1S1 to T2C3S3 / wsfactors = Time(2) Course(3) Size(3) / wsdesign = time within size(1) time within size(2) time within size(3)/ design . Yet Higher Order Models You should be able to extrapolate from the examples above to construct the programs for higher order analyses -- but if you are intending to tackle a factorial design with more than 3 factors, I recommend that you first be evaluated by one of our clinical faculty -- you may have taken leave of your senses! Copyright 2013, Karl L. Wuensch - All rights reserved.