Overview Kursus 02402 Introduction to Statistics Oneway analysis - - PowerPoint PPT Presentation

overview kursus 02402 introduction to statistics
SMART_READER_LITE
LIVE PREVIEW

Overview Kursus 02402 Introduction to Statistics Oneway analysis - - PowerPoint PPT Presentation

Overview Kursus 02402 Introduction to Statistics Oneway analysis of Variance (ANOVA) 1 Intro Example Lecture 12: Analysis of Variance Model and hypothesis Computation - decomposition of variance and the ANOVA table Test, F-distributions


slide-1
SLIDE 1

Kursus 02402 Introduction to Statistics Lecture 12: Analysis of Variance Per Bruun Brockhoff

DTU Informatics Building 305 - room 110 Danish Technical University 2800 Lyngby – Denmark e-mail: pbb@imm.dtu.dk

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 1 / 36

Overview

1

Oneway analysis of Variance (ANOVA) Intro Example Model and hypothesis Computation - decomposition of variance and the ANOVA table Test, F-distributions Example 1 Post hoc comparisons

2

Two-way ANOVA Example 2 Model and variance decomposition The ANOVA Table Example 2

3

R (R note 11)

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 2 / 36 Oneway analysis of Variance (ANOVA) Intro Example

Oneway ANOVA, example Group A Group B Group C 2.8 5.5 5.8 3.6 6.3 8.3 3.4 6.1 6.9 2.3 5.7 6.1 Is there a difference in the means of the groups A, B and C? Analysis of variance (ANOVA) can be applied for the analysis if it can be assumed that the observations in each

  • f the group are normally distributed with constant

variance.

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 4 / 36 Oneway analysis of Variance (ANOVA) Intro Example

Oneway ANOVA, example

A B C 3 4 5 6 7 8

Graphical comparison of 3 groups

groups response Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 5 / 36

slide-2
SLIDE 2

Oneway analysis of Variance (ANOVA) Intro Example

Oneway ANOVA, example

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 6 / 36 Oneway analysis of Variance (ANOVA) Intro Example

Oneway ANOVA, example

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 7 / 36 Oneway analysis of Variance (ANOVA) Model and hypothesis

One-Way ANOVA, the model We consider the model Yij = µ + αi + ǫij where it is assumed that ǫij ∼ N(0, σ2) µ is the mean of all the observations αi gives the level of ’group’ i

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 8 / 36 Oneway analysis of Variance (ANOVA) Model and hypothesis

One-Way ANOVA, the hypothesis We want to compare (more than two) means µ + αi in the model Yij = µ + αi + ǫij, ǫij ∼ N(0, σ2) that is, we can formulate the hypotheses: H0 : αi = 0 for all i H1 : αi = 0 for at least one i

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 9 / 36

slide-3
SLIDE 3

Oneway analysis of Variance (ANOVA) Computation - decomposition of variance and the ANOVA table

One-Way ANOVA, the decomposition Corresponding to the model Yij = µ + αi + ǫij, ǫij ∼ N(0, σ2) the total variation in the data can be R note it up into: SST = SS(Tr) + SSE ’One-way’ means that we only have one factor on k levels to examine. The method is called analysis of variance, since the tests are carried out by comparing variances.

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 10 / 36 Oneway analysis of Variance (ANOVA) Computation - decomposition of variance and the ANOVA table

Formulas for Sums of Squares SST =

k

  • i=1

ni

  • j=1

y2

ij − C

SS(Tr) =

k

  • i=1

T 2

i

ni − C where C = T 2

.

N Ti =

ni

  • j=1

yij

  • T. =

k

  • i=1

Ti

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 11 / 36 Oneway analysis of Variance (ANOVA) Computation - decomposition of variance and the ANOVA table

The ANOVA Table Source of Degrees of Sums of Test- variation freedom squares statistic F Treatment k − 1 SS(Tr)

SS(Tr)/(k−1) SSE/(N−k)

