Re: [R] Puzzling coefficients for linear fitting to polynom

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Fri, 07 Mar 2008 09:32:04 +0100

poly() computes by default orthogonal polynomials; check the online help file for poly() for more info. Probably you want to use the 'raw' argument in this example, i.e.,

x <- 1:3
y <- c(1, 4, 9)
lm(y ~ poly(x, 2, raw = TRUE))

I hope this helps.

Best,
Dimitris



Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


> Hi,
>
> I can not comprehend the linear fitting results of polynoms. For
> example, given the following data (representing y = x^2):
>
>> x <- 1:3
>> y <- c(1, 4, 9)

>
> performing a linear fit
>
>> f <- lm(y ~ poly(x, 2))
>
> gives weird coefficients:
>
>> coefficients(f)
> (Intercept) poly(x, 2)1 poly(x, 2)2
> 4.6666667 5.6568542 0.8164966
>
> However the fitted() result makes sense:
>
>> fitted(f)
> 1 2 3
> 1 4 9
>
> This is very confusing. How should one understand the result of
> coefficients()?
>
> Thanks for any tips,
> Firas.
>
> --
> Firas Swidan, PhD
> Founder and CEO
> Olymons: Blessing Machines with Vision (TM)
> http://www.olymons.com
> P.O.Box 8125
> Nazareth 16480
> Israel
> Cell: +.972.(0)54.733.1788
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 07 Mar 2008 - 08:35:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Mar 2008 - 09:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive