I'm planning an experiment that involves sampling insects from four trees along each of five streets (each street being an experimental site). My focal tree species has distinct male and female individuals, and plant sex is a factor I want to investigate, so my experiment will sample equal numbers of each sex. Additionally, I want to investigate insect distribution within trees, so I've split up each tree into two sides: one facing the street and the other facing away from the street. My expected data will look like this:

Site  Tree  Sex  Side  Abundance
1     1     M    S     10
1     1     M    B     5
1     2     F    S     11
1     2     F    B     6
1     3     M    S     8
1     3     M    B     3
1     4     F    S     12
1     4     F    B     6

(For column Side, S is the side facing the street and B the side facing away from the street.)

My currently planned model has sex and side as fixed effects (including an interaction between them), and site and tree nested within site as random effects, i.e.:


However, I'm unsure about this because sex varies among individual plants (a plant is either male or female), whereas side varies within individual plants (each plant has two sides). Just what kind of a model would I need to incorporate these factors?

  • $\begingroup$ It might be helpful to create a reproducible example. stackoverflow.com/questions/5963269/… $\endgroup$ Oct 28, 2020 at 8:08
  • $\begingroup$ What is site ? Is it the same as street, so you have 5 of them ? $\endgroup$ Oct 28, 2020 at 9:28
  • $\begingroup$ @RobertLong Sorry about that, streets are indeed sites. I've edited the question to make this clearer. $\endgroup$
    – Pitto
    Oct 28, 2020 at 10:53

1 Answer 1


Your model:

y ~ Sex*Side + (1 | Site) + (1 | Site:Tree)

makes sense to me conceptually. However with only 5 sites, this is rather few for fitting random intercepts, so I would suggest also fitting

y ~ Sex*Side + Site*Tree

Hopefully the inferences for Sex, Side and their interaction will be similar in both models.

You don't need anything special to account for the within and between factors.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.