I think you need poly(X, 2, raw = TRUE) to interpret the coefficients
in the manner described below.
poly uses orthogonal polynomials by default:
poly package:stats R Documentation
Compute Orthogonal Polynomials
Description:
Returns or evaluates orthogonal polynomials of degree 1 to
'degree' over the specified set of points 'x'. These are all
orthogonal to the constant polynomial of degree 0. Alternatively,
evaluate raw polynomials.
David Scott
On 21/01/2011 3:50 a.m., Joshua Wiley wrote:
Hi Barth,
Here is an option fitting a linear model toa second order polynomial
and extracting the coefficients. The Intercept corresponds to "c" in
your email, then poly(...)1 to "b" and poly(...)2 to "a".
################
dat<- read.table(textConnection("
Y X
0.159529 0
0.5 0.773019
1 1"), header = TRUE)
closeAllConnections()
coef(lm(Y ~ poly(X, 2), data = dat))
#################
For details see:
?poly
?lm
?coef
Hope this helps,
Josh
On Thu, Jan 20, 2011 at 6:42 AM, Barth B. Riley<bbri...@chestnut.org> wrote:
Hello
I would like to obtain the coefficients for a quadratic function (ax^2 + bx +
c) given three sets of points on the quadratic curve. For instance:
Y X
0.159529 0
0.5 0.773019
1 1
Is there a function in R to obtain the a, b and c ceofficients?
Thanks
Barth
PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
______________________________________________
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.
--
_________________________________________________________________
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142, NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018
Director of Consulting, Department of Statistics
______________________________________________
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.