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