try this: y <- c(15.51, 12.44, 31.5, 21.5, 17.89, 27.09, 15.02, 13.43, 18.18, 11.32) x <- seq(3.75, 6, 0.25) coef(lm(y ~ x + I(x^2) + I(x^3)))
I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Jonas Malmros" <[EMAIL PROTECTED]> To: <r-help@r-project.org> Sent: Monday, January 07, 2008 4:15 PM Subject: [R] Polynomial fitting >I wonder how one in R can fit a 3rd degree polynomial to some data? > > Say the data is: > > y <- c(15.51, 12.44, 31.5, 21.5, 17.89, 27.09, 15.02, 13.43, 18.18, > 11.32) > x <- seq(3.75, 6, 0.25) > > And resulting degrees of polynomial are: > > 5.8007 -91.6339 472.1726 -774.2584 > > THanks in advance! > > > > -- > Jonas Malmros > Stockholm University > Stockholm, Sweden > > ______________________________________________ > R-help@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. > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ R-help@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.