My data looks like the attached picture. The dependent variable indirectly measured physical activity. I tried to use mixed-effect model rather than RM Anova, because my actual data is imbalanced.

enter image description here

In this data, my research question is to figure out

  1. How treatment effects are different
  2. How genotype effects are different
  3. How physical activity change over time.

What I really want to do is to compare each slope of the physical activity change within day1, day2, and day3 (like..animal a: (4.5-2.5)/4 vs (4.5-2.9)/4 vs (4.8-2.6)/4, not exactly in this way but.. that's what I want to compare).

I am currently using R so I wrote a code using lmer function. I formulated Day and Hour variables as continuous variable because I want to see the linear trends. I didn't assume the cross level interaction (between-within var interaction) in the model.

lmer(DV ~ 1 + treatment*genotype + Day + Hour + Day*Hour + (1 | ID), data)

I am assuming that testing Day*Hour interaction term may be one way to look at it, but I am not sure.. Could you give me any advice about it or give me another way to look at it?? Thank you so much for your time in advance.

  • $\begingroup$ Velcome to our site! $\endgroup$ Commented Jun 14, 2014 at 16:41

1 Answer 1


One short thing: Day + Hour + Day*Hour can and should be replaced by Day*Hour (or Day + Hour + Day:Hour), because * allready includes the main effects see the formula help page. Second, conditioning on ID doesn't make sense, because you only have one observation per ID. You should condition on genotype and treatment. As you wrote down a random intercepts model (without random slopes) I stick to this in my proposed model:

lmer(DV ~ 1 + Day*Hour + (1|treatment) + (1|genotype), data) 
  • $\begingroup$ If there is variation in time or hour, this needs to be accounted for with a random slope. If not, and there is variation, the current model is mispecified. The type-one one error will increase with higher variation in the random slopes. $\endgroup$
    – D_Williams
    Commented Dec 11, 2016 at 6:21

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.