22s:152 Applied Linear Regression
Chapter 8:
1Way Analysis of Variance (ANOVA)
2Way Analysis of Variance (ANOVA)
————————————————————
•
We now consider an analysis with only
cate
gorical predictors (i.e. all predictors are
factors
).
–
Predicting height from sex (M/F)
–
Predicting white blood cell count from treat
ment group (A,B,C)
•
If only 1 categorical predictor of a continuous
response
⇒
OneWay ANOVA
μ
1
μ
2
μ
3
For example,
μ
dem
μ
rep
μ
ind
1
1way ANOVA visual:
0
5
10
15
20
25
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
Y
In a 1way ANOVA, we’re interested in find
ing di
ff
erences between population group means,
if they exist.
———————————————————
•
If two categorical predictors of a continuous
response
⇒
TwoWay ANOVA
μ
11
μ
12
μ
13
μ
21
μ
22
μ
23
For example,
Factor 1
low
med
high
Factor 2 yes
no
2
1way ANOVA
(only one factor)
•
Consider the
cell means model
notation:
(It uses 1 parameter to represent each cell mean)
Y
ij
=
μ
i
+
ij
where
μ
i
is the group
i
mean.
•
If there’s only 2 levels, like in sex, then we
can use a twosample
t
test
H
0
:
μ
1
=
μ
2
.
•
If we have
more
than 2 levels, we extend this
t
test idea to do a 1way ANOVA.
•
A twosample
t
test is essentially a 1way
ANOVA (it’s the simplest one, there’s only 2
levels to the factor)
3
•
Suppose we have three populations (or 3 lev
els of a categorical variable) to compare...
Example
: Does the presence of pets or friends
a
ff
ect the response to stress?
n
= 45 women (all dog lovers)
Each woman randomly assigned to one of
three treatment groups as:
1) alone
2) with friend
3) with pet
Their heart rate is taken and recorded during
a stressful task.
Allen, Blascovich, Tomaka, Kelsey, 1988, Journal of Personality and So
cial Psychology.
4
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
> pets=read.csv("pets.csv")
> head(pets)
group
rate
1
P 69.169
2
F 99.692
3
P 70.169
4
C 80.369
5
C 87.446
6
P 75.985
> attach(pets)
> is.factor(group)
[1] TRUE
The treatment groups
are:
‘C’ for control group or
alone
.
‘F’ for
with friend
.
‘P’ for
with pet
.
Consider the distribution of heart rate by
treatment group...
5
> boxplot(rate~group)
●
C
F
P
60
70
80
90
100
> table(group)
group
C
F
P
15 15 15
This is a balanced
1way ANOVA since all
groups have the same number of subjects.
6
Get the mean of each group.
> tapply(rate,group,mean)
C
F
P
82.52407 91.32513 73.48307
If we consider
μ
1
as the population mean
heart rate of the control group,
μ
2
as the population mean heart rate of the
friends group,
μ
3
as the population mean heart rate of the
pet group,
then, to test if any of the groups have a di
ff
er
ent heart rate, we would consider the ‘overall’
null hypothesis
H
0
:
μ
1
=
μ
2
=
μ
3
H
A
: at least one
μ
i
is di
ff
erent for
i
=1,2,3
7
Why not just do 3 pairwise comparisons?
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '13
 Sun
 Statistics, Linear Regression, Variance, 1way ANOVA

Click to edit the document details