I'm trying to figure out the best way to analyze the difference between sexes and across months for the means of a specific behavior (most individuals measured have repeated measures across the 5 years of the project which will contribute to the mean).

I thought a glmm would be most appropriate with

behavior ~ month + sex + sex*month + (1|Individual ID)

The month is coded as a factor (but with each month represented as a number 1-12) and so is the sex. Behavior is numeric. I need to account for the repeated measures of individuals across years because my samples sizes within a given year weren't always high (working with endangered zoo species but across the data set I do have 101 individuals just not always represented in each year and each month). The data produce the following graph. Males are green and females are blue. It has the general shape I was expecting (males stereotype more during the breeding season and females reduce stereotypes).

ggplot of the data look like this

I was expecting a significant interaction of sex*month based on the graph but I'm not seeing significance and I'm wondering, since the data are clearly not linear, if a glmm is actually appropriate? Any suggestions on analyses that would be best for this type of data?


It could just be an issue of precision. Repeated measures data have intraclass correlation, meaning that a correct analysis will be, on average, less precise/efficient than would be the case if the data were completely independent. That could be one reason why the LOESS curves you show do not agree with the model results: LOESS treats those data as independent. I agree the graph suggests that one or more month term should interact with sex, as measured by a statistical significance test.

Have you inspected a panel or spaghetti plot to see if there is heterogeneity in the mean response by sex? That is, is the tendency toward 0/1 in the earlier months driven by a few individuals who lie more than a few SDs beyond the average response? One possible impact is that the random intercept predicts a large unobserved latent response for them, so that their contribution to the analysis is downweighted significantly.

Are you using a logistic link or a linear link for your GLMM? You might also consider using a GEE to assess the reliability of the mixed model results. These handle the correlation structure in a slightly different way. In some ways, they make better use of outlying observations by not-so-dramatically downweighting their contribution to the estimated average and standard error.

  • $\begingroup$ Thanks @AdamO! I was thinking the same thing with the random effect (i.e. the graph just can't show me the exact model). I'll look into the GEE thanks for the suggestion! Reviewing similar problems in the literature I see many people break out the months, average across individuals (so only one point per individual) and then compare the difference between sexes. This seems like it would increase my likelihood of family-wise error but maybe I shouldn't be too worried about that? $\endgroup$ – Meghan Martin Feb 22 at 17:14
  • $\begingroup$ @MeghanMartin that would be a hierarchical model, and it ultimately boils down to one test, and if you're using a linear link, it should give the same results as the mixed model, possibly more conservative since the degrees of freedom are reduced in the final comparison. $\endgroup$ – AdamO Feb 22 at 17:33
  • $\begingroup$ Awesome! I'll do that. I'm trying to think of how reviewers would like that graphically represented though . . . probably not the loess curve I produced above? $\endgroup$ – Meghan Martin Feb 22 at 19:37
  • $\begingroup$ @MeghanMartin If the figure and the analysis are central to your analysis and hypothesis, show both, describe the differences and why they occur. $\endgroup$ – AdamO Feb 22 at 19:47

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.