# Mixed Effect Modeling with Categorical Variables

I am running an experiment where I get repeated measures over time from ~10 subjects. Because the effects of time aren't constant, I am treating timepoints categorically. So my model looks like:

Model<-lmer(data, Response ~ Categorical.Time + (1|Animal.Name))

Now when I do

summary(Model)

I get this (made up values)

            Estimate    Std. Error     df   t value  Pr(>|t|)
(Intercept)    10            2         10      20    1.00E-06
Day1           4             2         10      1     0.3
Day2           6             3         10      2     0.06
Day3           3             2         10     0.18   0.2
Day4           5             2         10      3     0.01*


Now, I figured I would also have to run an anova to get an overall effect of time on my response variable.

anova(Model), then take the p-value from that


A couple questions:

1. assuming the anova of the overall effect of time is NOT significant, should I disregard any individually significant timepoints? My thought is yes, to ignore anything if the overall time effect is ns. On the other hand, if the anova is significant I can report that the overall effect of time is significant, and Day4 specifically has a positive association with my response variable.

1. Second question: is anything else horribly wrong, from what I've written here?

Many thanks for any advice!

(teaching myself so please forgive basic errors)

• Can you elaborate more on the nature of your response? Are you treating time as categorical because you suspect the effect of time is non-linear? To this end, it would really help if you could post a plot of your response over time for each subject. With data collected over time, you would also need to check your model residuals for any presence of temporal correlation (e.g., construct ACF and PACF plots of the model residuals). Do you have a Day0 in your data? In other words, what is the reference level for your Day variable? – Isabella Ghement May 14 '18 at 16:00
• Hi! Thanks for reading :) yes, I suspect time's effects may be non-linear. I actually ran the same test with time as quantitative and am going to investigate which one is more appropriate (I'll read more on that before bugging someone online). I will check residuals and try to post some sample data. I do have a day0, yes, and that's the baseline/reference level. Thanks again for your help! – Will May 14 '18 at 16:28
• The plot of response values as a function of time should elucidate whether you can model the time effect as linear or non-linear. For a linear effect, the response values for each animal should show a tendency to increase (or decrease) over time. In that case, you can treat Day as a numerical variable in your model. If you see more complicated, non-linear patterns, then you can treat Day as a categorical variable (i.e., factor). – Isabella Ghement May 14 '18 at 18:08
• Thanks so much! One of my issues is that my subjects don't all have the same pattern. Some up, some down, some zig-zag, some steady :\ I will keep on trying to crack this nut though, many thanks for your advice! – Will May 14 '18 at 18:42
• If you see different response patterns over time across your subjects, you may want to consider random slopes for your dummy Day variables (if you have enough data to fit such a model). – Isabella Ghement May 14 '18 at 20:16