Help with R GLM Formula for paired/nested model


New Member
I have an experimental design as follows:

Two treatments, carried out on the same sample. The samples are collected from soil at five depths, in five different pits, from five different fields. I want to: (1) see if the treatment has an effect on the species richness found in the soil sample and (2) see if the effect of the treatment increases at deeper depths.

As it is a paired test I have dummy coded each pair of paired treatments into a variable called Pairs.

To test (1) i use the following formula:

lmer(Richness ~ Treatment + (1|Pairs) )

I don't know how to take into account the nested experimental design, accouting for differences in Pit and Field. I can't work out a formula to test (2). So far I am using this:

lmer(Richness ~ Treatment + Depth + (1|Pairs) + (1|Field/Pit) )

Does this seem correct?

Any help would be very much appreciated!