Residual N-k SSE Total N-1 SST

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 12 / 36 Oneway analysis of Variance (ANOVA) Test, F-distributions

One-Way ANOVA, the F-test We have: SST = SS(Tr) + SSE and the test statistic, F: F = SS(Tr)/(k − 1) SSE/(N − k) where k is the number of levels of the factor and N is the total number of observations.

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 13 / 36

slide-4
SLIDE 4

Oneway analysis of Variance (ANOVA) Test, F-distributions

One-Way ANOVA, test The test statistic F is calculated and the level of significance α chosen F = SS(Tr)/(k − 1) SSE/(N − k) The test statistic is compared to a quantile in the F distribution: F ∼ Fα(k − 1, N − k)

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 14 / 36 Oneway analysis of Variance (ANOVA) Test, F-distributions

F-distributions

1 2 3 4 5 6 0.0 0.2 0.4 0.6

Example of a F−distribution

x density

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 15 / 36 Oneway analysis of Variance (ANOVA) Test, F-distributions

F-distributions

1 2 3 4 5 6 0.0 0.2 0.4 0.6

Hypotheses test

x density Acceptance region Critical region F(f1,f2)

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 16 / 36 Oneway analysis of Variance (ANOVA) Test, F-distributions

F-distributions

1 2 3 4 5 6 0.0 0.2 0.4 0.6

Hypotheses test

x density Acceptance region Critical region F(f1,f2) 5 % 95 %

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 17 / 36

slide-5
SLIDE 5

Oneway analysis of Variance (ANOVA) Example 1

Example 1 For measurements of the gravitational constant, G, Heyl (1930) used balls of three different materials and got the following observations of G (unity 10−11Nm2kg−2) Material Measurement Gold 6.683 6.681 6.676 6.678 6.679 Platinum 6.661 6.661 6.667 6.667 6.664 Glass 6.678 6.671 6.675 6.672 6.674

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 18 / 36 Oneway analysis of Variance (ANOVA) Example 1

Example 1

1.0 1.5 2.0 2.5 3.0 6.665 6.670 6.675 6.680 maal Guld Platin Glas

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 19 / 36 Oneway analysis of Variance (ANOVA) Example 1

Example I Set up a statistical model for the experiment, and test if there is a difference in the estimated gravitation constant for the 3 materials. Use a significance level of α = 5%

  • Var. source

SSQ df MS F-test Material 6.1053 · 10−4 Residual 9.5200 · 10−5 Total 7.0573 · 10−4

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 20 / 36 Oneway analysis of Variance (ANOVA) Post hoc comparisons

Post hoc Confidence interval (Page 366) ¯ y1 − ¯ y2 ± tα/2

  • s2

1 n1 + 1 n2

  • Per Bruun Brockhoff (pbb@imm.dtu.dk)

Introduction to Statistics, Lecture 12 Fall 2012 21 / 36

slide-6
SLIDE 6

Two-way ANOVA Example 2

Example 2 A hearing aid has to be adjusted individually. One way to validate a hearing aid is to play a list (or series) of words at a low volume and then ask the patient to repeat the words. I a study it was desired to compare 4 different lists, which should have the same degree of difficulty and the same amount of words Test list I 28 24 32 30 34 30 36 32 ... 40 list II 20 16 38 20 34 30 30 28 ... 44 list III 24 32 20 14 32 22 20 26 ... 34 list IV 26 24 22 18 24 30 22 28 ... 42

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 23 / 36 Two-way ANOVA Example 2

Example 2 Put up a statistical model for the experiment. Account for how you can test if there is a difference in the degree of difficulty for the 4 lists. Should the experiment has been performed differently to be sure that the results are valid?

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 24 / 36 Two-way ANOVA Example 2

