ANOVA Table

Note:
  • The key is to construct a table of means similar to Table 1. Then SShabitat, SSyear and SSamong are computed by following the SSrow, SScolumn and SSamong formulas from the reading and class notes. The SSinteraction is then found by subtracting both SShabitat and SSyear from SSamong. The SSwithin is found by subtracting SSamong from SStotal. All degrees-of-freedom are found by formulae in the reading and class notes, noting that r=2, c=2 and n=25 (remember that n is the number of replicates per treatment in a two-way ANOVA, not the total number of individuals). The MS, F (but note that the denominator is always MSwithin), and p-values are found as usual.
  • I did this in R just for fun (you did not have to use R except for the p-values).

Table 1: Means table for cattail data.

far near mean
2015 75.45 74.46 74.95
2016 83.98 80.70 82.34
mean 79.72 77.58 78.65

 

Results shown in Table 2. R code to make calculations are shown in an appendix (note, however, that you are not expected to make these calculations in R).

 

Table 2: Completed analysis of variance table for cattail data.

df SS MS F p
Among 3 1510.2 503.4 2.582 0.0579
Year 1 1365.3 1365.3 7.003 0.0095
Habitat 1 114.5 114.5 0.587 0.4454
Year:Habitat 1 30.4 30.4 0.156 0.6939
Within 96 18717.1 195.0
Total 99 20227.3

R Appendix.

library(NCStats)
tmns <- matrix(c(75.45,83.98,74.46,80.70),byrow=FALSE,nrow=2)
colnames(tmns) <- c("far","near")
rownames(tmns) <- c("2015","2016")
mns <- addmargins(tmns,FUN=mean,quiet=TRUE)
mns <- round(mns,2)
r <- c <- 2
n <- 25
ssyear <- r*n*sum((mns[1:2,3]-mns[3,3])^2)
sshab <- r*n*sum((mns[3,1:2]-mns[3,3])^2)
ssamong <- n*sum((mns[1:2,1:2]-mns[3,3])^2)
ssint <- ssamong-sshab-ssyear
sstotal <- 20227.3
sswithin <- sstotal-ssamong
dfamong <- r*c-1
dfyear <- r-1
dfhab <- c-1
dfint <- dfamong-dfhab-dfyear
dftotal <- r*c*n-1
dfwithin <- dftotal-dfamong
ss <- c(ssamong,ssyear,sshab,ssint,sswithin)
df <- c(dfamong,dfyear,dfhab,dfint,dfwithin)
ms <- ss/df
F <- ms[-length(ms)]/ms[length(ms)]
distrib(F[1],df1=df[1],df2=df[5],distrib="f",lower.tail=FALSE)
distrib(F[2],df1=df[2],df2=df[5],distrib="f",lower.tail=FALSE)
distrib(F[3],df1=df[3],df2=df[5],distrib="f",lower.tail=FALSE)
distrib(F[4],df1=df[4],df2=df[5],distrib="f",lower.tail=FALSE)