Skip to content

polynom Fit

2 messages · E.A. Welge, Rafael A. Irizarry

#
Please, I'm a beginner with the R language. I'm looking for a function to
compute a Polynomfit for simple x-y Data. Who can help?

Many Greetings
E.A. Welge

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 5 Aug 2002, E.A. Welge wrote:

            
if you want least squares look at the help files for "lm" and "poly".
poly creates a basis matrix for polynomials evaluated at x 
lm does least squares fitting.

here is an example:

x <- 1:100   #simulated data
y <- rnorm(100)
n <- 4      #degree of polynomial
fit1 <- lm(y~poly(x,degree=n)) ##fit to data
plot(x,y)  #examle plot
lines(x,fitted(fit1))


hope this helps,
rafael
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._