More complicated ANOVA models: two-way and repeated measures

Post on 01-Jan-2016

45 views 2 download

Tags:

description

More complicated ANOVA models: two-way and repeated measures Chapter 12 Zar Chapter 11 Sokal & Rohlf. First, remember your ANOVA basics………. -Total SS in 1-way ANOVA -Deviations around total mean. 8. 7. 6. 5. Overall mean. Yield (tonnes). 4. 3. 2. Fert 1. Fert 3. Fert 2. 1. 0. 0. - PowerPoint PPT Presentation

Transcript of More complicated ANOVA models: two-way and repeated measures

More complicated ANOVA models: two-way and repeated measures

Chapter 12 Zar Chapter 11 Sokal & Rohlf

First, remember your ANOVA basics……….

0

1

2

3

4

5

6

7

8

0 10 20 30

Plot number

Yie

ld (

ton

ne

s)

-Total SS in 1-way ANOVA

-Deviations around total mean

Fert 1 Fert 2 Fert 3

Overall mean

0

1

2

3

4

5

6

7

8

0 10 20 30

Plot number

Yie

ld (

ton

ne

s)

Fert 1 Fert 2 Fert 3

Group means

Within group SS= deviations around group means

0

1

2

3

4

5

6

7

8

0 10 20 30

Plot number

Yie

ld (

ton

ne

s)

Fert 1 Fert 2 Fert 3

Overall mean

Group means

Among groups SS=deviations of group means from overall mean

Mean squaresCombine information on SS and df

Total mean squares = total SS/ total dftotal variance of data set

Within group mean squares = within SS/ within dfvariance (per df) among units given

same treatment

Among groups mean squares = among SS / among dfvariance (per df) among units given different treatments

Unfortunate word usage

Error MS

Among groups mean squares

Within group mean squaresF =

The question: Does fitting the treatment mean explain a significant amount of variance?

Compare calculated F to critical value from table (B4)

If calculated F as big or bigger than critical value, then reject H0

But remember…….

H0: m1 = m2 = m3

Need separate test (multiple comparison test) to tell which means differ from which

Factorial ANOVA= simultaneous analysis of the effect of more than one factor on population means

-- Effect of light (or music) and water on plant growth

-- Effect of drug treatment and gender on patient survival

--Effect of turbidity and prey type on prey consumption by yellow perch

--Effect of gender and income bracket on # pairs of shoes owned

Two-way ANOVA vs a nested (hierarchical) ANOVA see chapter 10 S& R

Example: the effect of drug on quantity of skin pigment in rats.

5 drugs + 1 control= 6 groups (fixed effect)

5 rats per drug

3 skin samples per rat

Each sample divided in to 2 lots, each hydrolyzed

2 optical density readings per hydrolyzed sample Ran

do

m e

ffec

ts

Drug is the main factor of interest

All other levels are subordinate

Rat1 in drug treatment 1 is not the same as Rat1 in drug treatment 2

Above design is nested. Rats are nested within drug treatment, skin sample is nested within rat etc…….

Can be mixed model (as in example) where primary effect is fixed (drug) but subordinate levels are random

Or can be completely random model if the levels (eg drugs) were truly a random sample of all possible drugs

Two-way ANOVA, Two-factor ANOVA

There must be correspondence across classes

--Effect of turbidity level and prey type on prey consumption by yellow perch

High and low turbidity must be the same across all prey types

Turbidity could be random or fixedPrey type probably always fixed?

-- Effect of drug treatment and gender on patient survivalDrug treatments must be same for both gendersDrug could be random or fixedGender always fixed?

Terminology

--Two factors A and B

-- a = number of levels of A; starting with i

-- b = number of levels of B; starting with j

-- n = number replicates; starting with l

-- Each combination of a level of A with a level of B is called a cell

-- Cell analogous to groups in 1-way ANOVA

--If there are 2 levels of 2 factors analysis called 2 x 2 factorial

Low A High A

Low B Low A

Low B

High A

Low B

High B Low A

High B

High A

High B

cell

Total SS = (Xijl –X)2a

i=1

b

j=1

n

l=1

= (all deviations from grand mean)2

Total DF = N-1

Among Cell SS = variability between cell means and grand mean

--among cell DF= ab-1--Analogous to among groups SS in 1-way ANOVA

Within Cell SS = deviations from each cell mean

--within cell DF = ab (n-1)--analogous to within groups SS in 1-way ANOVA

But……. Goal of 2-way ANOVA is to assess the affects of each of the 2 factors independently of each other

--Consider A to be the only factor in a 1-way ANOVA (ignore B)

Factor A SS = bn (Xi –X)2a

i=1

Then

--Consider B to be the only factor in a 1-way ANOVA

Factor B SS = an (Xj –X)2b

j=1

Now the tricky part……………

-- Among cell variability usually variability among levels of A + variability among levels of B

