[R] linear trend line and a quadratic trend line.

Eric Fail e at it.dk
Sun Nov 8 18:21:16 CET 2009




Dear list users



How is it possible to visualise both a linear trend line and a quadratic trend line on a plot
of two variables?



Here my almost working exsample.



data(Duncan)

attach(Duncan)

plot(prestige ~ income)

abline(lm(prestige ~ income), col=2, lwd=2)



Now I would like to add yet another trend line, but this time a quadratic one. So I have two
trend lines. One linear trend line and a quadratic trend line. A trend line as if I had taken
I(income^2) into the equation.



I know I can make two models and compare them using anova, but for pedagogical resons I wold
like to visualise it. I know the trick from my past as an SPSS user, but I would like to do
this in R as well. Se it in SPSS
http://www.childrens-mercy.org/stats/weblog2006/QuadraticRegression.asp



Thanks in adcance



Eric




More information about the R-help mailing list