The aim of this lesson is to (1) leave the participants to come up with their code for simple one-way ANOVA, and (2) to experiment with random effects ANOVA.
We will use modified data from the example from Marc Kery’s Introduction to WinBUGS for Ecologists, page 119 (Chapter 9 - ANOVA). The data describe snout-vent lengths in 5 populations of Smooth snake (Coronella austriaca) (Uzovka hladka in CZ).
Loading the data from the web:
snakes <- read.csv("http://www.petrkeil.com/wp-content/uploads/2014/02/snakes.csv")
# we will artificially delete 9 data points in the first population
snakes <- snakes[-(1:9),]
summary(snakes)
## population snout.vent
## Min. :1.000 Min. :36.56
## 1st Qu.:2.000 1st Qu.:43.02
## Median :3.000 Median :49.24
## Mean :3.439 Mean :50.07
## 3rd Qu.:4.000 3rd Qu.:57.60
## Max. :5.000 Max. :61.37
Plotting the data:
par(mfrow=c(1,2))
plot(snout.vent ~ population, data=snakes,
ylab="Snout-vent length [cm]")
boxplot(snout.vent ~ population, data=snakes,
ylab="Snout-vent length [cm]",
xlab="population",
col="grey")
For a given snake \(i\) in population \(j\) the model can be written as:
\(y_{ij} \sim Normal(\alpha_j, \sigma)\)
Try to write this model in the BUGS language and dump it into a file using cat
.
Try to prepare the data for this model in the list
format.
Try to fit the model and estimate posterior distributions of \(\alpha_j\).
Is there a significant difference of mean snout-vent length between populations 1 and 2?