Analysis of Variance or ANOVA In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this technique has frequently been applied to medical research, samples from the different populations are referred to as different treatment groups. Main Idea behind Analysis of Variance Measure the variability within the treatment groups and also the variability between the treatment groups. The between variability is due to both differences in treatment and the random error component. The within variability is due only to the random error component. So, if there are significant treatment differences, the between variability should be substantially larger than the within variability. In ANOVA, the null hypothesis H0 is always essentially there are no differences in treatment and the alternative hypothesis H1 is always essentially there is a difference in treatment. If the problem says test whether there are no treatment effects, H0 is there are NO differences in treatment. If the problem says test whether there are treatment effects, H0 is there are NO differences in treatment. We will begin with one-factor ANOVA. Suppose were looking at the effects of different types of

heart medication on pulse rate. An individuals pulse rate is the sum of different effects. pulse rate (effect of being on heart medication in general) (effect of this medication relative to heart medications in general) (random error of this individual) If there is no difference in the effects of the various heart medications or treatments, then the middle effect above is zero. That is what we would like to test. Example 1: A manager is comparing the output of 3 machines. He has recorded 5 randomly selected minutes of operation for machine 1, 10 minutes for machine 2, and 6 minutes for machine 3. The output is as shown below. Machine 1 Y1 (Y1 - Y1 ) 2 Machine 2 Y2 (Y2 - Y2 ) 2 Machine 3 Y3 10 6 11 6 7 8

8 9 13 12 4 10 6 6 10 10 12 5 6 8 6 (Y3 - Y3 ) 2 In this example, we have n = # of observations = 21 and c = # of groups (or # of machines here) = 3 Machine 1 Y1 (Y1 - Y1 ) 2 Machine 2

Y2 (Y2 - Y2 ) 2 Machine 3 Y3 10 6 11 6 7 8 8 9 13 12 4 10 6 6 10 10

12 5 6 8 6 (Y3 - Y3 ) 2 We compute the mean output per minute for each machine. The grand mean for all the machines combined is (42+67+64)/21 = 8.238. Machine 1 Y1 Machine 2 (Y1 - Y1 ) 2 Y2 Machine 3 (Y2 - Y2 ) 2 Y3 10 6 11 6 7 8 8

9 13 12 4 10 6 6 10 10 12 5 6 8 6 42 Y1 42 8.4 5 67 Y2 67 6.7 10

64 Y3 64 10.67 6 (Y3 - Y3 ) 2 We next look at the variation in output by computing sums of squared deviations. Machine 1 Machine 3 Y1 (Y1 - Y1 ) 2 Y2 (Y2 - Y2 )2 Y3 (Y3 - Y3 ) 2 10 2.56 6 0.49 11 0.1111

6 5.76 7 0.09 8 7.1111 8 0.16 9 5.29 13 5.4444 12 12.96 4 7.29 10 0.4444 6 5.76

6 0.49 10 0.4444 10 10.89 12 1.7778 5 2.89 6 0.49 8 1.69 6 0.49 67 30.10 64

15.33 42 Y1 Machine 2 42 8.4 5 27.2 Y2 67 6.7 10 Y3 64 10.67 6 The sum of squared variation within groups or SS within is the sum of the sums of squared deviations for the 3 groups = 27.2 + 30.10 + 15.33 = 72.63 . Machine 1 Machine 3 Y1 (Y1 - Y1 ) 2 Y2 (Y2 - Y2 )2

Y3 (Y3 - Y3 ) 2 10 2.56 6 0.49 11 0.1111 6 5.76 7 0.09 8 7.1111 8 0.16 9 5.29 13 5.4444

12 12.96 4 7.29 10 0.4444 6 5.76 6 0.49 10 0.4444 10 10.89 12 1.7778 5 2.89 6

0.49 8 1.69 6 0.49 67 30.10 64 15.33 42 Y1 Machine 2 42 8.4 5 27.2 Y2 67 6.7 10 Y3 64 10.67 6

