Re: [R] using poly() to predict

2015-01-15 Thread Stanislav Aggerwal
Thanks Prof Ripley. For anybody else wondering about this, see: http://stackoverflow.com/questions/26728289/extracting-orthogonal-polynomial-coefficients-from-rs-poly-function = The polynomials are defined recursively using the alpha and norm2 coefficients of the poly

[R] using poly() to predict

2015-01-14 Thread Stanislav Aggerwal
This method of finding yhat as x %*% b works when I use raw polynomials: x-1:8 y- 1+ 1*x + .5*x^2 fit-lm(y~poly(x,2,raw=T)) b-coef(fit) xfit-seq(min(x),max(x),length=20) yfit-b[1] + poly(xfit,2,raw=T) %*% b[-1] plot(x,y) lines(xfit,yfit) But it doesn't work when I use orthogonal polynomials:

Re: [R] using poly() to predict

2015-01-14 Thread Prof Brian Ripley
On 14/01/2015 14:20, Stanislav Aggerwal wrote: This method of finding yhat as x %*% b works when I use raw polynomials: x-1:8 y- 1+ 1*x + .5*x^2 fit-lm(y~poly(x,2,raw=T)) b-coef(fit) xfit-seq(min(x),max(x),length=20) yfit-b[1] + poly(xfit,2,raw=T) %*% b[-1] plot(x,y) lines(xfit,yfit) But it