Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different...

38
Analysis of Variance or ANOVA

Transcript of Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different...

Page 1: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Analysis of Variance

or ANOVA

Page 2: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.

Page 3: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.

Page 4: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.”

Page 5: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

We will begin with one-factor ANOVA.

Suppose we’re looking at the effects of different types of heart medication on pulse rate.

An individual’s pulse rate is the sum of different effects.

)individual thisoferror (random general)in smedicationheart torelative medication thisof(effect

general)in medicationheart on being of(effect rate pulse

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.

Page 6: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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 Machine 2 Machine 3

Y1 Y2 Y3

10 6 11

6 7 8

8 9 13

12 4 10

6 6 10

10 12

5

6

8

6

211 Y-(Y ) 2

22 Y-(Y ) 233 Y-(Y )

Page 7: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

In this example, we have n = # of observations = 21

and c = # of groups (or # of machines here) = 3

Machine 1 Machine 2 Machine 3

Y1 Y2 Y3

10 6 11

6 7 8

8 9 13

12 4 10

6 6 10

10 12

5

6

8

6

211 Y-(Y ) 2

22 Y-(Y ) 233 Y-(Y )

Page 8: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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 Machine 2 Machine 3

Y1 Y2 Y3

10 6 11

6 7 8

8 9 13

12 4 10

6 6 10

10 12

5

6

8

6

42 67 64

211 Y-(Y ) 2

22 Y-(Y ) 233 Y-(Y )

485

42Y1 . 76

10

67Y2 . 6710

6

64Y3 .

Page 9: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

We next look at the variation in output by computing sums of squared deviations.

Machine 1 Machine 2 Machine 3

Y1 Y2 Y3

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

42 27.2 67 30.10 64 15.33

211 Y-(Y ) 2

22 Y-(Y ) 233 Y-(Y )

485

42Y1 . 76

10

67Y2 . 6710

6

64Y3 .

Page 10: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The sum of squared variation within groups or SS withinis the sum of the sums of squared deviations for the 3 groups = 27.2 + 30.10 + 15.33 = 72.63 .

Machine 1 Machine 2 Machine 3

Y1 Y2 Y3

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

42 27.2 67 30.10 64 15.33

211 Y-(Y ) 2

22 Y-(Y ) 233 Y-(Y )

485

42Y1 . 76

10

67Y2 . 6710

6

64Y3 .

Page 11: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The mean squared variation within groups

MS within = (SS Within) / (n – c).

= 72.63/(21 – 3) = 72.63/18 = 4.035

Page 12: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The mean square variation between groups or MS Between is

48Y1 . 76Y2 . 6710Y3 .

2 2 2So, SS Between 5(8.4 8.238) 10(6.7 8.238) 6(10.67 8.238)

2388Y .In our example, n1=5 n2=10 n3=6 c = 3

5(0.026) 10(2.365) 6(5.898) 1859.

233

222

211 YYnYYnYYn Between SS )()()(

The sum of squared variation between groups or SS Between is

59292

1859

1c

Between SSBetween MS .

.

1c

Between SSBetween MS

Page 13: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The sum of squares total or SS Total = SS Between + SS Within

The mean squared total or MS Total = SS Total /( n – 1)

Page 14: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

We compile our information in a table called an ANOVA table.

Source of variation

Degrees of freedom

Sum of squares

Mean square

Between Groups

c – 13 – 1 = 2

59.18 29.59

Within Groups

n – c 21 – 3 = 18

72.63 4.035

Totaln – 1

21 – 1 = 20131.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.

Page 15: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.

Page 16: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The statistic we use here is the F-statistic:

., WithinMS

Between MSF cn 1c

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.

Page 17: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Fc-1, n-c

f(Fc-1, n-c)

acceptance region

crit. reg.

Like the 2, the F distribution is skewed to the right,

and the critical region for the test is the right tail.

Page 18: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

For our current example, we have:

81 2321 13cn 1c FFF ,,, 4.035

5929

WithinMS

Between MS . 337.

The F table shows that for 2 and 18 degrees of freedom, the 5% critical value is 3.55.

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.

f(F2, 18)

F2, 18

acceptance region

crit. reg.0.05

3.55 7.33

Page 19: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Degrees of freedom

Mean square

Between 224.78

Within 118.83

Total

Page 20: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

First we can calculate SS Total by adding SS Between and SS Within.

Source of variation

Sum of squares

Degrees of freedom

Mean square

Between 224.78

Within 118.83

Total 343.61

Page 21: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Mean square

Between 224.78 2

Within 118.83

Total 343.61

Page 22: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Mean square

Between 224.78 2

Within 118.83 15

Total 343.61

Page 23: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

The degrees of freedom for the SS total is n – 1 = 18 – 1 = 17.

Source of variation

Sum of squares

Degrees of freedom

Mean square

Between 224.78 2

Within 118.83 15

Total 343.61 17

Page 24: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Page 25: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Page 26: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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

Page 27: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

So,

15 2cn 1c FF ,, 7.922

39112

WithinMS

Between MS . 1914.

The F table shows that for 2 and 15 degrees of freedom, the 1% critical value is 6.36.

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.

f(F2, 15)

F2, 15

acceptance region

crit. reg.0.01

6.36 14.19

Page 28: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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) particular with theassociatederror (random method) theand teacher theofn interactio theof(effect

method) teachingparticular a of(effect teacher)particular a having of(effect

eperformancstudent

Page 29: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.

Page 30: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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.

Page 31: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Our ANOVA table now looks like this:

Source of Variation

Sum of SquaresDegrees of Freedom

Mean Square

Factor A SSA a – 1 MSA

Factor B SSB b – 1 MSB

Interaction between A & B

SSAB (a – 1)(b – 1) MSAB

Random Error SSE ab(r – 1 ) MSE

Total SSTn – 1

(or abr – 1)MST

Page 32: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Error MS

AFactor MSF 1rab 1a )(,

Error MS

BFactor MSF 1rab 1b )(,

Error MS

nInteractio MSF 1rab 1b1a )(),)((

Test Statistics for Two-Way ANOVA

Testing for the effect of the interaction of A and B:

Testing for the effect of factor A:

Testing for the effect of factor B:

Notice that in all three cases, the denominator is the same; it’s the Mean Squared Error.

Page 33: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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 SquaresDegrees of Freedom

Mean Square

Teacher 300

Method 400

Interaction 900

Error 1200

Total

Page 34: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

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 SquaresDegrees of Freedom

Mean Square

Teacher 300

Method 400

Interaction 900

Error 1200

Total

Page 35: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

First, we complete the table.

Source of Variation

Sum of SquaresDegrees of Freedom

Mean Square

Teacher 300 4 – 1 = 3 100

Method 400 3 – 1 = 2 200

Interaction 900 (4 – 1)(3 – 1) = 6 150

Error 1200ab(r – 1)

= (4)(3)(3 – 1)= 24

50

Total 2800n – 1 = abr – 1= 36 – 1 = 35

80

Page 36: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Now we test the hypotheses. We’ll begin with the teachers.

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

250

100

Error MS

Teachers MSF 243 ,

f(F3, 24)

F3, 24

acceptance region

crit. reg.0.05

3.012.00

From the F table, we find that the 5% critical value for 3 and 24 degrees of freedom is 3.01.

Since our statistic, 2.00, is in the acceptance region, we accept H0 that the teacher has no effect on student performance.

Page 37: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Next we look at the teaching methods.

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

450

200

Error MS

Method MSF 242 ,

f(F2, 24)

F2, 24

acceptance region

crit. reg.0.05

3.40 4.00

From the F table, we find that the 5% critical value for 2 and 24 degrees of freedom is 3.40.

Since our statistic, 4.00, is in the critical region, we reject H0 and accept H1 that the method does affect student performance.

Page 38: Analysis of Variance or ANOVA. In ANOVA, we are interested in comparing the means of different populations (usually more than 2 populations). Since this.

Last we look at the interaction of teachers and methods.

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

350

150

Error MS

nInteractio MSF 246 ,

f(F6, 24)

F6, 24

acceptance region

crit. reg.0.05

2.51 3.00

From the F table, we find that the 5% critical value for 6 and 24 degrees of freedom is 2.51.

Since 3 is in the critical region, we reject H0 & accept H1: there is an interaction effect of teacher & method on student performance.