Re: [R] poly regression

2009-06-10 Thread Ravi Varadhan
: [R] poly regression They have different coefficients because their model matrices are different but they both lead to the same predictions: > fitted(lm(y~1+x+I(x^2))) 1 2 3 4 5 6 7 8 9 10 1 4 9 16 25 36 49 64 81 100 > fitted(lm(y~poly(x,2))) 1 2 3 4

Re: [R] poly regression

2009-06-10 Thread Gabor Grothendieck
They have different coefficients because their model matrices are different but they both lead to the same predictions: > fitted(lm(y~1+x+I(x^2))) 1 2 3 4 5 6 7 8 9 10 1 4 9 16 25 36 49 64 81 100 > fitted(lm(y~poly(x,2))) 1 2 3 4 5 6 7 8 9 10 1

[R] poly regression

2009-06-09 Thread Ning Ma
hi, I want to do a polynomial regression of y on x of degree 2, as following > x<-1:10 > y<-x^2 > lm(y~poly(x,2)) Call: lm(formula = y ~ poly(x, 2)) Coefficients: (Intercept) poly(x, 2)1 poly(x, 2)2 38.5099.9122.98 Which is not what i had expected. If I wrote the expre