Professional Documents
Culture Documents
How To Calculate An ANOVA Table: Calculations by Hand
How To Calculate An ANOVA Table: Calculations by Hand
Calculations by Hand
We look at the following example: Let us say we measure the height of some
plants under the effect of 3 different fertilizers.
Interpretation:
An observation yij is given by: the average height of the plants (µ), plus
the effect of the fertilizer (Ai ). and an ”error” term (ij ), i.e. every seed is
different and therefore any plant will be different.
All these values (µ, Ai , ij ) are UNKNOWN!
Our GOAL is to test if the hypothesis A1 = A2 = A3 = 0 is plausible1 .
1
The (estimated) overall mean (µ̂, which is an estimation of the exact, un-
known overall mean µ) is calculated as follows2 :
1+2+2+5+6+5+2+1
µ̂ = =3
8
The estimated effects Âi are the difference between the ”estimated treat-
ment mean” and the ”estimated overall mean”, i.e.
Âi = M eani − µ̂
So
Then:
Cause of
the variation df SS MS F F Krit
Treatment ... ... ... ... ...
Residuals ... ... ...
Total ... ...
For the column df (degrees of freedom) just remember the rule ”mi-
nus one”:
2
SStreat = ”sum of squares between treatment groups”
X
= Â2i · #measures
= (−1.33)2 · 3 + (2.33)2 · 3 + (1.5)2 · 2 = 26.17
Remark 2 The total ”SS” is always equal to the sum of the other ”SS”!
SStreat 26.17
M Streat = = = 13.08
dftreat 2
SSres 1.83
M Sres = = = 0.37
dfres 5
The F-value is just given by:
M Streat 13.08
F = = = 35.68
M Sres 0.37
Interpretation:
The F − value says us how far away we are from the hypothesis ”we can not
distinguish between error and treatment”, i.e. ”Treatment is not relevant
according to our data”!
A big F −value implies that the effect of the treatment is relevant!
3
STEP 3: The decision:
Similar as for a T-test we calculate the critical value for the level α = 5%
with degrees of freedom 2 and 5 (just read off the values from the appropriate
table)3 .
krit
α = 5% ⇒ F2,5 (5%) = 5.79
krit (5%).
We have calculated F = 35.68 > F2,5
Consequently we REJECT THE HYPOTHESIS A1 = A2 = A3 = 0!!!
Similarly we could obtain the same result by calculating the p − value
Calculations with R
v <- c(1,2,2,5,6,5,2,1)
TR <- c(1,1,1,2,2,2,3,3)
d <- data.frame(v,TR)
d$TR <- as.factor(d$TR)
Interpretation:
• For every factor (in this case just TR) we construct a vector, which can
be interpreted as follows: the first three Values of the vector v belong
to treatment 1 (X), the two last components to treatment 3 (Z) and
the other 3 to treatment 2 (Y).
• check with str(d) that d$v is a vector of numbers (num) and d$TR is
a factor (Factor)
3
Because F is obtained by M Streat (2 deg of freedom) and M Sres (5 deg of freedom),
krit
we calculate F2,5 (5%).
4
> str(d)
’data.frame’: 8 obs. of 2 variables:
$ v : num 1 2 2 5 6 5 2 1
$ TR: Factor w/ 3 levels "1","2","3": 1 1 1 2 2 2 3 3
Interpretation:
> summary(d.fit)
Df Sum Sq Mean Sq F value Pr(>F)
TR 2 26.1667 13.0833 35.682 0.001097 **
Residuals 5 1.8333 0.3667
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
STEP 2: Decision:
Interpretation:
• With R we do not have the critical values to a level, but we have the
P −value (PR(>F)).
PR(>F)=0.1097%, this means: if we choose a level a of 0.1%, we can not
reject the Null-Hypothesis, by choosing a level α = 0.11% or bigger we
have to reject H0 ! (Usually we choose a = 5% ⇒ H0 will be rejected!)