0
$\begingroup$

I have to do a model for non-linear data with repeated measurements.

I worked with predatory insects. I did an experiment with 4 treatments, where per each treatment predators received a different diet during their nymphal development. When the predators reached the adult stage I assessed their predation rate in 2 days for every individual (in day 1 and day 5 after moulting respectively). The experiment had 2 replicates.

I am looking for a model in which I can see what had an impact on the predation rate (different diets(treatment), sex of the predator, etc.) and if there was a difference between the predation performance in day 1 and day 5.

First I used a generalized linear mixed model (glmer) as follow:

glmer_eaten <- glmer(eaten~treatment*day+sex+(1|treatment:block),
                     family="poisson", data=ex1)

where the factors are: the correlation between treatment and day , the sex of the predators, and as random effect treatment:block. (the random effect is not block alone since there are only 2 blocks, therefore the statistician told me to use treatment:block).

However, the random effect is not significant therefore I am using a generalized linear model (glm) instead.

glm(eaten~treatment*day+sex+block, family="poisson", data=ex1)

Nevertheless I do not know how to write in the model that there were REPEATED MEASUREMENTS. I mean I have to clarify that for the predation in day 1 and day 5 I used the same individual. Do you know how to write it the code?

This is how my dataset looks like: enter image description here

$\endgroup$
  • 1
    $\begingroup$ How do you know that the random effect "is not significant"? Last I checked, glmer() doesn't provide p values for random effects and I don't see how you would have used model comparison to compare a model with and without the random effect. $\endgroup$ – Ian_Fin Jul 15 '16 at 13:28
  • $\begingroup$ I used anova between the models glmer and glm $\endgroup$ – giulio zorzetto Jul 15 '16 at 13:50
  • $\begingroup$ I always thought that anova() could not compare models with and without random effects... I'm not entirely sure I grasp your question though. What about your glmer() model fails to include the fact your data had repeated measurements? $\endgroup$ – Ian_Fin Jul 15 '16 at 14:05
  • $\begingroup$ Do you mean novice there? Novel doesn't fit. $\endgroup$ – Glen_b -Reinstate Monica Jul 16 '16 at 19:26
2
$\begingroup$

Since you have repeated measures, you can't use glm(), because it will not account for the non-independence of measurements within individuals. To cater for repeated measurements in in glmer() you would use:

glmer_eaten <- glmer(eaten~treatment*day+sex+(1|name),
                 family="poisson", data=ex1)

which is assuming that name in your data is the identifier of the individual or subject that the repeated measures are on, as it appears from the short data extract in your post. Note that this should be a factor, not numeric, in R.

Also, you can't use anova() to test for the "significance" of random effects, because, assuming that the likelihoods are calculated in the same way, this is equivalent to using a likelihood ratio test to test whether the variance of a random effect is zero. Since this test occurs on the boundary of the parameter space (ie. you are testing whether something that cannot take negative values is zero) this test is not appropriate. There are modifications to this test, such as that implemented in Stata:

When there is only one variance being set to zero in the reduced model, the asymptotic distribution of the LR test statistic is a 50:50 mixture of a $\chi^2_p$ and a $\chi^2_{p+1}$ distribution, where p is the number of other restricted parameters in the reduced model that are unaffected by boundary conditions....See Self and Liang (1987).

When using glm() and glmer() in particular, since these are different packages, there is a distinct possibility that the likelihoods are computed differently, so in addition to the problem outlined above, a LRT would dangerous anyway.

You could, of course, fit a model with crossed random effects, such as:

glmer_eaten <- glmer(eaten~treatment*day+sex+
    (1|treatment:block)+(1|name), family="poisson", data=ex1)

References:

Self, S. G., and K.-Y. Liang. 1987. Asymptotic properties of maximum likelihood estimators and likelihood ratio tests under nonstandard conditions. Journal of the American Statistical Association 82: 605–610. http://www.stat.wisc.edu/~larget/Stat998/Fall2015/Self-Liang-1987.pdf

$\endgroup$
  • $\begingroup$ thank you! So it is not necessary to nest days with samples (name column)? what is the difference between (1|name) and (1|day/name)? $\endgroup$ – giulio zorzetto Jul 17 '16 at 12:40
  • $\begingroup$ (1|name) means that observations are clustered within name (repeated measurements). (1|day/name) means that observations are clustered within name, and name is clustered within day which would not be correct in your case because the same subjects are measured on each day. $\endgroup$ – Robert Long Jul 17 '16 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.