# Nested random factor with confounding (random?) variable

I have a question on how to specify a GLMM. I made an experiment with two treatments (control and treated) to test the effect of a water contaminant on reproductive cells of tadpoles. I have data on proportion of oocytes in a histological photo. I took several photos for each animal. My main interest is to test the effect of the treatment on the response variable. However, animals happen to be in different developmental stages. I have 5 stages in total. I tried to model these data using a glm including treatment and stage as fixed factor and the photos nested within an animal as random factors.

So first, I found out using:

Ord_plot(datos\$Oocitos_Total)


that the response variable is better modelled by a negative binomial, so I went on and used the lme4::glm.nb like this:

glmer.nb(Oocytes_Total~Treatment+as.factor(Stage)+(1|Animal:Photo), data=datos)


My question is: should I include the stage as fixed factor or a random factor to which Animal and Photo would be nested within? I'm only interested in the effect of the treatment, I only included the stage to control for this effect. The point is, a given animal will always have the same stage. Is my model above correct?

So I think you should include Stage as a fixed effect which cements it's role as a possible confounder.
Although you haven't asked about the other random effect, (1|Animal:Photo), I think you should specify this as (1|Animal/Photo) to reflect that there are several photos per animal, otherwise, with the way you wrote it, you only have random intercepts for the interaction.
• That's right. Thank you @RobertLong! I had tried that random effect (1|Animal/Photo) as well but wasn't sure which one to choose. Thank you for clarifying that too. – Diogo B Provete Jul 23 '16 at 18:32