How to fit a time series mixed model with several random effect in R (nmle)?

52 views Asked by At

I need to fit a time series mixed model in nmle. I found that nlme allows to specify the heterogeneous structure of the variance. My response variable is yield, which is dependent on

  • fixed factors: Genotype + Table + Genotype x Week + Table x Week + Akima (Akima is fit as a covariate)
  • Random factors: Col + Row + Col x Week + Row x Week
  • Repeated factor: measurements every "Week" per "Plant"

So far, I have fit the fixed and random factors, and it works.

data$Plant <- as.factor(data$Plant)
data$Week <- as.factor(data$Week)
data$Table <- as.factor(data$Table)
data$Block <- as.factor(data$Block)
data$Row <- as.factor(data$Row)
data$Col <- as.factor(data$Col)
data$Genotype <- as.factor(data$Genotype)

data$br <- with(data, Row:Week)
data$bc <- with(data, Col:Week)


# Only random variables
model1 <- lme(Yield ~ Genotype + Table + Genotype:Week  + Table:Week + Akima,
              random = list(Col=~ 1, Row=~ 1, br=~ 1, bc=~ 1),
              data = data)

The issue appears when I try to add the repeated variable. The variance-covariance matrix I have decided for the repeated factor is the UNSTRUCTURED one.

model2 <- lme(Yield ~ Genotype + Table + Genotype:Week  + Table:Week + Akima,
              random = list(Col=~ 1, Row=~ 1, br=~ 1, bc=~ 1, Plant = pdDiag(~Week)),
              data = data)

After running the last code I got this message:

Error in lme.formula(Yield ~ Genotype + Table + Genotype:Week +  : 
  fewer observations than random effects in all level 5 groups

Finally, I would also like to fit a model with the same fixed and random effect, but with a repeated factor with "Week" measurements per "Col x Row xBlock".

I've been looking for a solution, but I haven't found a similar example. Could someone help me to solve it?

A solution for how to fit a repeated factor with "Plant" as the subject, for which measurements have been taken every "week". It is important to fit the UNSTRUCTURED variance-covariance matrix.

0

There are 0 answers