Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Topic 11 – ANOVA II Balanced Two-Way ANOVA (Chapter 19)

Similar presentations


Presentation on theme: "1 Topic 11 – ANOVA II Balanced Two-Way ANOVA (Chapter 19)"— Presentation transcript:

1 1 Topic 11 – ANOVA II Balanced Two-Way ANOVA (Chapter 19)

2 2 Two Way ANOVA We are now interested the combined effects of two factors, A and B, on a response (note: text refers to these as R = rows and C = columns – we’ll call them A, B, and later C for a 3-way ANOVA). Examples:  Want to consider the effects of diet plan (Factor A) and exercise program (Factor B) on weight.  Want to consider the effects of a drug (Factor A) and a vitamin tablet (Factor B) on blood pressure.

3 3 Two Way ANOVA (2) Interested in a combination of the two factors; unlike blocking, both of primary interest. Could treat each combination of factors as a treatment and do one-way ANOVA, but then you have to use contrasts a lot in order to tests hypotheses of interest.

4 4 Two Way ANOVA (3) Interaction is a possibility. Replication is required to investigate interaction. You generally want at least two observations per treatment combination. You also generally want a balanced design (for this topic, we’ll assume cell sizes are equal).

5 5 Example (Problem 19.1) An animal experiment is designed to investigate whether the drug Levorphanol reduces stress as reflected in the cortical sterone level. It is also likely that Epinephrine (adrenaline) levels have some effect and there may be an interaction with the drug effect as well. Some animals were given a drug that raised their normal levels of Epinephrine.

6 6 Example (2) ControlLevorphanolEpinephrineBoth 1.90 1.80 1.54 4.10 1.89 0.82 3.36 1.64 1.74 1.21 5.33 4.84 5.26 4.92 6.07 3.08 1.42 4.54 1.25 2.57

7 7 Example (3) If we treat this as one-way ANOVA (which is not ideal in real life but useful here for instructional purposes), then we can design contrasts can be used to investigate the effects: ComparisonCLEB L effect E effect Interaction 1 1 111111

8 8 SAS Code (one-way)

9 9 SAS Output

10 10 Notes The three contrasts have a special property – they are “orthogonal”. Their sum is actually the model SS: 12.83 + 18.59 + 6.16 = 37.58. We see that there are distinguishable effects for both drugs, plus an interaction (F-tests). A significant interaction means that the size of the L effect is different at different levels of E (or equivalently, the size of the E effect is different for different levels of L); more later.

11 11 Two-Way ANOVA Break up the treatments into two factors. Factor 1: Levorphanol (Present / Absent) Factor 2: Epinephrine (High / Low) Investigates all combinations of the two factors Ep. Lev.LowHigh Absentxxxxx Presentxxxxx

12 12 Two-Way ANOVA (2) Rows / Columns of table represent levels of the factors. We have 5 observations at each combination of levels. Another way to view the design:

13 13 Output from interaction model Note: Type III SS will be the same, since balanced design.

14 14 Statistical Model a levels of Factor A; b levels of Factor B n observations per cell, so the total number of observations is nab. Usual basic assumptions: Independent & Normal Errors with Constant Variance.

15 15 Statistical Model (2)

16 16 Statistical Model (3) As before we think of all the effects in terms of deviation from the grand (overall) mean. We need parameter restrictions: SAS does things slightly differently – making mu the mean for the last treatment combination (labeled ab ), and setting any parameter with one of those levels to zero.

17 17 Statistical Model (4) Original ANOVA table (SAS) will have an “overall” F-test.  Simply tests whether ANY of the factors are significant.  Not particularly useful (unless insignificant) as it doesn’t differentiate between the factors. Because of this, we usually create an “extended” ANOVA table by replacing the model line with the Type I SS.

18 18 Analysis of Variance Table SourceDFSSMSF0F0 Factor ASSAMSAMSA/MSE Factor BSSBMSBMSB/MSE AB Interaction SSABMSABMSAB/MSE ErrorSSEMSE TotalSST

