ANOVA:
Analysis of Variation
ANOVA:
Learning Objectives
• Underlying methodological principles of
ANOVA
• Statistical principles: Partitioning of
variability
• Summary table for one-way ANOVA
t-Test vs ANOVA:
The Case for Multiple Groups
• t-tests can be used to compare mean differences for two
groups
• Between Subject Designs
• Within Subject Designs
• Paired Samples Designs
• The test allows us to make a judgment concerning
whether or not the observed differences are likely to have
occurred by chance.
• Although helpful the t-test has its problems
Multiple Groups
• Two groups are often insufficient
• No difference between Therapy X and Control:
Are other therapies effective?
• .05mmg/l Alcohol does not decrease memory
ability relative to a control: What about other
doses?
• What if one control group is not enough?
Multiple Groups 2
• With multiple groups we could make multiple
comparisons using t-tests
• Problem: We would expect some differences in
means to be significant by chance alone
• How would we know which ones to trust?
Comparing Multiple Groups: The
“One-Way” Design
Alcohol Level (Dose in mg/kg)
0 (Control) 10 20
.......
• Independent variable (“factor”):
• Dependent variable
(“measurement”):
• Analysis: Variation between and within conditions
Analysis of Variance (F test):
Advantages
•
Provides an omnibus test & avoids multiple t-tests and
spurious significant results
•
it is more stable since it relies on all of the data ...
•
recall from your work on Std Error and T-tests
• the smaller the sample the less
stable are the population
parameter estimates.
What does ANOVA do
• Provides an F ratio that has an underlying
distribution which we use to determine statistical
significance between groups (just like a t-test or a
z-test)
• e.g., Take an experiment in which subjects are
randomly allocated to 3 groups
• The means and std deviations will all be different from
each other
• We expect this because that is the nature of sampling
(as you know!)
The question is …
are the groups more different than
we would expect by chance?
How does ANOVA work?
• Instead of dealing with means as data points we
deal with variation
• There is variation (variance) within groups (data)
• There is variance between group means (Exptl
Effect)
• If groups are equivalent then the variance
between and within groups will be equal.
• Expected variation is used to calculate statistical
significance in the same way that expected
differences in means are used in t-tests or z-tests
The basic ANOVA situation
Two variables: 1 Categorical, 1 Quantitative
Main Question: Do the (means of) the quantitative
variables depend on which group (given by
categorical variable) the individual is in?
If categorical variable has only 2 values:
• 2-sample t-test
ANOVA allows for 3 or more groups
An example ANOVA situation
Subjects: 25 patients with blisters
Treatments: Treatment A, Treatment B, Placebo
Measurement: # of days until blisters heal
Data [and means]:
• A: 5,6,6,7,7,8,9,10 [7.25]
• B: 7,7,8,9,9,10,10,11 [8.875]
• P: 7,9,9,10,10,10,11,12,13 [10.11]
Are these differences significant?
Informal Investigation
Graphical investigation:
• side-by-side box plots
• multiple histograms
Whether the differences between the groups are
significant depends on
• the difference in the means
• the standard deviations of each group
• the sample sizes
ANOVA determines P-value from the F statistic
Side by Side Boxplots
13
12
11
10
days
8
7
A B P
treatment
What does ANOVA do?
At its simplest (there are extensions) ANOVA tests the
following hypotheses:
H0: The means of all the groups are equal.
Ha: Not all the means are equal
doesn’t say how or which ones differ.
Can follow up with “multiple comparisons”
Note: we usually refer to the sub-populations as
“groups” when doing ANOVA.
Assumptions of ANOVA
• each group is approximately normal
• check this by looking at histograms or use
assumptions
• can handle some non-normality,
but not severe outliers
• standard deviations of each group are
approximately equal
• rule of thumb: ratio of largest to
smallest sample st. dev. must be less
than 2:1
Normality Check
We should check for normality using:
• assumptions about population
• histograms for each group
With such small data sets, there really isn’t a
really good way to check normality from data,
but we make the common assumption that
physical measurements of people tend to be
normally distributed.
Notation for ANOVA
• n = number of individuals all together
• k = number of groups
•x = mean for entire data set is
Group i has
• ni = # of individuals in group i
• x = value for individual j in group i
ij
• x = mean for group i
i
• s = standard deviation for group i
i
How ANOVA works (outline)?
ANOVA measures two sources of variation in the data and compares their
relative sizes
• variation BETWEEN groups
• for each data value look at the difference between its
group mean and the overall mean
• variation WITHIN groups
• for each data value we look at the difference
between that value and the mean of its group
The ANOVA F-statistic is a ratio of the
Between Group Variaton divided by the
Within Group Variation:
F
Between
MSB Within
MSWagainst H , since it
A large F is evidence 0
indicates that there is more difference between
groups than within groups.
How are these computations made?
We want to measure the amount of variation due to
BETWEEN group variation and WITHIN group
variation
to:
For each data value, we calculate its contribution
xi x
• BETWEEN group variation: 2
(xij xi )
2
• WITHIN group variation:
An even smaller example
Suppose we have three groups
• Group 1: 5.3, 6.0, 6.7
• Group 2: 5.5, 6.2, 6.4, 5.7
• Group 3: 7.5, 7.2, 7.9
We get the following statistics:
SUMMARY
Groups Count Sum Average Vara ince
Column 1 3 18 6 04.9
Column 2 4 238. 59.5 01.76667
Column 3 3 226. 75.33333 01.23333
ANOVA Output
Analysis of Variance for days
Source DF SS MS F P
treatment 2 34.74 17.37 6.45 0.006
Error 22 59.26 2.69
Total 24 94.00
# of data values - # of groups
(equals df for each group
1 less than # of
added together)
groups
1 less than # of individuals
(just like other situations)
ANOVA
Analysis
Source DF
Output
of Variance for days
SS MS F P
treatment 2 34.74 17.37 6.45 0.006
Error 22 59.26 2.69
Total 24 94.00
MSB = SSB / DFB
MSW = SSW / DFW
P-value
comes from
F = MSB / MSW F(DFB,DFW)
(P-values for the F statistic are in Table E)
So How big is F?
Since F is
Mean Square Between / Mean Square Within
= MSB / MSW
A large value of F indicates relatively more difference
between groups than within groups (evidence
against H0)
To get the P-value, we compare to F(I-1,n-I)-distribution
• I-1 degrees of freedom in numerator (# groups -1)
• n - I degrees of freedom in denominator (rest of df)
Where’s the Difference?
Once ANOVA indicates that the groups do not all
appear to have the same means, what do we do?
Analysis of Variance for days
Source DF SS MS F P
treatmen 2 34.74 17.37 6.45 0.006
Error 22 59.26 2.69
Total 24 94.00
Individual 95% CIs For Mean
Based on Pooled StDev
Level N Mean StDev ----------+---------+---------+------
A 8 7.250 1.669 (-------*-------)
B 8 8.875 1.458 (-------*-------)
P 9 10.111 1.764 (------*-------)
----------+---------+---------+------
Pooled StDev = 1.641 7.5 9.0 10.5
Clearest difference: P is worse than A (CI’s don’t overlap)