lundi 8 janvier 2018

nested random effects in lmer: higher-level term both fixed and random?

I have sampled multiple individuals from each of 6 populations (pop). These 6 populations belong to 2 habitats (habitat): grass, sand. So, my populations are nested within the habitat types.

pop is coded with unique levels:

pop's for grass: g1, g2, g3

pop's for sand: s1, s2, s3

Now, I am interested in the effect of habitat type on my response variable (habitat as fixed effect), but only after controlling for the fact that certain individuals belong to certain populations (pop as random effect), and after giving the information that certain populations occur only in certain habitat types (pop nested within the habitat).

Reading the GLMM FAQ by Bolker, I build my model with the following structure:

lmer(y ~ habitat + (1|habitat/pop))

Is it correct to treat habitat as both fixed and random effect? Or does the model "understand" that pop is nested within habitat type (because they are uniquely coded), so I can change the model structure to lmer(y ~ habitat + (1|pop))?

Thanks for any kind of advice.

Cheers

Ned

PS: I can prepare a reproducible example if needed.




Aucun commentaire:

Enregistrer un commentaire