Presentation is loading. Please wait.

Presentation is loading. Please wait.

2 Way Analysis of Variance (ANOVA) Peter Shaw RU.

Similar presentations


Presentation on theme: "2 Way Analysis of Variance (ANOVA) Peter Shaw RU."— Presentation transcript:

1 2 Way Analysis of Variance (ANOVA) Peter Shaw RU

2 n ANOVA - a recapitulation. n This is a parametric test, examining whether the means differ between 2 or more populations. n It generates a test statistic F, which can be thought of as a signal:noise ratio. Thus large Values of F indicate a high degree of pattern within the data and imply rejection of H0. n It is thus similar to the t test - in fact ANOVA on 2 groups is equivalent to a t test [F = t 2 ]

3 How to do an ANOVA: table 1: Calculate total Sum of Squares for the data Ss tot = Σ i (x i - μ ) 2  = Σ i ( x i 2 ) – CF  where CF = Correction factor = ( Σ i x i * Σ i x i ) /N n 2: calculate Treatment Sum of Squares SS trt = Σ t (X t. *X t. )/r - CF u where X t. = sum of all values within treatment t n 3: Draw up ANOVA table

4 ANOVA tables n Exact layout varies somewhat - I dislike SPSS’s version! n Learn as parrots: n Source DF SS MS F SourcedfSSMSF Treatment(T-1)SS trtSStrt / (T-1)MStrt / MSerr ErrorSserr by subtraction =SS err / DF err TotalN-1Ss totVariance

5 One way ANOVA’s limitations n This technique is only applicable when there is one treatment used. n Note that the one treatment can be at 3, 4,… many levels. Thus fertiliser trials with 10 concentrations of fertiliser could be analysed this way, but a trial of BOTH fertiliser and insecticide could not.