-- The unaccounted for variability is due to the effect of interaction

-- Interaction means that the effect of A is not independent of the presence of a particular level of B

--Interaction effect is in addition to the sum of the effects of each factor considered separately

With zm Without zm

Low light With zm

Low light

Without zm

Low light

High light With zm

High light

Without zm

High light

Grow algae two levels of light and with and without zebra mussels, 15 reps in each cell, N=60

Measure net primary production of the algae (NPP)

We will now graphically examine a range of outcomes of this 2x2 factorial ANVOA

Some of the possible outcomes have below.

Be prepared to discuss the meaning –ie, your interpretation of the graph with your name on it.

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

No difference of either factor and no interaction

High lightLow light

Erin H.

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Significant main effect of light

High lightLow light

Dave H.

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Significant main effect of ZM

High lightLow light

Jhonathon

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Both main effects are significant, but no interaction

High lightLow light

Josh S.Anthony

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Significant interaction, but no significant main effect

High lightLow light

ColinXiao-Jain

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Interaction and the main light effect are significant

High lightLow light

RajanColeen

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20

Interaction and the main zm effet are significant

High lightLow light

Chen-LinNan

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20High lightLow light

the interaction and both main effects are significant

RezaMalak

With zm Without zm

NP

P (

mg

O2/

m2/

2hr)

0

10

20High lightLow light

the interaction and both main effects are significant

ChenxiDamien

How to in SAS:

Data X; set Y; proc glm; class gender salary; model shoepair=gender salary gender*salary;

Main effectsinteraction

Analysis of covariance (ANCOVA)

-Testing for effects with one categorical and one continuous predictor variable

-Testing for differences between two regressions

-Some of the features of both regression and analysis of variance.

-A continuous variable (the covariate) is introduced into the model of an analysis-of-variance experiment.

Initial assumption that there is a linear relationship between the response variable and the covariate

If not, ANCOVA no advantage over simple ANOVA

Ex. Test of leprosy drugVariables =               

Drug - two antibiotics (A and D) & control (F)

PreTreatment - a pre-treatment score of leprosy bacilli

PostTreatment - a post-treatment score of leprosy bacilli

-10 patients selected for each drug) -6 sites on each measured for leprosy bacilli. -Covariate = pretreatment score included in model for increased precision in determining the effect of drugs on the posttreatment count of bacilli.

data drugtest; input Drug $ PreTreatment PostTreatment @@;

datalines; A 11 6 A 8 0 A 5 2 A 14 8 A 19 11 A 6 4 A 10 13 A 6 1 A 11 8 A 3 0 D 6 0 D 6 2 D 7 3 D 8 1 D 18 18 D 8 4 D 19 14 D 8 9 D 5 1 D 15 9 F 16 13 F 13 10 F 11 18 F 9 5 F 21 23 F 16 12 F 12 5 F 12 16 F 7 1 F 12 20 ;

proc glm; class Drug; model PostTreatment = Drug PreTreatment Drug*PreTreatment / solution; run;

Different way to read in data

Define categorical variable

Model dependent var=categorical variable covariate and categorical * covariate interaction

First, slopes must be equal to proceed with other comparisons.

If interaction term significant- end of test

If interaction term not significant can compare intercepts (means)

Source DF Type I SS Mean Square F Value Pr > F

Drug 2 293.6000000 146.8000000 9.15 0.0010

PreTreatment 1 577.8974030 577.8974030 36.01 <.0001

  Source DF Type III SS Mean Square F Value Pr > F

Drug 2 68.5537106 34.2768553 2.14 0.1384

PreTreatment 1 577.8974030 577.8974030 36.01 <.0001

  Parameter Estimate   Standard Error t Value Pr > |t|

Intercept -0.434671164 B 2.47135356 -0.18 0.8617

Drug A -3.446138280 B 1.88678065 -1.83 0.0793

Drug D -3.337166948 B 1.85386642 -1.80 0.0835

Drug F 0.000000000 B . . .

PreTreatment 0.987183811   0.16449757 6.00 <.0001

** u

se T

ype

III

SS

Type I SS for Drug gives the between-drug sums of squares for ANOVA model PostTreatment=Drug.

Measures difference between arithmetic means of posttreatment scores for different drugs, disregarding the covariate.

The Type III SS for Drug gives the Drug sum of squares adjusted for the covariate.

Measures differences between Drug LS-means, controlling for the covariate.

The Type I test is highly significant (p=0.001), but the Type III test is not.

Therefore, while there is a statistically significant difference between the arithmetic drug means, this difference is not significant when you take the pretreatment scores into account.

rock: r2 = 0.19, p<0.13

light: r2 = 0.47, p<0.02

shade: r2 <0.01, p<0.78

-1

0

1

2

3

0 1 2 3

log-TP in water (μg L-1)

log p

erip

hyto

n c

hlo

roph

yll

-a

(m

g m

-2) light

shaderock