I'm using lmer to test how multiple variables (in this case, treatment, species, and sex) influence avian behaviour.

M1 <- lme4(Behaviour ~ Treatment+Subspecies+Sex + (1|Individual)+(1|Stimulus-ID), data=data)

where behaviour is continuous and Treatment,Subspecies, and sex are all categorical. Individual and Stimulus Ids are set to be as random variables as this was a repeated design (for individual) and I want to reduce pseudoreplication by controlling for my stimuli (e.g., bird song playback) as is often done in behavioural research.

In early efforts, I've found that Treatment and Sex are important in some behavioural context and Subspecies in others (but interactions between these fixed factors are non-significant). However, while in the field, I noted other covariates that appear significant when I run them in the full model. For example, Time of day a behaviour recorded was noted is an important predictor of the overall behaviour.

However, I'm mostly interested in the effect of Treatment, Subspecies, and Sex. I would like to control for this confounding variable (among others), but I'm pretty stumped on the proper way to code for this and I would appreciate any insight one may have. That is to say, I know time of day is important in predicting behaviour, so I want to account for this so that I can fully appreciate the effect Treatment/subspecies/sex has on individual behaviour.

If this is poorly written or needs further clarification, I'm happy to provide any more insight. Thanks in advance for your help and any suggestions you have!

  • 3
    $\begingroup$ Is there some reason why you have rejected adding it as another covariate in the model? $\endgroup$
    – mdewey
    Jan 26, 2019 at 15:33
  • 1
    $\begingroup$ How you control for Time of Day will ultimately depend on whether or not you have multiple days worth of data for each bird. $\endgroup$ Jan 26, 2019 at 19:28
  • $\begingroup$ @mdewey, the main reason is that time of day is intuitive going to influence the results, so it being a significant covariate is unsurprising, and frankly uninteresting. But I was curious if there was a way to account for time of day to get a 'true' value for the three fixed factors. I could be off base about this of course and misinformed with what I'm able to do statistically. re: Isabella, The current set up for my data is five repeated trials per bird, spaced by three days each trial. $\endgroup$
    – JAJones
    Jan 27, 2019 at 19:32
  • $\begingroup$ @JAJones: Thanks for your clarification. So, for the same bird, you have trial #1 on day 1, followed by trial #2 on day 1 + 3 = day4, followed by trial # 3 on day 4 + 3 = day 7, etc.? What happens on a given day? Is the bird exposed to a single stimulus at a particular time of day? Or to a whole bunch of stimuli at different times of day? How are you going to code 'time of day"? Is it going to be morning vs afternoon, for example? Also, how is your Treatment different from the stimulus? $\endgroup$ Jan 27, 2019 at 23:27
  • 1
    $\begingroup$ Including a variable in the model does not imply that you are interested in its effect. You may, as I believed you wanted, have included it in order to take out its effect. I am not confused as to what your scientific question really is if you do not want to include a confounder which you know influences your variable of interest. $\endgroup$
    – mdewey
    Jan 28, 2019 at 9:30

1 Answer 1


You have stated that you believe Time is a confounding variable in this analysis. If so then you should include Time as a covariate in the analysis.

However, before doing so, it is important to ensure that the variable is indeed a (potential) confounder, or a competing exposure.

To be a confounder, it must be a cause, or a proxy of a cause, of the outcome, AND a cause, or a proxy of a cause, of the exposure(s). So, in this case, if Time causes Behaviour AND also causes any of the other exposures, then it is indeed a confounder. It seems unlikely that it can be a cause of Sex or Subspecies, but if it determines the Treatment given, then it is a confounder, and should be included as a covariate in order to obtain unbiased estimates of the other fixed effects. The estimate for Time (and it's statistical significance) is irrelevant (and should not be interpreted if it is a confounder).

On the other hand, if Time is on the causal pathway from the exposure(s) to the outcome, for example, if the Treatment given depends on the time of day, then it is a mediator and should not be included as a covariate - including a mediator in a regression can invoke a reversal paradox (for example Simpson's Paradox) - see Tu et al (2008)

Lastly, if Time is not a cause of the exposure(s) (but is a cause of the outcome), then it should be treated as a competing exposure, and included in the model as a covariate; this will improve the accuracy of the other fixed effects estimates that you are interested in.

Tu, Y.K., Gunnell, D. and Gilthorpe, M.S., 2008. Simpson's Paradox, Lord's Paradox, and Suppression Effects are the same phenomenon–the reversal paradox. Emerging themes in epidemiology, 5(1), p.2.

  • 3
    $\begingroup$ Thanks Robert. This really does add a lot of clarity to my questions. I see now that I was using the term confounding incorrectly (due to the reasons you list). Time in my experiment may cause the outcome (behavior) but I did not give a treatment based on the time of day. To that end, I see that I should add it as a covariate as you indicate in the final paragraph. I really appreciate the help with clearing some things up. $\endgroup$
    – JAJones
    Jan 28, 2019 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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