Polynomial equation
Hi Chris, You can use lm with poly (look ?lm, ?poly). If x and y are your arrays of points and you wish to fit a polynom of degree 4, say, enter: model <- lm(y~poly(x,4,raw=TRUE) and then summary(model) The raw=TRUE causes poly to use 1,x,x^2,x^3,... instead of orthogonal polynomials (which are "better" numerically but may be not what you need). Regards, Moshe.
--- On Fri, 8/1/10, chrisli1223 <chrisli at austwaterenv.com.au> wrote:
From: chrisli1223 <chrisli at austwaterenv.com.au> Subject: [R] Polynomial equation To: r-help at r-project.org Received: Friday, 8 January, 2010, 12:32 PM Hi all, I have got a dataset. In Excel, I can fit a polynomial trend line beautifully. However, the equation that Excel calculates appear to be incorrect. So I am thinking about using R. My questions are: (1) How do I fit a polynomial trendline to a graph? (2) How do I calculate and display the equation for that trendline? Many thanks for your help. Greatly appreciated. Chris -- View this message in context: http://n4.nabble.com/Polynomial-equation-tp1009398p1009398.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.