One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data...

61
09/30/12 1 Experimental Design One-way ANOVA One-way ANOVA Method to compare more than two samples simultaneously without inflating Type I Error rate (α) Simplicity Few assumptions Adequate for highly complex hypothesis testing

Transcript of One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data...

Page 1: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 1

Experimental Design One-way ANOVA

One-way ANOVA

● Method to compare more than two samples simultaneously without inflating Type I Error rate (α)

● Simplicity

● Few assumptions

● Adequate for highly complex hypothesis testing

Page 2: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 2

Experimental Design One-way ANOVA

Outline of this class●Data organization and layout

●Repartitioning of variance

●Definition of a linear model

●Combine the linear model with the repatitioning of variances

●Definition of a statistic (F-test)

Page 3: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 3

Experimental Design One-way ANOVA

Data organization

Suppose that we want to investigate the average length of a fish species in three different lakes because we suspect that there might be some form of local adaptation

We sample 5 fish (replicates) at each lake

Page 4: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 4

Experimental Design One-way ANOVA

Data organization

First we establish how to measure “length”

Lenght

This is an important part of experimental design!

Page 5: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 5

Experimental Design One-way ANOVA

Data organization

Then we collect the data

Page 6: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 6

Experimental Design One-way ANOVA

Data organization

Factor “Lake” has three levels: 1, 2 and 3

Page 7: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 7

Experimental Design One-way ANOVA

Data organization

Page 8: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 8

Experimental Design One-way ANOVA

Data organization

We may represent it as

Note that Lake is a classification criteria, that is, we can classify each fish according to the lake where it belongs

Page 9: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 9

Experimental Design One-way ANOVA

Total variation =

Ronald Aylmer Fisher (1890-1962)

Repartitioning the variance

Page 10: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 10

Experimental Design One-way ANOVA

Total variation =

Sum of all the squared differences between each individual value and the grand mean (overall mean)

But why squaring the differences?

Why this formula?

Page 11: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 11

Experimental Design One-way ANOVA

Total variation =

Page 12: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 12

Experimental Design One-way ANOVA

= 0

Total variationWithin treatments variation

Among (between) treatments variation

Page 13: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 13

Experimental Design One-way ANOVA

Repartitioning the variance

Page 14: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 14

Experimental Design One-way ANOVA

What do these quantities measure?

Repartitioning the variance

Page 15: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 15

Experimental Design One-way ANOVA

Why use analysis of variance to test hypothesis about the means?

Repartitioning the variance

Page 16: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 16

Experimental Design One-way ANOVA

Defining a linear model

Any single measurement can be predicted if we know the mean (μ) of the treatment or sample where it belongs (i) and the error (e) associated with that particular replicate (j) in the sample i

Page 17: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 17

Experimental Design One-way ANOVA

An interesting propertyTake sample 1 (Lake 1)

Page 18: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 18

Experimental Design One-way ANOVA

An interesting property

Page 19: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 19

Experimental Design One-way ANOVA

An interesting property

Page 20: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 20

Experimental Design One-way ANOVA

An interesting propertyWe can represent any sample in terms of its errors

We will make use of this property later on...

Page 21: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 21

Experimental Design One-way ANOVA

Back to the linear model

H0: μ

1 = μ

2 = μ

3 = ... = μ

i ... = μ

a = μ

If the null hypothesis is true, all samples (treatments or levels) came from the same population

Page 22: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 22

Experimental Design One-way ANOVA

Defining the linear model

If the null hypothesis is false, some samples will deviate from the grand mean by an amount called A

H0: A

1 = A

2 = A

3 = ... = A

i ... = A

a = 0

Page 23: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 23

Experimental Design One-way ANOVA

Defining the linear model

Page 24: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 24

Experimental Design One-way ANOVA

Defining the linear model

Page 25: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 25

Experimental Design One-way ANOVA

Defining the linear model

Page 26: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 26

Experimental Design One-way ANOVA

Joining the linear model andthe repartitioning of variances

Page 27: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 27

Experimental Design One-way ANOVA

Page 28: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 28

Experimental Design One-way ANOVA

Page 29: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 29

Experimental Design One-way ANOVA

Where do we know this from?

We know that a sample can also be represented by the deviations of each replicate to the sample mean (errors)

Page 30: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 30

Experimental Design One-way ANOVA

Page 31: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 31

Experimental Design One-way ANOVA

Page 32: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 32

Experimental Design One-way ANOVA

Page 33: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 33

Experimental Design One-way ANOVA

Page 34: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 34

Experimental Design One-way ANOVA

Page 35: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 35

Experimental Design One-way ANOVA

Page 36: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 36

Experimental Design One-way ANOVA