Example 2 It turns out, that it is the same 24 persons that is used in all of the four lists, which is shown in the table Test/Person 1 2 3 4 5 6 7 8 24 list I 28 24 32 30 34 30 36 32 ... 40 list II 20 16 38 20 34 30 30 28 ... 44 list III 24 32 20 14 32 22 20 26 ... 34 list IV 26 24 22 18 24 30 22 28 ... 42

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 25 / 36 Two-way ANOVA Example 2

Two-way ANOVA We assume now that we have the following model Yij = µ + αi + βj + ǫij, ǫij ∼ N(0, σ2) that is, we have two factors, α and β, where β can also be considered to be a block variable. In that case the design is called a randomized block design.

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 26 / 36

slide-7
SLIDE 7

Two-way ANOVA Example 2

Two-way ANOVA A1 A2 A3 B1 x x x B2 x x x B3 x x x B4 x x x

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 27 / 36 Two-way ANOVA Model and variance decomposition

Two-way ANOVA, Model and variance decomposition When β represents a block variable we have the model Xij = µ + αi + βj + ǫij, ǫij ∼ N(0, σ2) and SST = SS(Tr) + SS(Bl) + SSE

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 28 / 36 Two-way ANOVA The ANOVA Table

The ANOVA Table Source of Degrees of Sums of Test variation freedom squares statistic F Treatment a − 1 SS(Tr)

SS(Tr)/(a−1) SSE/((a−1)(b−1))

Block b − 1 SS(Bl)

SS(Bl)/(b−1) SSE/((a−1)(b−1))

Residual (a − 1)(b − 1) SSE Total N − 1 SST Critical value for blocks: Fα(b − 1, (a − 1)(b − 1)) Critical value for treatment: Fα(a − 1, (a − 1)(b − 1))

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 29 / 36 Two-way ANOVA Example 2

Example 2 It turns out, that it is the same 24 persons that is used in all of the four lists, which is shown in the table Test/Person 1 2 3 4 5 6 7 8 24 list I 28 24 32 30 34 30 36 32 ... 40 list II 20 16 38 20 34 30 30 28 ... 44 list III 24 32 20 14 32 22 20 26 ... 34 list IV 26 24 22 18 24 30 22 28 ... 42

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 30 / 36

slide-8
SLIDE 8

Two-way ANOVA Example 2

Example 2 Set up a statistical model for the experiment. Account for how you can test if there is a difference in the degree of difficulty for the 4 lists.

  • Var. source

SSQ df MS F test List 920.5 Person 3231.6 Residual 2506.5 Total 6658.6

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 31 / 36 Two-way ANOVA Example 2

Example 2

List1 List2 List3 List4 15 20 25 30 35 40 45

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 32 / 36 R (R note 11)

R (R note 11)

> attach(C12tin) > Lab <- factor(Lab) > anova(lm(weight~Lab)) Analysis of Variance Table Response: weight Df Sum Sq Mean Sq F value Pr(>F) Lab 3 0.013006 0.0043354 2.8097 0.05038 . Residuals 44 0.067892 0.0015430

  • Signif. codes:

0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 34 / 36 R (R note 11)

R (R note 12)

> attach(example) > treatm <- factor(treatm) > block <- factor(block) > anova(lm(y~treatm+block)) Analysis of Variance Table Response: y Terms added sequentially (first to last) Df Sum of Sq Mean Sq F Value Pr(F) treatm 2 56 28.00000 3.230769 0.1116192 block 3 90 30.00000 3.461538 0.0913831 Residuals 6 52 8.66667

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 35 / 36

slide-9
SLIDE 9

R (R note 11)

Overview

1

Oneway analysis of Variance (ANOVA) Intro Example Model and hypothesis Computation - decomposition of variance and the ANOVA table Test, F-distributions Example 1 Post hoc comparisons

2

Two-way ANOVA Example 2 Model and variance decomposition The ANOVA Table Example 2

3

R (R note 11)

Per Bruun Brockhoff (pbb@imm.dtu.dk) Introduction to Statistics, Lecture 12 Fall 2012 36 / 36