# Split plot design with nested random effects and interactions between random effects

I am trying to analyse a split plot design for a plant growth experiment with the following variables:

• Biomass (dependent variable)
• Transect (sub plot factor with three levels)
• Treatment (main plot factor with two levels)
• Block (2 blocks in total, serving as replicates of the treatment)
• Location (multiple locations within each transect point)

I know what the random effect structure should look like. However, I can’t work out how to write this in R script. Could someone please help me? It’s probably very easy, but I have been looking for hours and hours and can’t find it.

Random effects should be:

• Block
• Interaction Block and Treatment
• Location nested within Transect
• (Location nested within Transect), interaction with Treatment

So perhaps something like: (1|block)+(1|block*treatment)+(1|location:transect) +(1|(location:transect)*treatment)

Based on comments from your question on stack overflow, "Seeds were collected from plants along three independent transects and within each transects from different sublocations."
I would consider the "Location" variable as repeats or subsample from each Transect and not include it as a factor in the model. It ensure the error is calculated correctly, I would average each group of repeats/subsamples together and then perform the anova.

#in Base R
res.good <- aov(Biomass ~ Transect * Treatment +Error(Block:Transect), data=data)
summary(res.good)

#With the lme4 library
library(lme4)
rmodel <- lmer(Biomass ~  Transect*Treatment + (1|Transect:Block), data = data)
anova(rmodel)


Without running this on sample data, it is difficult to know if the degree of freedom works out correctly.
I'll welcome any comments or corrections. Good luck