The mean squared variation within groups MS within = (SS Within) / (n c). = 72.63/(21 3) = 72.63/18 = 4.035 The sum of squared variation between groups or SS Between is SS Between n1 ( Y1 Y ) 2 n 2 ( Y2 Y ) 2 n 3 ( Y3 Y ) 2 The mean square variation between groups or MS Between is SS Between MS Between In our example, n1=5 Y1 8.4 c 1 n2=10 Y2 6.7 n3=6 Y3 10.67 c=3 Y 8.238 So, SS Between 5(8.4 8.238) 2 10(6.7 8.238) 2 6(10.67 8.238) 2 5(0.026) 10(2.365) 6(5.898) MS Between SS Between 59.18 29.59 c 1 2 59.18

The sum of squares total or SS Total = SS Between + SS Within The mean squared total or MS Total = SS Total /( n 1) We compile our information in a table called an ANOVA table. Source of variation Degrees of freedom Sum of squares Mean square Between Groups c1 31=2 59.18 29.59 Within Groups nc 21 3 = 18 72.63 4.035

Total n1 21 1 = 20 131.81 6.591 Notice that the degrees of freedom column adds up to the total at the bottom, and the sum of squares column adds up to the total at the bottom, but the mean square column does NOT add up to the total at the bottom. Remember that the purpose of all the work we have been doing is to test whether there is a treatment effect, that is a difference in the means of the various groups. The hypotheses are H0: there is no difference in the means, and H1: there is a difference in the means. In our current example, we want to know if there is a difference in the mean output level of the various machines. The statistic we use here is the F-statistic: Fc 1, n c MS Between . MS Within The subscripts are the degrees of freedom of the F-statistic and they are the degrees of freedom that are associated with the numerator and the denominator of the statistic. Like the 2, the F distribution is skewed to the right, and the critical region for the test is the right tail. f(Fc-1, n-c)

acceptance region crit. reg. Fc-1, n-c For our current example, we have: Fc 1, n c F3 1, 21 3 F2, 18 MS Between 29.59 7.33 MS Within 4.035 The F table shows that for 2 and 18 degrees of freedom, the 5% critical value is 3.55. f(F2, 18) Since our F has a value of 7.33, we reject the null hypothesis and conclude that there is a difference in the mean output levels of the 3 machines. acceptance region 0.05 crit. reg. 3.55 7.33 F2, 18

Example 2: In order to compare the average tread life of 3 brands of tires, random samples of 6 tires of each brand are tested on a machine which simulates road conditions. The tread life for each tire is measured. Complete the analysis of variance table and test at the 1% level whether there is a difference in the average tread life of the 3 tire brands. Source of variation Sum of squares Between 224.78 Within 118.83 Total Degrees of freedom Mean square First we can calculate SS Total by adding SS Between and SS Within. Source of variation Sum of squares

Between 224.78 Within 118.83 Total 343.61 Degrees of freedom Mean square The degrees of freedom for the SS Between is c 1 = 3 1 = 2, since there are three groups (3 tire brands). Source of variation Sum of squares Degrees of freedom Between 224.78 2 Within

118.83 Total 343.61 Mean square The degrees of freedom for the SS Within is n c = 18 3 = 15, since there are 18 observations (6 of each of the 3 brands). Source of variation Sum of squares Degrees of freedom Between 224.78 2 Within 118.83 15 Total 343.61 Mean

square The degrees of freedom for the SS total is n 1 = 18 1 = 17. Source of variation Sum of squares Degrees of freedom Between 224.78 2 Within 118.83 15 Total 343.61 17 Mean square The MS Between is (SS Between) / (dof Between) = 224.78 / 2 = 112.39

Source of variation Sum of squares Degrees of freedom Mean square Between 224.78 2 112.39 Within 118.83 15 Total 343.61 17 The MS Within is (SS Within) / (dof Within) = 118.83 / 15 = 7.922 Source of variation

Sum of squares Degrees of freedom Mean square Between 224.78 2 112.39 Within 118.83 15 7.922 Total 343.61 17 The MS Total is (SS Total ) / (dof Total ) = 343.61 / 17 = 20.212 Source of variation Sum of

squares Degrees of freedom Mean square Between 224.78 2 112.39 Within 118.83 15 7.922 Total 343.61 17 20.212 So, Fc 1, n c MS Between 112 .39 F2, 15 14.19

