Transcript Document

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
Yield (tonnes)
7
6
5
Overall
mean
4
3
2
Fert 1
1
Fert 3
Fert 2
0
0
10
20
Plot number
30
Within group SS= deviations around group means
Group means
8
Yield (tonnes)
7
6
5
4
3
2
Fert 1
1
Fert 3
Fert 2
0
0
10
20
Plot number
30
Among groups SS=deviations of group means from
overall mean
Group means
8
Yield (tonnes)
7
6
5
Overall
mean
4
3
2
Fert 1
1
Fert 3
Fert 2
0
0
10
20
Plot number
30
Mean squares
Combine information on SS and df
Total mean squares = total SS/ total df
total variance of data set
Within group mean squares = within SS/ within df
variance (per df) among units given
Error MS
same treatment
Unfortunate
word usage
Among groups mean squares = among SS / among df
variance (per df) among units given
different treatments
 The question: Does fitting the treatment mean
explain a significant amount of variance?
F=
Among groups mean squares
Within group mean squares
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 rats per drug
3 skin samples per rat
Each sample divided in to 2 lots, each hydrolyzed
2 optical density readings per hydrolyzed sample
Random effects
5 drugs + 1 control= 6 groups (fixed effect)
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 fixed
Prey type probably always fixed?
-- Effect of drug treatment and gender on patient survival
Drug treatments must be same for both genders
Drug could be random or fixed
Gender 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
a
b
n
Total SS =    (Xijl –X)2
i=1 j=1 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)
a
Factor A SS = bn  (Xi –X)2
i=1
Then
--Consider B to be the only factor in a 1-way ANOVA
b
Factor B SS = an  (Xj –X)2
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.
Erin H.
NPP (mgO2/m2/2hr)
No difference of either factor and no interaction
Low light
High light
20
10
0
With zm
Without zm
Dave H.
Significant main effect of light
NPP (mgO2/m2/2hr)
Low light
High light
20
10
0
With zm
Without zm
Jhonathon
Significant main effect of ZM
NPP (mgO2/m2/2hr)
Low light
High light
20
10
0
With zm
Without zm
Both main effects are significant, but no interaction
NPP (mgO2/m2/2hr)
Josh S.
Anthony
Low light
High light
20
10
0
With zm
Without zm
Significant interaction, but no significant main effect
NPP (mgO2/m2/2hr)
Colin
Xiao-Jain
Low light
High light
20
10
0
With zm
Without zm
Interaction and the main light effect are significant
NPP (mgO2/m2/2hr)
Rajan
Coleen
Low light
High light
20
10
0
With zm
Without zm
Interaction and the main zm effet are significant
NPP (mgO2/m2/2hr)
Chen-Lin
Nan
Low light
High light
20
10
0
With zm
Without zm
the interaction and both main effects are significant
NPP (mgO2/m2/2hr)
Reza
Malak
Low light
High light
20
10
0
With zm
Without zm
the interaction and both main effects are significant
NPP (mgO2/m2/2hr)
Chenxi
Damien
Low light
High light
20
10
0
With zm
Without zm
How to in SAS:
Data X; set Y;
proc glm;
class gender salary;
model shoepair=gender salary gender*salary;
interaction
Main effects
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 drug
Variables =
Drug
PreTreatment
- two antibiotics (A and D) & control (F)
- 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 ;
Different way to read in data
proc glm;
class Drug; Define categorical variable
model PostTreatment = Drug PreTreatment
Drug*PreTreatment / solution;
run;
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
** use Type III SS
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
Standard Error
t Value
Pr > |t|
Parameter
Estimate
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
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.
light
shade
rock
-2
log periphyton chlorophyll-a (mg m )
3
2
rock: r2 = 0.19, p<0.13
light: r2 = 0.47, p<0.02
1
shade: r2 <0.01, p<0.78
0
0
1
-1
log-TP in water (μg L-1)
2
3