[R] Obtaining a quadratic function igven three points on a curve

Joshua Wiley jwiley.psych at gmail.com
Thu Jan 20 15:50:57 CET 2011


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 <bbriley at 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 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list