COVARIANCE

1st Assumption: individual observations are independent from each other (that is, no particular observation influences any other observation in the same or other sample)

INDEPENDENCE OF OBSERVATIONS

Page 37: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 37

Experimental Design One-way ANOVA

COVARIANCE

If observations are independent, covariance is null (zero)

INDEPENDENCE OF OBSERVATIONS

Page 38: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 38

Experimental Design One-way ANOVA

If observations are independent, covariance is null (zero)

INDEPENDENCE OF OBSERVATIONS

Page 39: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 39

Experimental Design One-way ANOVA

Let’s focus on this term...

This is the deviation of sample means from the grand mean (Remember the Central Limit Theorem?)

Page 40: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 40

Experimental Design One-way ANOVA

The central limit theorem says

Page 41: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 41

Experimental Design One-way ANOVA

2nd Assumption: sample variances are equal (homogeneous or homoscedastic)

HOMOGENEITY OF VARIANCES

Page 42: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 42

Experimental Design One-way ANOVA

2nd Assumption: sample variances are equal (homogeneous or homoscedastic)

HOMOGENEITY OF VARIANCES

Page 43: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 43

Experimental Design One-way ANOVA

2nd Assumption: sample variances are equal (homogeneous or homoscedastic)

HOMOGENEITY OF VARIANCES

Page 44: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 44

Experimental Design One-way ANOVA

2nd Assumption: sample variances are equal (homogeneous or homoscedastic)

HOMOGENEITY OF VARIANCES

Using the same argument

Page 45: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 45

Experimental Design One-way ANOVA

Page 46: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 46

Experimental Design One-way ANOVA

Change the order of “Between” and “Within” samples since this is the most common layout for an ANOVA

Page 47: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 47

Experimental Design One-way ANOVA

Introducing degrees of freedom

● For a factor with a levels: a-1

● For the within samples variation: a(n-1)

● For the Total variation: an-1

Page 48: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 48

Experimental Design One-way ANOVA

Introducing degrees of freedom

Page 49: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 49

Experimental Design One-way ANOVA

Introducing degrees of freedom and Mean Squares

Mean Square (MS) = Sum of Squares / Degrees of Freedom (SS/DF)

Page 50: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 50

Experimental Design One-way ANOVA

Introducing degrees of freedom and Mean Squares

Mean Square (MS) = Sum of Squares / Degrees of Freedom (SS/DF)

Page 51: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 51

Experimental Design One-way ANOVA

Revisiting the null hypothesisIf the null hypothesis is true, sample means will be the same as the grand mean and deviations from the latter (A

i) will be zero

H0: A

1 = A

2 = A

3 = ... = A

i ... = A

a = 0

Page 52: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 52

Experimental Design One-way ANOVA

If the null hypothesis is true

Page 53: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 53

Experimental Design One-way ANOVA

If the null hypothesis is true

Page 54: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 54

Experimental Design One-way ANOVA

Choosing a statistical test

Page 55: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 55

Experimental Design One-way ANOVA

The adequate statistical test

3th Assumption: the variable being sampled follows a normal distribution (often stated as: the population being sampled follows a normal distribution)

NORMALITY OF SAMPLED POPULATION

If this is true, the ratio between two variances follows a F-distribution

Page 56: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 56

Experimental Design One-way ANOVA

The F distribution

F ≈ 1: H0 true

F > 1: H0 false

Page 57: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 57

Experimental Design One-way ANOVA

ANOVA in action

Source of variation

SS DF MS F P

Lakes 48.933

Error 50.000

Total 98.933

Page 58: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 58

Experimental Design One-way ANOVA

ANOVA in action

Source of variation

SS DF MS F P

Lakes 48.933 2

Error 50.000 12

Total 98.933 14

Page 59: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 59

Experimental Design One-way ANOVA

ANOVA in action

Source of variation

SS DF MS F P

Lakes 48.933 2 24.467

Error 50.000 12 4.167

Total 98.933 14

Page 60: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 60

Experimental Design One-way ANOVA

ANOVA in action

Source of variation

SS DF MS F P

Lakes 48.933 2 24.467 5.872

Error 50.000 12 4.167

Total 98.933 14

Page 61: One-way ANOVA - FCUP · 09/30/12 2 Experimental Design One-way ANOVA Outline of this class Data organization and layout Repartitioning of variance Definition of a linear model Combine

09/30/12 61

Experimental Design One-way ANOVA

ANOVA in actionSource of variation

SS DF MS F P

Lakes 48.933 2 24.467 5.872

Error 50.000 12 4.167

Total 98.933 14

F > Fcrit

H0 rejected

HA accepted

Average length of fish species differs among lakes

0.017