Solved – Comparing slopes in mixed-effect model

lme4-nlmemixed model

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.

Best Answer

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) 
Related Question