2

I need to compare binary responses (nectar present/absent) between flowers of two treatments ("y" and "n"). This seems like a straight forward case for a Chi-square test, however- my design involved a couple of layers of nesting (site/plant).

What is the best way to account for nesting in a categorical analysis?

Example data below

site    plant   flower   status   nectar_present
ek      11      102      n        0
ek      11      103      y        0
ek      11      104      n        1
ek      11      105      y        0
ek      11      106      n        1
ek      11      107      y        0
ek      11      108      n        0
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
JKO
  • 673
  • 2
  • 8
  • 18

1 Answers1

1

You have a binary (yes/no) response variable, so logistic regression would be a natural starting point. But the nesting structure means that the usual independence assumption would fail. That can be modeled with a random effects model (or mixed model), in R with the lme4 package. If you will post (a link to) the data I can have a look. Assuming enough observations, something like the following code:

library(lme4)
mod0 <- glmer( status ~ (1 | site/plant), data=your_data_frame, family=binomial )

will fit a pure random effects model. Fixed effects can also be included. Many examples on this site, for instance Specifying and Interpreting Mixed effects logistic regression and many others.

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467