# I need help specifying my lmer model

I have a question to setting up my lmer model.

I have measures of two groups of participants. Each participant was measured twice on two separate days (before and after; b_a). I want to find out if the treatment in group 1 leads to changes in the measurement “before" and “after” and if the effect changes from day1 to day2. So, I am interested in the interaction of group * day * before/after. If I understood correctly, then my fixed effects structure is clear. Though, I am not sure about the random effects structure. My suggestion for the model would be:

lmer(measurement ~ 1+ group * day * b_a + (1|subject)+ (1+Day/b_a), data)

… apparently this is the same as

lmer (measurement ~ 1+ group * Day * b_a + (1|subject), data)

at least the output is the same…

My first question: Is this the correct model?

My second question would be: If it is, then why does my RManova (with ezanova) give me different results? (can this have to do with the different calls summary(model) vs anova(model)?)

Thanks in advance for your help!

## 1 Answer

First: You can leave out the 1+ part, as the intercept is always fitted unless it is explicitely disabled.

Next: If I understand your goal directly, you correctly identified the fixed effect structure. Let's work on the random effect structure. There are two things to consider: What kind of grouping do you have, and what can differ in this grouping. Grouping is done in your design by separating participants into two groups (probably experimental vs. control), by each participant being measured multiple times, and by the different days. Since you are interested in the difference between the two groups, this is a fixed and not a random effect. Similarly, you are interested if there is a difference between the two days, so again, this is a fixed effect.

This only leaves the subject as a valid grouping. Since you don't seem to be interested between differences in the participants, this is a random effect. Random effects are always given with |..., so you need a |subject in your random effects structure (which is missing the second part.

Now some points on the fixed effects: When you write group * day * b_a that implies you are including all main effects as well as their interactions. If you randomized your groups, there is absolutely no reason to expect a group main effect. While it often doesn't hurt to keep it in, there can be some cases where this can lead to bad model fits. You should monitor convergence and significance of this predictor, and if it becomes significant (or does not converge) you should be very skeptical of the model.

Let's get to the random effects structure: Participants are separated into groups, so any random effect including group cannot be used (this includes interactions). So the most general random effects structure would be Day * b_a|subject (different effects of day, b_a, and their interaction for each subject).

However, because you have grouped subjects into two groups, you should be expecting differences between subjects that are not just random fluctuations, but rather related to the manipulation. Thus, between-subject variances may be overestimated and effects may be underestimated. Also, if you only have four measurements per subject, you may not be able to reliably estimate the between-subject variances. So you might have to thin out your random effects structure later to get the model to converge (you can also try dropping predictors, that you know should be zero).

If you want to be simplistic (complicated random effects structures often require many models to be tried out, and this can greatly increase researcher dfs), then (1|subject) also is quite acceptable.

• Thank you so much! I understand the random effects structure being (day*b_a|subject) and a simpler one being (1|subject). The problem with the simpler structure is that the results don't match what I see in the plots... Now, for the more complex RE structure the model does not converge. As far as I know, I can "thin out" RE structure by assuming uncorrelated slopes and intercepts. Is there another way to “thin out”? – Lathy Mar 26 '20 at 14:42
• I also understand what you mean with "as you have grouped subjects into two groups, you should be expecting differences between subjects that are not just random fluctuations, but rather related to the manipulation". Did I understand correctly, that considering this, I would need something like (group|subject). But, as I split subjects into groups, this is not possible...? Or did I completely misunderstand that part? – Lathy Mar 26 '20 at 14:42
• @Lathy group|subject would imply a different effect of group for each subject. That is not possible, as each subject is only in one group (there is no between-subject group effect). 1) There shouldn't be any group effect at all, at least if you randomly partitioned subjects into the groups. Any group effect, that you might find is related to between subject differences, so including it in the model may lead to artifacts. 2) You are expecting a different b_a effect in each of the groups (the b_a X group interaction). However, then the fixed effect is correlated with the random effect. – LiKao Mar 30 '20 at 10:42
• @Lathy As for thinning out: Yes removing the correlations is one step. Removing random effects altogether is another. There is some guidance on CV on how to do this. Why the results don't match the plots, I cannot tell because I don't know the plots and what you expect. Could be related to many things. – LiKao Mar 30 '20 at 10:44
• @Lathy Some things that could change the plots as well as the models: Do you have any subjects with missing cells? RManova has to drop these subjects, lmer doesn't (but it could lead to convergence problems). Depending if subjects with missing cells are also dropped when graphing the data, this could also show why the plots don't match. Also, you could look the shrinkage of the different effects. If they are strongly asymetric, then this could also produce differences. – LiKao Mar 30 '20 at 10:49