21 Mixed models

Advanced Topics are still under development

21.1 What is mixed modelling and why do we need it?

Ecological and biological data is often complicated and messy. We can have lots of grouping factors like populations, data collection sites that mean our data has clusters so that our data points are not truly independent. This is where mixed models are useful, these combine fixed and random effects to help us deal with messy data, structured data, and they help us save degrees of freedom. They are incredibly useful, but frequently tricky to implement well!

21.1.1 Fixed effects

So far in our statistics we have dealt only with fixed effects

Fixed effects are variables that are constant, or have a constant effect on the individual. For example we can argue that the effect of species on average body mass is constant, and does not change. It could be argued that these variables could change over time, but for research and experimental purposes are constant. We assume that the values of a fixed variable in one study should be the same as values in another study.

21.1.2 Random effects

Random effects, these are the opposite of fixed effects. These variables have unpredictable effects, for example this could be the sample sites. It is perfectly plausible that data collected within different sites are more similar to each other than data from different sites.

Unlike fixed effects we assume these values are samples drawn from a larger population of values. We are often not interested in the explicit effect of this variable, but we expect it to have an effect on the dependent variable and wish to account for it. These could be any of a number of grouping variables, for example:

  • Study-site

  • Repeated measurements in an individual

  • Experimental replications

21.2 The data

We are going to look at bacterial growth in four different growth media. We ran this experiment five times, in five different microbial growth cabinets

head(bacteria)

21.3 Simple model

21.4 Covariates

21.5 Mixed model

21.5.1 Random slopes

Rats data - Exeter

Task
  1. Plot a scatterplot of Alcohol vs TotalPhenols and colour data points by WineType

Something