[R] Odp: fitting a quadratic function - poly?

Bert Gunter gunter.berton at gene.com
Wed Apr 14 18:54:37 CEST 2010


 

Petr Pikal wrote:

"...

I mean that you can use

fit<- lm(y~x+I(x^2))
coef(fit)[1] + coef(fit)[2]*x + coef(fit)[3]*x^2

but you can not use

fit<- lm(y~poly(x,2))
coef(fit)[1] + coef(fit)[2]*x + coef(fit)[3]*x^2  "

(to get the fits for any x vector)

-- But you **can** use

ypred <- predict(fit,data.frame(x = x))

-- in **both** cases. Which is, I think, how it should be done.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Statistics 



> answer is, "yes you can." See ?SafePrediction  for details. -- Bert
> 
> Regards
> Petr
> 
> > 
> > Thanks in advance,
> > Stefan
> > 
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list