1 Objective

The aim of this lesson is to leave the participants to come up with their code for simple one-way ANOVA (part 1), and to experiment with random effects ANOVA (part 2).


2 The Data

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).


Loading the data from the web:

  snakes <- read.csv("http://www.petrkeil.com/wp-content/uploads/2017/02/snakes_lengths.csv")

  summary(snakes)
##    population      snout.vent   
##  Min.   :1.000   Min.   :36.56  
##  1st Qu.:2.000   1st Qu.:43.02  
##  Median :3.000   Median :49.76  
##  Mean   :3.439   Mean   :50.35  
##  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")


3 The model: Fixed-effects ANOVA

For a given snake \(i\) in population \(j\) the model can be written as:

\(y_{ij} \sim Normal(\alpha_j, \sigma)\)


4 Tasks for you: