Professional Documents
Culture Documents
Aims
Understand the basic principles of
ANOVA
Why it is done?
What it tells us?
Following up an ANOVA:
Planned Contrasts/Comparisons
Choosing Contrasts
Coding Contrasts
ANOVA
Compares several means.
Can be used when you have manipulated more
than one Independent Variables.
It is an extension of regression (the General
Linear Model)
Slide 3
1
2
3
Slide 4
Vs
Vs
Vs
Experimental Hypothesis:
The means differ.
ANOVA as Regression
Placebo Group
Libido i b0 b1
X Low X Placebo b1
b1 X Low X Placebo
ANOVA in Experiments:
Theory of ANOVA
We calculate how much variability there
is between scores
Total Sum of squares (SST).
Rationale to Experiments
Group 1
Group 2
Lecturing
Lecturing
Skills
Skills
Variance created by our manipulation
Removal of brain (systematic variance)
=
Population
No Experiment
10
M
M=
=
10
10
M
M=
=
99
M
M=
=
11
11
M
M=
=
99
M
M=
=
10
10
M
M=
=
88
M
M=
=
12
12
M
M=
=
11
11
M
M=
=
10
10
Experiment
4
Frequency
Frequency
Mean = 10
Mean = 10
SD = 1.22
SD = 1.22
0
6
10
10
11
11
Sample
SampleMean
Mean
12
12
13
13
14
14
Theory of ANOVA
We compare the amount of
variability explained by the Model
(experiment), to the error in the
model (individual differences)
This ratio is called the F-ratio.
Theory of ANOVA
ANOVA by Hand
Testing the effects of Viagra on
Libido using three groups:
Placebo (Sugar Pill)
Low Dose Viagra
High Dose Viagra
The Data
Slide 18
The
data:
Grand Mean
Slide 20
2
N 1
SST s grand
SS T 3.124 15 1
43.74
Slide 21
SS
(N 1)
SS s 2 N 1
Degrees of Freedom
(df)
Degrees of Freedom (df) are the
number of values that are free to
vary.
Think about Rugby Teams!
dfT N 1 15 1 14
Slide 22
Grand Mean
Slide 23
Slide 24
Model Degrees of
Freedom
How many values did we use to
calculate SSM?
We used the 3 means.
df M k 1 3 1 2
Slide 25
Grand Mean
Df = 4
Slide 26
Df = 4
Df = 4
2
si
ni 1
SS
(N 1)
SS s 2 N 1
2
2
2
1 n1 1 s group
SS R s group
n
s
2 2
group 3 n3 1
Slide 27
SS R s group
n
s
2 2
group 3 n3 1
Slide 28
Residual Degrees of
Freedom
How many values did we use to
calculate SSR?
We used the 5 scores for each of the
SS for each group.
Slide 29
Double Check
SST SS M SS R
43.74 20.14 23.60
43.74 43.74
SS M 20.135
MS M
10.067
df M
2
SS R 23.60
MSR
1.967
dfR
12
Slide 31
5.12
MS R
1.967
Slide 32
Slide 33
Source
SS
df
MS
Model
20.1
4
10.06
7
5.12*
Residu
al
23.6
0
12
1.967
Total
43.7
4
14
How?
Multiple t-tests
We saw earlier that this is a bad idea
Orthogonal Contrasts/Comparisons
Hypothesis driven
Planned a priori
Trend Analysis
Slide 35
Planned Contrasts
Basic Idea:
The variability explained by the Model
(experimental manipulation, SSM) is due
to participants being assigned to different
groups.
This variability can be broken down
further to test specific hypotheses about
which groups might differ.
We break down the variance according to
hypotheses made a priori (before the
experiment).
Its like cutting up a cake (yum yum!)
Slide 36
Only 2 Chunks
Each contrast should compare only 2
chunks of variation (why?).
K-1
You should always end up with one less
contrast than the number of groups.
Slide 37
Generating Hypotheses
Example: Testing the effects of Viagra
on Libido using three groups:
Placebo (Sugar Pill)
Low Dose Viagra
High Dose Viagra
Placebo
Mean
Slide 39
2.20
3.20
5.00
How do I Choose
Contrasts?
Big Hint:
In most experiments we usually have one
or more control groups.
The logic of control groups dictates that
we expect them to be different to groups
that weve manipulated.
The first contrast will always be to
compare any control groups (chunk 1)
with any experimental conditions (chunk
2).
Slide 40
Hypotheses
Hypothesis 1:
People who take Viagra will have a higher
libido than those who dont.
Placebo (Low, High)
Hypothesis 2:
People taking a high dose of Viagra will
have a greater libido than those taking a
low dose.
Low High
Slide 41
Planned Comparisons
Slide 42
Another Example
Another Example
Coding Planned
Contrasts: Rules
Rule 1
Groups coded with positive weights
compared to groups coded with negative
weights.
Rule 2
Rule 3
Slide 45
Rule 5
If a group is singled out in a comparison,
then that group should not be used in any
subsequent contrasts.
Slide 46
Using aov():
viagraModel<-aov(libido ~ dose, data =
viagraData)
summary(viagraModel)
plot(viagraModel)
Output
Robust ANOVA
Require the data to be in wide format
rather than the long format.
We can reformat the data using
unstack():
viagraWide<-unstack(viagraData, libido ~
dose)
viagraWide
Robust ANOVA
For an ANOVA of the Viagra data
based on 20% trimmed means:
t1way(viagraWide)
Robust Output
Output
Slide 63
Tukey
For the Viagra data, we can obtain
Tukey post hoc tests by executing:
postHocs<-glht(viagraModel, linfct =
mcp(dose = "Tukey"))
summary(postHocs)
confint(postHocs)
Output
Polynomial contrasts:
trend analysis
Trend Analysis
Follow the general procedure of setting
the contrast attribute of the predictor
variable:
contrasts(viagraData$dose)<-contr.poly(3)