19 19 Replication Recall that RCBD typically has n = 1.  Notice what happens in the ANOVA table if we have n = 1.  In this case, we will not be able to investigate interaction as the DF for error would be zero (interaction and error effects would be confounded, or inseparable – a different type of “confounding” than we discussed last time). We need at least two replicates in order to assess interaction.

20 20 Breakdown of SS As before, don’t worry too much about the formulas in the book. Do remember:  SSModel + SSError = SSTotal  SSModel gets broken down via the Type I SS  For balanced design, Type III SS will all be the same as Type I SS. Balanced designs are to be preferred.  Know other relationships within the ANOVA table and how to put together test statistics.

21 21 Tests There is a specific order in which you need to do the tests.  General Rule of Thumb: Test higher order terms first.  If higher order terms are significant (say AB interaction), then tests for lower order terms (A and B main effects) do not matter as much.  Why?

22 22 Test for Interaction F-statistic: Hypotheses If then reject H 0. If insignificant, then can test for main effects.

23 23 Test for Main Effect Factor A F-statistic: Hypotheses If then reject H 0

24 24 Test for Main Effect Factor B F-statistic: Hypotheses If then reject H 0.

25 25 Comparing Factors / Levels If there is an interaction – you must do comparisons for one factor at each level of the other factor. (More later) If a main effect tests significant (whether or not there is interaction), you can study the main effect by averaging over all levels of the other factor.  This will be most meaningful if there truly is no interaction; when interaction is present, still best to study it first.

26 26 Basic SAS Code Bar notation in model statement tells SAS to include all combined effects (all main effects and all interactions) for the factors involved. Alternatively could do E L E*L; which may be important if you don’t want all interactions in a model.

27 27 Output from interaction model Note: Type III SS will be the same, since balanced design.

28 28 Create “Extended” Table The Type I SS lines replace the model line. This makes it easy to see not only that there are significant effects, but which effects in particular are important.

29 29 Where next? Interaction is significant, so we will want to study that. Because main effects are also significant, we will be able to distinguish them to some extent from the interaction.  Our statements about the main effects, however, will be less useful than they would be if there were no interaction.

30 30 Computing main the effects The means for each combination are Compare Levorphanol (average out epin.) Low EHigh E L Absent2.2465.284 L Present1.7542.572

31 31 Main Effects (2) Adding L results in a significant decrease in stress levels for the animals. Compare Epinephrine (average out lev.) Higher levels of E result in significant increases in the stress levels.

32 32 Interaction What about the interaction?  Difference in effect of L between low E and high E: This says that the effect size for the use of L is much larger when E levels are high. You get a greater reduction in stress (or more bang for your buck).

33 33 Interaction (2) You could go the other way and consider:  Difference in effect of E when L is used (vs. not used): Interpretation: The effect size for having higher levels of E is smaller when the drug L is used.

34 34 Conclusions Higher levels of E result in greater stress (as we might expect). The drug L seems to effectively lower stress levels regardless of E levels. But it works more efficiently at higher levels of E and lowers stress levels by a greater amount.

35 35 Interactions When there is significant interaction, the key to the analysis is studying the interaction and interpreting it.

36 36 Interaction Plots Two choices:  Plot MEAN Response vs. Factor B by Factor A  Plot MEAN Response vs. Factor A by Factor B Possible outcomes include  Main Effects but No Interaction  One Main Effect but No Interaction  Same Direction Interaction (as in example; increase or decrease, but not by same amount)  Reverse Interaction  See Section 19-6-2.

37 37 Interaction Plots We’ll now take a look at a number of 2 x 2 interaction plots to get an idea of what to look for. Once you learn to look at the plots, you will be able to:  Determine if interaction is present  Estimate effect sizes from the plots

38 38 Interaction Plots (1) Main Effects, No Interaction

39 39 Interaction Plots (2) Only Factor A Main Effect

40 40 Interaction Plots (3) Decreasing A effect, but not by same amt.

41 41 Interaction Plots (4) Reverse Interaction (Main effects likely appear insignificant due to the interaction)

42 42 Key to Interpretation If interaction is present, then the effect of one factor depends on the level of the other factor.  Hence main effects carry explicit meaning only if we have no interaction.  If opposite behavior (as on the previous slide), main effect might be cancelled out by the interaction and appear insignificant. When interaction is present, you need to discuss the effect of each variable at a specific level of the other (cannot separate).

43 43 Example We return to our example  Difference in effect of L based on E = high or low: Can we test for significance?  Need to develop standard errors.

44 44 Example (2) From ANOVA table, MSE = 1.019 on 16 degrees of freedom. For any two-sided t-test, the critical value for significance level 0.05 will be 2.12. For E = low, the estimated L effect is -0.492 (see previous slide). The standard error for that difference would be So T = -0.492/0.6384 = -0.77. We conclude that the L effect is not significantly different from 0 for low E. For E = high, estimated effect of L is -2.712 with SE of 0.6384. Hence T = -4.25. and we conclude that the L effect is a significant decrease for high E.

45 45 Obtaining these tests from SAS First note that the minor calculations we’ve done in the notes you should be able to put together by hand. In SAS, we’ll use the LSMEANS statement in PROC GLM, and can get all the numbers we have computed. New: As an option in LSMeans for the interaction A*B, use SLICE = to obtain tests for the significance of Factor A at fixed levels of Factor B.

46 46 SAS Code

47 47 Studying Interaction Recall: Since the interaction was significant, we must study this data at the interaction level.  We were able to examine main effects (also significant), but that analysis must be taken with a grain of salt (you’ll see why in a moment). Our LSMEANS statement will produce output for the L effect at each level of E.

48 48 Basic LSMeans Output

49 49 L Effect sliced by E levels Conclusions  If the epinephrine level is high, then the drug is effective.  But if the epinephrine level is low, the drug doesn’t do anything that is statistically significant.

50 50 Could “slice” on Levorphanol Conclusions  If the drug is not used, higher epinephrine levels result in a significant stress level increase.  If the drug is used, then higher epinephrine levels don’t change the stress level significantly.

51 51 Conclusions Even though the main effects are “significant” – the presence of interaction means we must talk about the combined effects (as on the previous two slides). The conclusions based on main effects would be inaccurate.  Main: Drug is effective (wrong!)  Interaction: Drug is effective for those with high levels of epinephrine (correct!)

52 52 Interaction Plots Interaction plots provide another useful way to look at interaction effects. An interaction plot is a plot of the treatment means at each level of one factor for each level of the other factor. The plots are overlaid so that you wind up with a plot in which the different lines represent the different levels of the 2 nd factor.

53 53 Interaction Plots (2) To obtain an interaction plot: 1.Use the SORT procedure to sort the data by each treatment. 2.Use the MEANS procedure to obtain the means for each combination. 3.Use the GPLOT procedure (and associated statements) to produce the plot

54 54 SAS Code Note: Produces only the combined means which are the ones you actually want.

55 55 Output Data Set

56 56 Alternative Code (class stmt) Note: Produces means for individual variables as well as combinations.

57 57 Output Data Set (class stmt)

58 58 Interesting Tidbit Means from CLASS statement can be used to produce effect sizes (which you should be able to calculate as we did in 1-way ANOVA).

59 59 Plotting the Combined Means

60 60 Interaction Plot

61 61 Conclusions (as before) Higher levels of epinephrine increase stress levels. Levorphenol brings stress levels back into normal range. (It is not effective for anything if stress levels are already normal). Levorphenol appears to be useful in animals with abnormally high stress levels.

62 62 CLG Activity Examine some interaction plots. Perform a two-way ANOVA.


Download ppt "1 Topic 11 – ANOVA II Balanced Two-Way ANOVA (Chapter 19)"

Similar presentations


Ads by Google