6 Linear models.. n Although rather worrying-looking, these equations formally define the ANOVA model being used. (By understanding these equations you can readily derive all of ANOVA from scratch) n The formal model underlying 1-Way ANOVA with Treatment A and r replicates: n X ir = μ + A i + Err ir n X ir is the rth replicate of Treatment A applied at level i n A i is the effect of treatment i (= difference between μ and mean of all data in treatment i. n Err tr is the unexplained error in Observation X tr Note that ΣA i = Σerr ir = 0

7 μ Trt 1 Trt 2 n Basic model: Data are deviations from the global mean: n X ir = μ + Err ir n Sum of vertical deviations squared = SS tot Trt 1 Trt 2 n 1 way model: Data are deviations from treatment means: n X ir = μ + A i + Err ir n Sum of vertical deviations squared = SS err A1 A2

8 μ μ A1 No model n X ir just is! n H0 model: n X ir = μ + Err ir 1 way anova model: X ir = μ + A i + Err ir

9 Two-way ANOVA n Allows two different treatments to be examined simultaneously. n In its simplest form it is all but identical to 1 way, except that you calculate 2 different treatment sums of squares: Calculate total Sum of Squares Ss tot = Σ i ( x i 2 ) – CF Calculate Sum of Squares for treatment A SS A = Σ A (X A. *X A. )/r - CF Calculate Sum of Squares for treatment B SS B = Σ B (X B. *X B. )/r - CF

10 2 Way ANOVA table SourcedfSSMSF Treatment A(N A -1)SS A SS A / (N A -1)MS A / MS err Treatment B(N B -1)SS B SS B / (N B -1)MS B / MS err ErrorByBy Subtraction SubtractionSS err / DF err TotalN-1SS totVariance

11 The 2 way Linear model n The formal model underlying 2-Way ANOVA, with 2 treatments A and B n X ikr = μ + A i + B k + err ikr n X ikr is the rth replicate of Treatment A level i and treatment B level k n A i is the effect of the i th level of treatment A (= difference between μ and mean of all data in this treatment. n B k is the effect of the k th level of treatment B (= difference between μ and mean of all data in this treatment. n Err ijr is the unexplained error in Observation X ijr Note that ΣA i = ΣB k = Σerr ikr = 0

12 To take a worked example (Steel & Torrie p. 343). Effect of 2 treatments on blood phospholipids in lambs. 1 was a handling treatment, one the time of day. A1B1A1B2A2B1A2B2 8.5317.5339.1432.00 20.5321.0726.2023.80 12.5320.8031.3328.87 14.0017.3345.8025.06 10.8020.0740.2029.33 totals: 66.3996.80182.67139.06

13 2 Way ANOVA on these data: Start by a preliminary eyeballing of the data: They are continuous, plausibly normally distributed. There are 2 handling treatments and 2 time treatments, which are combined in a factorial design so that each of the 4 combinations is replicated 5 times. Get the basics: n = 20 Σx = 484.92 Σx^2 = 13676.7 CF = 484.92^2 / 20 = 11757.37 SS = 13676.7 - cf = 1919.33

14 Now get totals for treatments A and B A1A2Σ B166.39182.67249.06 B296.80139.06235.86 Σ163.19321.73484.92 Hence the sums of squares for A and B can be calculated: SSA = 163.19^2/10 + 321.73^2 / 10 - CF = 1256.75 SSB = 249.06^2/10 + 235.86^2/10 - CF = 8.712

15 A alone SourceDfSSMSF A 11256.751256.7534.14** error18 662.58 36.81 total191919.33 B alone SourceDfSSMSF B1 8.71 8.710.08 NS error181910.62106.15 total191919.33 Pooled (the correct format) SourceDfSSMSF A11256.751256.7532.67** B1 8.71 8.710.24NS error17 653.87 38.86 total191919.33

16 Note that we have reduced error variance and DF by incorporating 2 treatments into one table. This is not just good practice but technically required - by including only one treatment in the table you are implicitly calling the effects of the other treatment random noise, which is incorrect. ANOVA tables can have many different treatments included. The skill in ANOVA is not working out the sums of squares, it is the interpretation of ANOVA tables. The clues to look for are always in the DF column. A treatment with N levels has N-1 DF - this always applies and allows you to infer the model a researcher was using to analyse data.

17 A B 1 1 18 1 1 22 1 2 25 1 2 35 1 3 47 1 3 53 2 1 29 2 1 31 2 2 38 2 2 42 2 3 45 2 3 51 3 1 38 3 1 42 3 2 46 3 2 44 3 3 35 3 3 45 Your turn! These data come from a factorial experiment with 2 treatments applied at 3 levels each, with 2 replicates of each treatment. Hence the design contains 3 (A)*3 (B)*2(reps) = 18 data points. They are specially contrived to make the calculations easy for ANOVA Remember the sequence: Get: n, Σx, Σx^2 Calculate CF then SS tot Get the totals for each treatment: A1, A2, A3, B1, B2 and B3 hence get SS A and SS B

18 These model data: n N = 18 n Σx = 686.00 n Σx^2 = 27822.00 n CF = 26144.22 n SS tot = 27822.00 -26144.22 = 1677.78

19 Totals for each treatment: n A1A2A3Σ n B1406080180 n B2608090230 n B31009680276 n Σ200236250686

20 Sums of squares: n SSa = 200^2/6 + 236^2/6 + 250^2/6 - CF = 221.78 n SSb = 180^2/6 + 230^2/6 + 276^2/6 - CF = 768.44 n SourceDfSSMSF n A 2221.78110.892.1 NS n B 2768.44384.227.26** n error13687.56 52.89 n Σ171677.78

21 Interaction terms n We now meet a unique, powerful feature of ANOVA. It can examine data for interactions between treatments - synergism or antagonism. n No other test allows this, while in ANOVA it is a standard feature of any 2 way table. n Note that this interaction analysis is only valid if the design is perfectly balanced. Unequal replication or missing data points make this invalid (unlike 1 way, which is robust to imbalance).

22 Synergism and antagonism n Some treatments intensify each others’ effects: n The classic examples come from pharmacology. n Alcohol alone is lethal at the 20-40 unit range. Barbiturates are lethal. Together they are a vastly more lethal combination, as the 2 drugs synergise. (In fact most sedatives and depressants show similar dangerous synergism). n In ecology, SO2 + NO2 is more damaging than the additive effects of each gas alone - a synergism.

23 Antagonism. n is the opposite - 2 treatments nullifying each other. n Drought antagonises effects of air pollution on plants, as drought leads to closed stomata excluding the noxious gas.

24 123 Treatment A I I I1 Treatment B Response 123 Treatment A I I I Response 123 I I I I I I 2 No interaction I I I Synergism I I I Antagonism

25 How to do this? n Easy! We work out a sum of squares caused by ALL treatments at ALL levels. Thus for a 3*3 design there are really 9 treatments, etc. Call this SS trt n Now we can partition this Sum of squares: SStrt = SS A + SS B + SS Interaction n We know SSA, we know SSB, so we get SS interaction by subtraction. n To get SStrt we just add up all data in each treatment, square this total, divide by replicates, add up and remove CF.

26 For the lamb blood data: n We have 4 separate treatments: A1B1, A1B2, A2B1, A2B2 n The data within these 4 groups add to: 66.39, 182.67, 96.80, 139.06. There are 5 replicates n SStrt = 66.39^2/5 + 182.67^2/5 + 96.8^2/5 + 139.06^2/5 - CF = 1539.407

27 n SourceDfSSMSF n All trts31539.07*********** n A 11256.751256.7552.93* n B 1 8.71 8.71 0.37NS n A*B1 273.95 273.9511.54** n error16 379.92 23.75 Σ191919.33 2 Way anova table with interaction

28 Interpreting the interaction term The hardest part of 2 way anova is trying to explain what a significant interaction term means, in terms that make sense to most people! Formally it is easy; you are testing H0: Ms for interaction term is same population as MS for error. In English let’s try “It means that you can’t reliably predict the effect of Treatment A at level m with B at level n, knowing only the effect of A m and B n on their own.”

29 Treatment A – big effect (A2>A1) Treatment B – mean (B1) is v close to mean (B2) so no effect Interaction: When A=1, B1 B2 A1B1 A1B2 A2B1 A2B2


Download ppt "2 Way Analysis of Variance (ANOVA) Peter Shaw RU."

Similar presentations


Ads by Google