# How do I use lme4 in R for linear mixed effects?

I read up quite a number of resources and I'm still unsure how/if I am applying the lmer correctly for my data.

I'm looking for between-group differences in response rates (controlling for baseline values) for 4 incentive groups (there is a within-subjects factor and a between-subjects factor, and it is the group*round interaction that I am interested in).

My data looks like this:

After reading some of the forums and papers, based on what I understood, I coded it this way:

lmer(response_rate ~ Round + Group + Round*Group + (1|ID), data=data)

Just wanted to check if this makes sense/if this is correct?

Any advice/help would be greatly appreciated. Or if there are any basic resources on this for a beginner in stats would also be great.

Thank you so much! :)

• You have not included baseline which you stated you wanted to include. Mar 11 at 11:42
• To follow up on the comment from @mdewey : is Round 1 perhaps the "baseline" for the Round 2 observations? Are there only 2 observations on each individual, one in each Round? Also, what is the "response rate": is it something like a count, or a fraction of trials with a certain outcome?
– EdM
Mar 11 at 13:31
• Hi :) thanks so much for replying to my query. It's an RCT with different rounds, and baseline will be round1, and round2 are observation rounds. response_rate is the percentage of surveys done for each participant per round. Eventually there will be a total of 3 rounds done - but for now I am just looking at round1 and round2. Mar 15 at 2:51

• Welcome! That's basically correct. (+1) Remaining questions are whether that's the best use of the data and if glmer might be needed. With only 2 observations per individual, one might "control for baseline" by evaluating Round2-Round1 differences in a one-way ANOVA (extending paired t-tests to 4 groups). That approach would avoid modeling the distribution of random intercepts. It wouldn't, however, allow for evaluation of differences among groups in Round1 values; your approach would. lmer vs glmer depends on the nature of the response_rate, which isn't clear from the question.