On Apr 26, 2009, at 8:40 PM, Ronnen Levinson wrote:

Hi.

Is there an analog to abline() that can be used to plot a polynomial fit?

For example, I can draw the straight-line fit

   fit <- lm(y ~ x)

via

   abline(coef=fit$coef)

but I'm not sure how to draw the polynomial fit

   fit <- lm(y ~ poly(x,2))

I do see the function curve(), but not how to prepare an expr for
curve() based on the coefficients returned by the polynomial fit.

Thanks for your help,

Use instead the predict function. Something like:

lines(x=seq(min(x), max(x), length=100), y= predict( fit, newdata= ....) #insert properly constructed dataframe



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
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.

Reply via email to