I am trying to develop a mixed effects model on a data set with repeated measures.
Met
is measured on a series of randomly selected days on 24 samples submitted to 3 treatments (Treat
, with levels c
, uc
and ga
).
The levels of Met
change due to differences in weather conditions during the days (Date
). Date thus becomes a second random effect of the model (along with the items sampled (ID
)).
My main interest is to see whether Treat
has a significant effect on Met
across days.
some sample data:
# create example data frame
ID <- factor(rep(c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x"), 6))
Treat <- factor(rep(c(rep("c",8), rep("uc",8), rep("ga",8)), 6))
Date <- factor(rep(c(rep("10/06/2007",24), rep("19/06/2007",24), rep("12/07/2007",24), rep("21/07/2007",24), rep("11/08/2007",24), rep("12/08/2007",24)), 1))
Met <- as.numeric(c(rnorm(8,5,2), rnorm(8,7,2), rnorm(8,9,2),
rnorm(8,15,2), rnorm(8,17,2), rnorm(8,19,2),
rnorm(8,9,2), rnorm(8,11,2), rnorm(8,13,2),
rnorm(8,8,2), rnorm(8,10,2), rnorm(8,12,2),
rnorm(8,2,2), rnorm(8,4,2), rnorm(8,6,2),
rnorm(8,3,2), rnorm(8,5,2), rnorm(8,7,2)))
ww <- gl(1,1,144)
lys.data <- data.frame(ID, Treat, Date, Met, ww)
head(lys.data)
# set contrasts of data frame
lys.data$Treat <- factor(lys.data$Treat, levels=c("c", "uc", "ga"))
Then the analysis:
library(nlme)
lme.001 <- lme(Met ~ Treat, data = lys.data,
random=list(ww=pdBlocked(list(pdIdent(~Date-1),
pdIdent(~ID-1)))))
summary(lme.001)
From the results I get it seems that I am not doing what I assume I am doing as the degrees of freedom seem incorrect (way too high). Is it correct that the number of denominator degrees of freedom increase with the number of repetitions (dates) that the experiment has been performed?
Who can help me out here or point me into the right direction? Am I going wrong with the way the I am representing the nesting of the data? (I assume there is none).