Remember that polynomials of the form
y = b1*x + b2*x^2 + ... + bm*x^m
fit the linear regression equation form
Y = beta_1*x_1 + beta_2*x_2 + ... + beta_m*x_m
If one sets (from the 1st to the 2nd equation)
x - x_1
x^2 - x_2
x^3 - x_3
etc.
In R this is easy, just use the identity operator
It is easier to use poly(raw=TRUE), and better to use poly() with
orthogonal polynomials.
The original poster shows signs of having read neither the help for
predict.lm nor the posting guide, and so almost certainly misused the
predict method.
On Thu, 16 Aug 2007, Jon Minton wrote:
Hi everybody!
I'm looking some way to do in R a polynomial fit, say like polyfit
function of Octave/MATLAB.
For who don't know, c = polyfit(x,y,m) finds the coefficients of a
polynomial p(x) of degree m that fits the data, p(x[i]) to y[i], in a
least squares sense. The result c is a vector of