[R] Plotting a quadratic line on top of an xy scatterplot
jean.plamondon at fpinnovations.ca
Tue Apr 12 06:14:36 CEST 2011
Is it just me or it appears the "temperature" and "probability" should be
Anyhow it should help you to assign your model to a variable (as Joshua did
with his own suggestion)
yourmodel <-lm(x[,2] ~ x[,1] + I(x[,1]^2)) # again, taking literally the way
you formulated it...
And you could then access the coefficients individually:
c <- coef(yourmodel) # for the intercept
b <- coef(yourmodel)
a <- coef(yourmodel)
To build yourself a vector of predicted y-values based on a vector of
x-values ("dat" as per Joshua's post)
and pass them to the "lines" function to be plotted over your existing plot.
This is less convenient than using the "predict" but sometimes it helps to
do the arithmetic at a lower level.
View this message in context: http://r.789695.n4.nabble.com/Plotting-a-quadratic-line-on-top-of-an-xy-scatterplot-tp3443018p3443693.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help