MS Within 7.922 The F table shows that for 2 and 15 degrees of freedom, the 1% critical value is 6.36. f(F2, 15) Since our F has a value of 14.19, we reject the null hypothesis and conclude that there is a difference in the mean tread life of the 3 tire brands. acceptance region 0.01 crit. reg. 6.36 14.19 F2, 15 Two-Factor ANOVA with Interaction Effects Now, we have two factors of interest, A and B, and the factors may interact to influence a particular variable Y with which we are concerned. For example, we may want to explore the effects of different teachers and different teaching methods on student performance. So, student performance (effect of having a particular teacher) (effect of a particular teaching method) (effect of the interaction of the teacher and the method) (random error associated with the particular student)

We have 3 sets of hypotheses. H0: factor A has no effect on Y. H1: factor A has an effect on Y. H0: factor B has no effect on Y. H1: factor B has an effect on Y. H0: the interaction of factors A and B has no effect on Y. H1: the interaction of factors A and B has an effect on Y. For each A and B possibility, we have r replications (or observations). For example, suppose we have a = 4 different teachers, b = 3 different methods, and r = 3 replications. There are 12 different teaching possibilities: You could have teacher A, B, C, or D, and that instructor could be using method 1, 2, or 3. For each one of these 12 situations, we have 3 replications, or 3 observations, or exam scores of 3 students. Our ANOVA table now looks like this: Source of Variation Sum of Squares Degrees of Freedom Mean Square Factor A SSA a1

MSA Factor B SSB b1 MSB Interaction between A & B SSAB (a 1)(b 1) MSAB Random Error SSE ab(r 1 ) MSE Total SST n1 (or abr 1) MST Test Statistics for Two-Way ANOVA Testing for the effect of factor A:

Fa 1, ab( r 1) MS Factor A MS Error Testing for the effect of factor B: Fb 1, ab( r 1) Notice that in all three cases, the denominator is the same; its the Mean Squared Error. MS Factor B MS Error Testing for the effect of the interaction of A and B: F( a 1)( b 1), ab( r 1) MS Interaction MS Error Example 3: Consider the following ANOVA table relating student performance to 4 teachers, 3 teaching methods, and the interaction of those 2 factors, using 3 replications. Source of Variation

Sum of Squares Teacher 300 Method 400 Interaction 900 Error 1200 Total Degrees of Freedom Mean Square Complete the table and then test at the 5% level whether student performance depends on (1) the teacher, (2) the teaching method, and (3) the interaction of the teacher and the method. Source of Variation Sum of Squares Teacher 300

Method 400 Interaction 900 Error 1200 Total Degrees of Freedom Mean Square First, we complete the table. Source of Variation Sum of Squares Degrees of Freedom Mean Square Teacher 300 41=3 100 Method

400 31=2 200 Interaction 900 (4 1)(3 1) = 6 150 Error 1200 ab(r 1) = (4)(3)(3 1) = 24 50 Total 2800 n 1 = abr 1 = 36 1 = 35 80 Now we test the hypotheses. Well begin with the teachers. F3, 24 MS Teachers 100

2 MS Error 50 From the F table, we find that the 5% critical value for 3 and 24 degrees of freedom is 3.01. f(F3, 24) acceptance region 0.05 crit. reg. 2.00 3.01 Source of Variation SS dof MS Teacher 300 3 100 Method 400

2 200 Interaction 900 6 150 Error 1200 24 50 Total 2800 35 80 Since our statistic, 2.00, is in the acceptance region, we accept H0 that the teacher has no effect on student performance. F3, 24 Next we look at the teaching methods. F2,24

MS Method 200 4 MS Error 50 Source of Variation SS dof MS Teacher 300 3 100 Method 400 2 200 Interaction 900 6

150 Error 1200 24 50 Total 2800 35 80 From the F table, we find that the 5% critical value for 2 and 24 degrees of freedom is 3.40. f(F2, 24) Since our statistic, 4.00, is in the critical region, we reject H0 and accept H1 that the method does affect student performance. acceptance region 0.05 crit. reg. 3.40 4.00 F2, 24

Last we look at the interaction of teachers and methods. F6,24 MS Interaction 150 3 MS Error 50 From the F table, we find that the 5% critical value for 6 and 24 degrees of freedom is 2.51. f(F6, 24) acceptance region 0.05 crit. reg. 2.51 3.00 Source of Variation SS dof MS Teacher 300 3

100 Method 400 2 200 Interaction 900 6 150 Error 1200 24 50 Total 2800 35 80 Since 3 is in the critical region, we reject H0 & accept H1: there is an interaction effect of teacher & method on student

performance. F6, 24