[R-sig-ME] How to extend an existing linear mixed effects model using lme in R?

Thierry Onkelinx thierry.onkelinx at inbo.be
Wed Mar 30 09:23:02 CEST 2016

Dear Urs,

What you can do is first get the predictions from m1 for dataset d and add
it as a variable to dataset d. Then fit a model on dataset d using the
prediction from m1 as an offset.

d$M1 <- predict(m1, newdata = d, level = 0)
m2 <- lme(y ~ offset(M1) + c, random = ~1|id, data = d)


d$M1 <- predict(m1, newdata = d, level = 1)
m2 <- lm(y ~ offset(M1) + c, data = d)

fitting m2 <- lme(y ~ a + b + c, random = ~1|id, data = d) will probably
give a better fit.

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-03-30 2:32 GMT+02:00 urs <urs op kleinholdermann.de>:

> Dear list,
> I fitted a linear mixed effects model using lme in R on a relatively large
> data set. Now I want to extend this model, introducing an additional fixed
> effect on a subset of the data without altering coefficients estimated on
> the original dataset. I.e.
> original model for example:
> m1 = lme(y~a+b,random=~1|id,data=D)
> now I want to do something similiar to
> m2 = update(m1,~.+c,data=d)
> Where d is a subset of D. The values of the new predictor c are only
> available for this subset. However, I would like to keep the originally
> estimated coefficients of the model m1 with regard to predictors a and b.
> If I use update as described above coefficients for all predictors (a,b,c)
> are estimated again on the smaller dataset d. Any suggestions on how I can
> estimate the effect of c while keeping the old coefficient values for a and
> b? Or is this for some reason a bad idea altogether?
> Urs
> _______________________________________________
> R-sig-mixed-models op r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

	[[alternative HTML version deleted]]

More information about the R-sig-mixed-models mailing list