# Do I have a nested design or simple three-way Anova?

I have measured nitrogen release from sediment in a river at six different sites (blue squares), at each site I took 3 replicate measurements of nitrogen release within each of two habitat types (areas with and without plants, green and grey circles). Sites differed in underlying sediment type, either Sandy or Muddy.

The design is unbalanced, 2 sites have muddy sediment and four have sandy.

I am trying to assess the effect of habitat type, site and sediment type (an their interactions) on nitrogen release.

My understanding is that this is a hierarchical or nested design, with habitat type nested within site, which is nested within sediment type. Is this correct?

Would be grateful for any help on this or point me to some reading!

Thanks!

Deciding when to treat something as a fixed- or random-effect in a multilevel can be a subjective process. Check out my response here to someone who was asking the really solid question of basically asking when we treat something as an IV or cluster variable. If you are looking for reading, I have some citations to multilevel/mixed-modeling books and papers that I enjoy there.

In your specific case, given what your hypothesis is, I would say that you have a two-level model:

### Level 1: Observation

• $Y$ - Nitrogen release
• $X_1$ - Habitat type
• $X_2$ - Sediment type

### Level 2: Site

• Any relevant covariates that are at the site level could be put here.

To fit this model (in the syntax of the lme4 package in R), you could say:

y ~ x1 + x2 + x1*x2 + (1|siteid)


This means that y is predicted by the two variables as well as the interaction between the two, and we allow each site to have it's own intercept (the random effects are inside of the parentheses and the 1 refers to the intercept).

Your data would need to be in long format and take the structure where every observation has its own row, and every row has a label for siteid that tells you which site it was in.