Skip to content
Prev 383931 / 398502 Next

"effects" package with "lme4"

Dear Axel,
There's no need to apologize. 

The functions in the effects package compute and graph fixed effects for mixed models. You could compute and graph the BLUP for the fitted spline for each subject (see below) but it's not what the effects package does.

I think that the following does what you want:

-------- snip ----------

subjects <- levels(sleepstudy$Subject)
fits <- matrix(0, length(subjects), 10)
rownames(fits) <- subjects
for (subject in subjects){
  fits[subject, ] <- predict(fm1, newdata=data.frame(Subject=subject, Days=0:9))
}
plot(c(0, 10), range(fits), type="n", xlab="Days", ylab="Reaction")
for (subject in subjects) lines(0:9, fits[subject, ])

-------- snip ----------

Best,
 John