# Specify nested random effects [closed]

I have data from a field survey. The objective of the study is to relate number of seedling (respond variable, count data), flood duration (exploratory variable, categorical variable with 3 levels) and percent canopy coverage (exploratory variable, quantitative).

In each flooding duration, I have data from five 25x25 meter plots. The plots were randomly placed throughout study site, so I do not think they are dependent. Within each plot I used three 2x2 meter subplots nested within the bigger plot, and number of seedlings were count from these subplots. Total number of observations is 45; 3 flood levels x 5 plots x 3 subplots.The data looks like this.

I am new to mixed effect model, and from my understanding the subplots nested within plots. I would like to do this using lmer as follows.

Model <- lmer(seedling ~ flood duration * canopy  + (1|plot/subplots), data = mydata)


I am not sure about the (1|plot/subplots) term. Is the term correct?

Just a bit about syntax, as @Dimitris Rizopoulos mentioned that because in mydata, the sub-plots index numbers are not the same within each plot (in my case subplots 1-1, 1-2, and 1-3 are within plot 1 only), I could use glmer (seedling ~ flood duration * canopy + (1 | plot) + (1 | subplots), data = mydata, family = poisson()). From my understanding that I might be wrong the “(1 | plot) + (1 | subplots)” is a way to tell R that these are crossed random effect. However, because my sub-plots index numbers are not the same within each plot, R will know that these are nested effect, and this syntax will give the same result as glmer (seedling ~ flood duration * canopy + (1 | plot/subplots), data = mydata, family = poisson()). Is this understanding correct?

## closed as off-topic by jbowman, Michael Chernick, kjetil b halvorsen, mkt, mdeweyOct 12 '18 at 13:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – jbowman, Michael Chernick, kjetil b halvorsen, mkt, mdewey
If this question can be reworded to fit the rules in the help center, please edit the question.

• Thank you very much Prof. @Dimitris Rizopoulos.Thank you very much. I would like just to make sure that I understand some points of your answer correctly. You mentioned that I have only 45 observations and I should start with random intercept for the plot level. To do this is glmer (seedling ~ flood duration * canopy + (1 | plot), data = mydata, family = poisson()) a correct syntax for the random intercept for the plot level only ? – Ponlawat Oct 11 '18 at 10:47
• Yes, this indeed correct. – Dimitris Rizopoulos Oct 11 '18 at 11:27
• a bit about syntax, @Dimitris Rizopoulos because in mydata, the sub-plots index numbers are not the same within each plot (in my case subplots 1-1, 1-2, and 1-3 are within plot 1 only), I could use (1 | plot) + (1 | subplots). From my understanding that I might be wrong the “(1 | plot) + (1 | subplots)” is a way to tell R that these are crossed random effect. However, because my sub-plots index numbers are not the same within each plot, R will know that these are nested effect, and this syntax will give the same result as (1 | plot/subplots), Is this understanding correct? – Ponlawat Oct 11 '18 at 11:33
• Check the last bullet in this section of the GLMM FAQ: bbolker.github.io/mixedmodels-misc/… – Dimitris Rizopoulos Oct 11 '18 at 11:38

• Since your outcome variable, seeding, is a count, you would need a Poisson mixed effects model rather than a linear mixed model (the latter being used for normally distributed outcomes). To fit a Poisson mixed model, you need to use glmer(..., family = poisson()).
• Because the sub-plots index numbers are not the same within each plot, you could use the following syntax: glmer(seedling ~ flood duration * canopy + (1 | plot) + (1 | subplots), data = mydata, family = poisson()).