[R] Lack-of-fit test for linear mixed effects model (lme) including two fixed effects
Isabella Zwiener
izwiener at gmx.de
Sat May 17 19:22:41 CEST 2014
Dear list members,
I fitted a linear mixed effects model using the lme function from nlme
package. In the model I included two fixed effects, one being continuous and
one a factor having 4 categories. Furthermore, I have one random effect (id)
which I want to include as a random intercept only. I used the following
code:
fit1 <- lme(outcome ~ fixed1 + fixed2, random = ~1|id)
Now I would like to perform a lack-of-fit test. In a previous post (where
there was only one continuous fixed effect) I have seen the following
suggestion:
fit1 <- lme(outcome ~ fixed1, random = ~1|id, method="ML")
fit2 <- lme(outcome ~ factor(fixed1, ordered=TRUE), random = ~1|id,
method="ML")
anova(fit1,fit2)
Now my questions are:
1) How do I perform a lack-of-fit test with one continuous and one factor as
fixed affects?
2) Is it necessary to set method=ML for the lack-of-fit test?
3) If I have to use method=ML for the lack-of-fit test, should I use
method=ML also in my model taht I would like to interpret? In my original
model I used REML, but only because this is the default in lme and I did not
change it.
As I have not applied a lack-of-fit test before, I would really be glad for
any help!
Best regards,
John
More information about the R-help
mailing list