# Mixed model repeated measures in R - specific questions

I am using a mixed model repeated measures analysis and have a few questions in terms of how to structure the model.

My setup is 24 individual plots, grouped into 6 blocks. There are 4 treatments in 2 levels: i.e. 2 different treatment types, 4 treatments in total: No treatment, treatment 1, treatment 2, interaction between treatment 1 and 2. Each treatment is replicated once per block, i.e. 6 times in total.

Measurements are repeated over time. I.e. the same plot is repeatedly measured at different time points. All plots are measured once for each time point. The time intervals between each measurement campaign (time point) are not equal (i.e. could vary from a few days to several weeks), which needs to be accounted for in the analysis, if possible. Most likely, the variances are also not equal for each measurement campaign.

I would put Block as a random factor, but it could also be added as a fixed effect.

So to sum up:

Dependent variable - y

Fixed effects - Treatments T1 and T2, separately and interaction

Random effect - Block (could also be fixed?)

Subject - PlotID, individual plots (which are repeated through time)

Repeated measures - Time point (given as day-of-year)

I tried the following syntax for mixed model repeated measures in R (lme4 package, lmerTest for p-values):

a. lmer(y ~ T1 * T2 * Time + (1|Block), data=dataset)

But I understand there are other ways as well:

b. lmer(y ~ T1 * T2 * Time + (1+Time|Block), data=dataset)

c. lmer(y ~ T1 * T2 * Time + (1|Block/Time), data=dataset)

d. lmer(y ~ T1 * T2 * Time + (1|Block:Time), data=dataset)

e. lmer(y ~ T1 * T2 * Time + (1+Block|PlotID), data=dataset)

Here are my questions:

1. Which model would be most correct in my case? What are the differences between them? I should note that when I ran models b-e, my model did not always converge. What would be the reason for this?

2. Is this the correct way of doing repeated measures - to simply include Time as a fixed factor? Or is there another way of structuring this type of analysis?

3. Should Time (day-of-year) be classified as factor, numeric or integer?

4. Should I specify PlotID anywhere (as in e)? I need the model to recognise that I have 24 individual plots repeated over time. At the same time, I want to correct for the noise arising from the differences between blocks. Each combination of treatment and block is unique (i.e. 24 in total).

5. What covariance structure does R use? How are the degrees of freedom calculated?

6. I previously set up the analysis in SAS Enterprise. Here, I ran into the problem that I got no significant results at all, even though it looks like there should at least be some significance according to my graphs. Also, I get completely different results in R and SAS. What is the reason for this?

• None of your random effects is what I would have chosen. I believe you should consider the plots nested within the blocks. Assuming you only need a random intercept (and that's what I usually start with) you should use (1 | Block / Plot). If you include Time as numeric in your fixed effect, you model a linear trend. That might or might be not appropriate. Including time as a factor variable is a practice I would avoid, although it might work well if you have very few time points. Otherwise, you'll quickly overparameterize your model. A GAMM might be a better option (see package mgcv). ... Feb 25, 2016 at 9:12
• ... Variance and auto-correlation structures you can model with the nlme package. Feb 25, 2016 at 9:12

I found this page quite helpful to decide how to specify the formula depending on the design. Your random part would probably look like (1 + time | Block/PlotID) - however, I'm not sure if you even would want to include the interaction in the random parts as well.
Question 3) If you use time as factor, you may get an error (like number of observations <= number of random effects or so). In such cases, use argument control = lmerControl(check.nobs.vs.nRE="ignore") in your lmer-call. See this post for more details. For more than two or three time points, I would include time as numeric.