Skip to content
Prev 14714 / 20628 Next

Repeated measures with a non-linear time effect

Hi Dan,

that was a misunderstanding. I meant you should code time as a factor and run a modified version of the model (see code below).

library(lme4)
library(lattice)
library(multcomp)

df <- data.frame(subject = rep(c("T1", "T2", "T3", "C1", "C2", "C3"), 3),
                 group = rep(c(rep("T", 3), rep("C", 3)), 3),
                 time = c(rep(1, 6), rep(2, 6), rep(3, 6)),
                 measure = c(0, 253, 155, 16, 232, 251, 1035, 1014, 760, 98, 239, 87, 371, 60, 47, 0, 260, 190),
                 col = rep(c(rep("red", 3), rep("blue", 3)), 3), stringsAsFactors = FALSE)
df$time <- as.factor(df$time)
xyplot(measure ~ time|subject, data = df)

# using the lme4 package
fit <- lmer(measure ~ time * group + (1|subject), data = df)
summary(fit)
cftest(fit)

# using anova
fit <- aov(measure ~ time * group + Error(subject), data = df)
summary(fit)

Both models are able to detect the interaction between treatment and time.

Hope this helps.

Best,

J?rg

?
J?rg Albrecht, PhD
Postdoctoral researcher
Institute of Nature Conservation
Polish Academy of Sciences
Mickiewicza 33
31-120 Krakow, Poland
www.carpathianbear.pl <http://www.carpathianbear.pl/>
www.globeproject.pl <http://www.globeproject.pl/>
www.iop.krakow.pl <http://www.iop.krakow.pl/>