Welcome!
This week we will analyse a factorial experiment using ANOVA: first as a completely randomised design (CRD), then as a randomised complete block design (RCBD). The experiment investigates aggressive interactions in Tasmanian devils.
You will come across Exercises in this lab. Solutions will be posted on Friday evening.
Learning outcomes
At the end of this practical students should be able to:
- use R to analyse experiments with a factorial treatment structure where the experimental design is a CRD or RCBD;
Specific goals
By the end of this lab, you should be able to:
Preparation
This lab uses emmeans. Install it if you are missing it by running the following in the console:
Downloads
| File | Used in | Download |
|---|---|---|
tasmanian_devil_aggression.csv |
Sections 1 and 2 | Download |
1. Factorial ANOVA as CRD (~30 min)
You are interested in investigating if aggressive interactions between Tasmanian devil individuals are influenced by eating in a group or alone, and if they are male or female. You conduct an experiment where you observe the number of aggressive interactions between individuals in a 10 minute trial. You have 12 nights to conduct the experiment and each night you observe one trial for each of the 4 treatment combinations.
Analyse the data using a factorial ANOVA as if it was collected by a CRD.
The data is in the tasmanian_devil_aggression.csv file.
Factors:
- feeding_context: Alone vs Group
- sex: Female vs Male
Response variables:
- aggression_count (integer count per trial)
- log_aggression = log(aggression_count + 1)
Blocking factor (we will ignore this for the CRD analysis but it will be used in the RCBD analysis):
- block: Night_01 … Night_12 (each night includes all 4 treatment combinations)
- Total N: 12 blocks × 2 sexes × 2 contexts = 48 trials (1 obs per cell per block)

Analysis
Exercise 1
(i) Write out the statistical model for the factorial ANOVA for this experiment. Define all the terms in the model. You can write out in words or in mathematical notation.
(ii) Test the assumptions of the factorial ANOVA and transform the data (if needed). Hint first run the model using the aov() function and then use the plot() function to check the assumptions.
(iii) Use an ANOVA to analyse the CRD and report on the results.
(iv) Explore any significant results using post-hoc tests from emmeans package and its emmeans() function. Include any plots that you think are useful to visualise the results.
Before we move on, now is a good time to take a 5-minute break.
2. Factorial ANOVA with blocking (~30 min)
Now we will analyse the same experiment as above but this time we will include the blocking factor of block (night) in the analysis. This means we will be analysing the data as if it was collected by a RCBD.
Analysis
Exercise 2
(i) Write out the statistical model for the factorial ANOVA with blocking for this experiment. Define all the terms in the model. You can write out in words or in mathematical notation.
(ii) Test the assumptions of the ANOVA model and transform the data (if needed). Hint first run the model using the aov() function and then use the plot() function to check the assumptions.
(iii) Use an ANOVA to analyse the RCBD and report on the results.
(iv) Calculate how much variation the blocking term captured.
Conclusion
Closing thoughts
We analysed a factorial experiment this week using Tasmanian devil aggression data: first as a CRD to test for main effects and interactions, then as an RCBD to account for night-to-night variation. These factorial designs and analysis techniques extend the one-way ANOVA methods from previous weeks.
Attribution
This lab was developed using resources that are available under a Creative Commons Attribution 4.0 International license, made available on the SOLES Open Educational Resources repository.