Skip to content
Prev 138820 / 398506 Next

Puzzling coefficients for linear fitting to polynom

It does help if you read the help information for poly.
(Intercept) poly(x, 2, raw = TRUE)1 poly(x, 2, raw = TRUE)2 
           0                       0                       1
You were assuming a power basis for the polynomial, 1, x, x^2.  If you
want to use that you must declare that using raw = TRUE.  The default is
to use an orthogonal polynomial basis, and you can expect the
coefficients relative to that to be, well, puzzling.

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Firas Swidan, PhD
Sent: Friday, 7 March 2008 6:16 PM
To: r-help at r-project.org
Subject: [R] Puzzling coefficients for linear fitting to polynom

Hi,

I can not comprehend the linear fitting results of polynoms. For
example, given the following data (representing y = x^2):
performing a linear fit
gives weird coefficients:
(Intercept) poly(x, 2)1 poly(x, 2)2 
  4.6666667   5.6568542   0.8164966 

However the fitted() result makes sense:
1 2 3 
1 4 9 

This is very confusing. How should one understand the result of
coefficients()?

Thanks for any tips,
Firas.