Solved – Linear mixed effect model with repeated measures using lmer

blockinglinearmixed modelrrepeated measures

Background
I think I am close to the error structure I want for random effects but not sure about some parts of it. I am carrying an experiment on wheat plots in a field to measure the increase in aphid numbers over time.

Experimental design and coding for predictors
I put 4 populations of aphids into a wheat plot and subjected them to four different cage treatments (Cage_treatment). I measured the number of aphids before they were subjected to the treatments and after e.g. two time periods, before and after(Time). I repeated this in many wheat plots within a field. Three wheat plots are part of different three types of crop rotation (Rotation). These 3 plots x 3 crop rotations equal a block. There are four blocks in total. I am measuring aphid numbers per tiller (Total_per_tiller).

The effects I am interested in e.g. fixed effects is how the Total_per_tiller aphid numbers change over Time, how this differs for each Cage_treatment and how the Rotation effects this.

Fixed and Random effects

Fixed effects:

  • Cage_treatment,
  • Rotation,
  • Time,

Random effects:

  • Plot ID,
  • Block,

This is the following code for my maximal model:

model <- lmer(Total_per_tiller~Cage_treatment*Rotation*Time + (Time|PlotID) + 
              (1|Block/Rotation), REML=FALSE)   

Does this look right?

Best Answer

In your model Rotation is both a fixed effect slope and a random effect nested in Block in here: (1|Block/Rotation). If you wanted Rotation to be a random slope in Block you would have to define it as (1 + Rotation|Block). What (1|Block/Rotation) means is: (1|Block) + (1|Block:Rotation), i.e. a random intercept for Block and a random intercept for Rotation nested in Block.

Check also this post on SO or here. More information on defining models in lme4 you can find in an article by Bates et al. (in press) or in this online book.

Btw, why you don't want REML method for estimation?

Related Question