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

Petr PIKAL petr.pikal at precheza.cz
Thu Apr 15 08:28:10 CEST 2010


Hi

Bert Gunter <gunter.berton at gene.com> napsal dne 14.04.2010 18:54:37:

> 
> 
> 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.

I completely agree with you. However sometimes it is necessary to put an 
equation and estimated coefficients to a report - for that you can not use 
coefficients from poly() estimate directly. 

(Please do not beat me, I know that polynomial model is ***rarely*** 
physically viable and personally I never use it until it it has not a 
physical sense - like free fall)

Regards
Petr

> 
> 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