Note:
  • The key is to construct a table of means similar to what is shown in the R code as mns. Then SShabitat, SSyear and SSAmong are computed by following the SSA, SSB and SSAmong formulae from the reading. The SSA:B 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, noting that a=2, b=2 and m=25. The MS, F (but note that the denominator is always MSWithin), and p-values are found as usual (but make sure use df1=1 for all but the top row).
  • I did this in R just for fun (you did not have to use R except for the p-values).

ANOVA Table

  1. Completed table shown below. Calculations shown in the R Code and Results appendix.
df SS MS F p
Among 3 1510.2 503.4 2.582 0.0579
Year 1 1361.6 1361.6 6.984 0.0096
Habitat 1 114.5 114.5 0.587 0.4454
Year:Habitat 1 34.1 34.1 0.175 0.6768
Within 96 18717.1 195.0
Total 99 20227.3
  1. There is no evidence for an interaction effect (p=0.6768). There is also no evidence for a “habitat” main effect (p=0.4454). However, there is evidence for a “year” main effect (p=0.0096).

R Code and Results

> library(NCStats)
> 
> tmns <- matrix(c(75.45,83.98,74.46,80.70),byrow=FALSE,nrow=2)
> mns <- addmargins(tmns,FUN=mean,quiet=TRUE)
> colnames(mns) <- c("far","near","year")
> rownames(mns) <- c("2015","2016","habitat")
> mns <- round(mns,2)
> mns
          far  near  year
2015    75.45 74.46 74.96
2016    83.98 80.70 82.34
habitat 79.72 77.58 78.65
> a <- b <- 2
> m <- 25
> ssyear <- a*m*sum((mns[1:2,3]-mns[3,3])^2)
> sshab <- b*m*sum((mns[3,1:2]-mns[3,3])^2)
> ssamong <- m*sum((mns[1:2,1:2]-mns[3,3])^2)
> ssint <- ssamong-sshab-ssyear
> sstotal <- 20227.3
> sswithin <- sstotal-ssamong
> dfamong <- a*b-1
> dfyear <- a-1
> dfhab <- b-1
> dfint <- dfamong-dfhab-dfyear
> dftotal <- a*b*m-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)