lec 1: an introduction to anova - s ugauss.stat.su.se/gu/ep/lec1.pdf · ying li stockholm...

32
Lec 1: An Introduction to ANOVA Ying Li Stockholm University October 31, 2011 Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Upload: others

Post on 04-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Lec 1: An Introduction to ANOVA

Ying LiStockholm University

October 31, 2011

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 2: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Three end-aisle displays

Which is the best?

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 3: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Design of the Experiment

Identify the stores of the similar size and type.

The displays are randomly assigned to use.

First Principle

Randomization

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 4: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Design of the Experiment

Identify the stores of the similar size and type.

The displays are randomly assigned to use.

First Principle

Randomization

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 5: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Observations

3 levels

5 replicates

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 6: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

1 2 3

67

89

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 7: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

The Analysis of Variance

a level of the factors (a treatments)

n replicates

N = a× n runs

Completely randomized design

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 8: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Statistical Model

yij = µ+ τi + εij

i = 1, · · · a

j = 1, · · · n

µ : overall mean

τi : the effect of ith treatment

εij ∼ N(0, σ2),i .i .d .∑ai τi = 0

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 9: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

The Analysis of Variance

We are interested in testing the equality of treatment means

E (yi .) = µ+ τi = µi

i = 1, · · · a The appropriate hypothesis are

H0 : µ1 = µ2 = · · · = µa

H1 : µi 6= µj

for at least one pair (i , j)

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 10: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

If H0 is true, the distribution of F0 is Fa−1,a(n−1)

Reject H0 if F0 > Fα,a−1,a(n−1)

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 11: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 12: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Equation for manual calculation

Balanced Data:

SST =a∑

i=1

n∑j=1

y2ij −y2..N

SSTreatment =1

n

a∑i=1

y2i . −y2..N

SSE = SST − SSTreatment

Unbalanced Data

SST =a∑

i=1

ni∑j=1

y2ij −y2..N

SSTreatment =a∑

i=1

y2i .ni− y2..

N

SSE = SST − SSTreatment

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 13: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Example

y1. = 5.73,y2. = 6.24, y3. = 8.32,y.. = 6.76SST = 21.93SSTreatment = 18.78SSE = SST − SSTreatment = 3.15

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 14: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

DF SS MS F P

Treatment 2 18.78 9.39 35.77 <0.001

Error 12 3.15 0.26

Total 14 21.93

Which ones cause the differ?

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 15: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

DF SS MS F P

Treatment 2 18.78 9.39 35.77 <0.001

Error 12 3.15 0.26

Total 14 21.93

Which ones cause the differ?

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 16: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Multiple Comparison Methods

We know the end-aisle display different than others. We mightsuspect the first and the second are different. Thus one reasonabletest hypothesis would be

H0 : µ1 = µ2

H1 : µ1 6= µ2

or,H0 : µ1 − µ2 = 0

H1 : µ1 − µ2 6= 0

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 17: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Contrasts

In general, a contrast is a linear combination of the parameters ofthe form

Γ =a∑

i=1

ciµi

where ci are the contrast constants, and∑a

i=1 ci = 0.For unbalance design

∑ai=1 cini = 0.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 18: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

The hypothesis can be expressed in the terms of contrasts

H0 :a∑

i=1

ciµi = 0

H1 :a∑

i=1

ciµi 6= 0

In our example, c1 = 1,c2 = −1, c3 = 0.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 19: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Contrast Tests

Testing hypothesis involving contrast can be done in two basicways

1 t-test:

t0 =

∑ai=1 ci yi .√

MSEn

∑ai=1 c

2i

2 F-test:

F0 =MScMSE

=SSc/1

MSE

where

SSc =(∑a

i=1 ci yi .)2

1n

∑ai=1 c

2i

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 20: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Orthogonal Contrasts

Two contrasts∑a

i=1 = ciµi = 0 and∑a

i=1 = diµi = 0are orthogonal if

a∑i=1

cidi = 0

or in unbalanced case if

a∑i=1

nicidi = 0

We can specify a− 1 orthogonal contrasts. Tests performed onorthogonal contrasts are independent.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 21: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Example

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 22: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Pairwise Comparison

The null hypothesis are

H0 : µi = µj , i 6= j

Tukey’s test

Make use of the distribution of studentized range statistics

q =ymax − ymin√MSE2 ( 1

ni+ 1

nj)

Appendix Table 7 contains upper percentiles for q.The difference d between two averages is significant if

|d | > qα(a, f )√2

√MSE (

1

ni+

1

nj)

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 23: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Pairwise Comparison

The null hypothesis are

H0 : µi = µj , i 6= j

Tukey’s test

Make use of the distribution of studentized range statistics

q =ymax − ymin√MSE2 ( 1

ni+ 1

nj)

Appendix Table 7 contains upper percentiles for q.The difference d between two averages is significant if

|d | > qα(a, f )√2

√MSE (

1

ni+

1

nj)

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 24: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

The fisher least significant difference method (LSD)

The fisher least significant difference method procedure use T testfor testing

H0 : µi = µj , i 6= j

The test statistics is:

t0 =yi . − yj .√

MSE ( 1ni

+ 1nj

)

The quantity: least significant difference (LSD)

LSD = tα/2,N−a

√MSE (

1

ni+

1

nj)

If|yi . − yj .| > LSD

we conclude that the population means µi and µj differ.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 25: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Questions:1

Why in some situation overall F test of ANOVA is significant, butthe pairwise comparison fails to reveal the differences?

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 26: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Questions:2

Many tests available:Duncan, Student-Newman-Keuls, REGWQ, Bonferroni, Sidak,Scheff, ·Which pairwise comparison method do I use?

unfortunately, no-clear cut answer.

Fisher’s LSD procedure, only apply if F test is significant

Tukey’s method control overall error rate, many statisticiansprefer.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 27: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Questions:2

Many tests available:Duncan, Student-Newman-Keuls, REGWQ, Bonferroni, Sidak,Scheff, ·Which pairwise comparison method do I use?

unfortunately, no-clear cut answer.

Fisher’s LSD procedure, only apply if F test is significant

Tukey’s method control overall error rate, many statisticiansprefer.

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 28: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Dunnett’s Test

Often one of the treatments is a control treatment, and we wantto compare the other treatments with the control treatment. Wewant to test a− 1 hypotheses:

H0 : µj = µ1

wherei = 2, · · · , a

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 29: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

Dunnett’s Test

For the ith treatment, H0 is rejected if

|yi − y1| > dα(a− 1, f )

√MSE (

1

ni+

1

nj)

Appendix 8 gives upper percentiles for dα(a− 1, f )

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 30: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

One Example

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 31: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

One Example

Ying Li Stockholm University Lec 1: An Introduction to ANOVA

Page 32: Lec 1: An Introduction to ANOVA - s ugauss.stat.su.se/gu/ep/lec1.pdf · Ying Li Stockholm University Lec 1: An Introduction to ANOVA. Pairwise Comparison The null hypothesis are H

One Example

Ying Li Stockholm University Lec 1: An Introduction to ANOVA