: [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
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
2 matches
Mail list logo