Docsity

R studio - 4 anova statistica, Appunti di Elementi di Informatica

Toggle sidebar
bg1
Comparison of means of multiple groups
When we have many (more than 2) groups, we may think to
perform t-tests for µ1=µ2,thenµ1=µ3,thenµ2=µ3...
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Anteprima parziale del testo

Scarica R studio - 4 anova statistica e più Appunti in PDF di Elementi di Informatica solo su Docsity!

Comparison of means of multiple groups

When we have many (more than 2) groups, we may think to

perform t-tests for μ 1

= μ 2

, then μ 1

= μ 3

, then μ 2

= μ 3

Comparison of means of multiple groups

When we have many (more than 2) groups, we may think to

perform t-tests for μ 1 = μ 2 , then μ 1 = μ 3 , then μ 2 = μ 3...

Why is this not appropriate? not optimal?

Comparison of means of multiple groups

When we have many (more than 2) groups, we may think to

perform t-tests for μ 1

= μ 2

, then μ 1

= μ 3

, then μ 2

= μ 3

Why is this not appropriate? not optimal?

If we perform many tests, we need to correct probability levels. If

we perform 20 tests, each with 5% probability of being positive, we

suspect some may become positive just for chance...

Tests are not independent...

Comparison of means of multiple groups

When we have many (more than 2) groups, we may think to

perform t-tests for μ 1 = μ 2 , then μ 1 = μ 3 , then μ 2 = μ 3...

Why is this not appropriate? not optimal?

If we perform many tests, we need to correct probability levels. If

we perform 20 tests, each with 5% probability of being positive, we

suspect some may become positive just for chance...

Tests are not independent...

Proper way to correcting for this: analysis of variance.

One-way analysis of variance

We have measured a response variable Y in g groups.

Example: Yield under a control and two treatments

1

ctrl trt1 trt

Box-plots of yield

Yield

Question: Is yield di↵erent under control and treatments?

1 data from Dobson, A. J. (1983) An Introduction to Statistical Modelling in

the standard R library

Formulae in analysis of variance

Y

ik

⇠ N(μ i

2

), i = 1,... , g (groups)

H 0 : μ i

⌘ μ,

2 > 0.

H

1

: di↵erences among μ i

2 > 0.

Note; if g = 2 test on equality of means (t-test).

Method: decomposition of variance

P

i,k

(Y

ik

Y )

2

P

i

n i

Y

i

Y )

2

P

i

P

k

(Y

ik

Y

i

2 .

total variation variation variation

among groups within groups

Y

i

: mean in group i,

Y general mean.

M.C. Whitlock, Dolph Schluter, ANALISI STATISTICA DEI DATI BIOLOGICI, Zanichelli editore S.p.A. Copyright © 2010 15 | 3

L’idea dell’analisi della varianza

Le deviazioni delle osser-

vazioni dalla media generale

Le deviazioni delle medie dei

gruppi dalla media generale

Le deviazioni delle osser-

vazioni dalla media del

gruppo a cui appartengono

Somma dei quadrati di

queste deviazioni =

SS_total

Somma dei quadrati di

queste deviazioni =

SS_among

Somma dei quadrati di

queste deviazioni =

SS_within

SS_total = SS_among + SS_within

Hypothesis testing in analysis of variance

Under H 0

(all μ i

equal)

2

SSamong =

2

X

i

n i

Y

i

Y )

2

⇠

2

(g 1)

2

SS

within

2

X

i

X

k

(Y

ik

Y

i

2

⇠

2

((n 1)g )

and they are independent.

[Formulae true with equal size n of all groups]

Hence the distribution of

SS

among

/(g 1)

SS

within

/((n 1)g )

is known and is called F g 1 ,(n1)g

Analysis of variance: R

2

A related quantity

R

2

=

SSamong

SS

total

‘variance’ ‘explained’ by model

total ‘variance’

Necessarily 0  R

2  1.

HIgh R

2 and rejection of H 0 are di↵erent (though related) facts.

R-squared in the example: 0.

M.C. Whitlock, Dolph Schluter, ANALISI STATISTICA DEI DATI BIOLOGICI, Zanichelli editore S.p.A. Copyright © 2010 15 | 4

Test di significatività della differenza fra le medie

tramite il confronto con la distribuzione F

Paired comparisons

But which is the correct level of significance?

We may be comparing only groups whose means appear

particularly di↵erent. If there are 6 groups, there would be 15

possible comparisons. The probability that at least one of them

would be beyond the nominal 5% level is much higher...

One solution is called Tukey’s HSD (Honest Significant Di↵erence)

that looks at the distribution of maximum di↵erence(R command

TukeyHSD(aov(weight ~ group, data = PlantGrowth))):

di↵ lwr upr p adj

trt1-ctrl 0. 371 1. 0622161 0.3202161 0.

trt2-ctrl 0.494 0. 1972161 1.1852161 0.

trt2-trt1 0.865 0.1737839 1.5562161 0.

We can conclude that the yield with treatment 2 is significantly

di↵erent (higher) than with treatment 1.

M.C. Whitlock, Dolph Schluter, ANALISI STATISTICA DEI DATI BIOLOGICI, Zanichelli editore S.p.A. Copyright © 2010 15 | 5

Presentazione finale dei dati con il

risultato dei confronti fra gruppi: il gruppo

con etichetta a è significativamente

diverso dai gruppi con etichetta b

M.C. Whitlock, Dolph Schluter, ANALISI STATISTICA DEI DATI BIOLOGICI, Zanichelli editore S.p.A. Copyright © 2010 18 | 4

Illustrazione grafica di analisi della varianza a 2 vie con effetti additivi

da

M.C. Whitlock, Dolph Schluter, ANALISI STATISTICA DEI DATI BIOLOGICI, Zanichelli editore S.p.A. Copyright © 2010 18 | 5

da

Illustrazione grafica di analisi della varianza a 2 vie con

interazione