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

Petr PIKAL petr.pikal at precheza.cz
Wed Apr 14 18:16:53 CEST 2010


Hi


Bert Gunter <gunter.berton at gene.com> napsal dne 14.04.2010 18:01:52:

> Below.
> 
> -- Bert 
> 
> 
> Bert Gunter
> Genentech Nonclinical Statistics
> 
> 
> Coefficients are different as you fit different values. See
> 
> ?poly
> 
> poly(-10:10,2)
> 
> I believe that others give you better explanation. So you can not use 
> coefficients evaluated by lm(.~poly(...)) directly.
> 
> -- Well, it depends what you mean by "use...directly." But I think the

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

Regards
Petr


> 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