[R-sig-ME] Use of poly( ) in LMER: bug?

Reinhold Kliegl reinhold.kliegl at gmail.com
Fri Feb 12 17:29:13 CET 2010


Try:
library(lme4)
(fm1 <- lmer(Reaction ~ Days + (1|Subject), sleepstudy))
(fm2 <- lmer(Reaction ~ poly(Days, 1, raw=TRUE) + (1|Subject), sleepstudy))

Then:
?poly

Reinhold Kliegl

On Fri, Feb 12, 2010 at 5:14 PM, Javier Perez-Barberia
<j.Perez-Barberia at macaulay.ac.uk> wrote:
> Dear users,
>
> After more than a day figuring out why my predicted values were so high we found out that fitting a term as poly(my_term,1)
> was creating havoc in the fixed effects of LMER for this term.
>
> I thought that poly(my_term,1) was the same that fitting "my_term", it seems that I was wrong.
>
> Although it doesn't make sense fitting a linear term as poly(my_term,1) rather than the more economical "my_term", I wonder what it is behind
> the poly( ) function that produces such a different result (see below).
>
> Many thanks
>
> Javier
>
> Model 1
> fm1<-lmer(niche_breadth~cos_days+sin_days+poly(easting,2)+poly(northing,2)+
>          poly(mean_temp,1)+lgdensity+lgdensity*poly(easting,2)+lgdensity*poly(northing,2)+
>          (lgdensity|block)+(1|year),data=data)
>
>
> fixef(fm1)[8]
> poly(mean_temp, 1)
>         0.1789691
> Model 2 (as Model 1 but "mean_temp" rather than "poly(mean_temp,1)")
>
> fixef(fm1)[8] ##all other fixed effects were as in Model 1.
>   mean_temp
> 2.590413e-05
>
>
> Dr. Javier Perez-Barberia
> Population and evolutionary ecologist
> The Macaulay Institute
> Craigiebuckler
> Aberdeen
> AB15 8QH
> Scotland, UK
>
> Tel: +44(0)1224 395221
> e-mail: j.perez-barberia at macaulay.ac.uk
> http://www.macaulay.ac.uk
> http://www.macaulay.ac.uk/upland
>
> --
> Please note that the views expressed in this e-mail are those of the
> sender and do not necessarily represent the views of the Macaulay
> Institute. This email and any attachments are confidential and are
> intended solely for the use of the recipient(s) to whom they are
> addressed. If you are not the intended recipient, you should not read,
> copy, disclose or rely on any information contained in this e-mail, and
> we would ask you to contact the sender immediately and delete the email
> from your system. Thank you.
> The Macaulay Land Use Research Institute is a company limited by guarantee,
> registered in Scotland under company number 16190 and a registered Scottish
> charity, number SC011922. Registered office
> Macaulay Drive, Craigiebuckler, Aberdeen, AB15 8QH.
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




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