1
$\begingroup$

I have been scouring Stackexchange and various sites for the past few days for an answer to this question, and I've found a lot of helpful comments. However, I want to know if I've used correct syntax for my model in nlme. A main issue is that I'm having trouble replicating published results from the exact same dataset. The experimental setup is as follows:

Randomized complete block design (i.e., 4 treatments [including control] within each block, 6 blocks)

Repeated measures (i.e., mean weekly measurements over the course of a year)

Unbalanced (i.e., sometimes weekly data is missing for some plots within blocks)

In the published work, the authors say that they used a "mixed model ANOVA with repeated measures and an autoregressive level 1 covariance matrix". They say that they use treatment, week, and their interaction as fixed effects and block as a random effect. Because of their specification of the covariance matrix structure, I have decided to use nlme, which allows for that parameter (as opposed to lmer4, as far as I understand). Here is my best attempt at replication, to no success:

mod <- lme(mean ~ treatment * week, random = ~ 1 | block/treatment, correlation = corAR1(), 
       control = lmeControl(opt = 'optim'), data = df)

I believe my issue lies somewhere in how I'm defining the "random" term. Any help is greatly appreciated!!

$\endgroup$
  • 1
    $\begingroup$ What I can tell you is that your auto-correlation structure needs the same grouping factors as your random effect. You should also supply the time covariate to it if you have missing values. corAR1(form = ~ week | block / treatment) $\endgroup$ – Roland Dec 5 '16 at 12:03
  • $\begingroup$ @Roland - Thank you. I get this error when I use week|block/treatment: Error in Initialize.corAR1(X[[i]], ...) : covariate must have unique values within groups for "corAR1" objects. This was my code: mod <- lme(mean ~ treatment * week, random = ~ week | block/treatment, correlation = corAR1(value = 0.9, form = ~week|block/treatment), control = lmeControl(opt = 'optim'), data = df) $\endgroup$ – user2943039 Dec 5 '16 at 15:01
  • $\begingroup$ The error is self-explaining. Package nlme supports only one value per combination of week/block/treatment. If you have repeated measures inside this grouping, you can't use it. Do you have subplots? Or measurements twice a week? Or just random replicate measurments (which you'd need to aggregate then)? $\endgroup$ – Roland Dec 5 '16 at 15:51
  • $\begingroup$ @Roland - The error may be self-explaining, but it wasn't clear to me. As described in the post, this is a repeated measures experiment, where treatments within blocks were measured weekly. Because the weekly measurements are highly autocorrelated, that is why I'm using the correlation structure. I measured autocorrelation and input it into the parameter value. With this knowledge, do you see any other issues with the format of my code, based on what I want to accomplish? $\endgroup$ – user2943039 Dec 5 '16 at 16:10
  • 1
    $\begingroup$ Check again.The error message doesn't lie. $\endgroup$ – Roland Dec 6 '16 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.