[R] Plot different regression models on one graph

kMan kchamberln at gmail.com
Sun Feb 14 23:30:33 CET 2010


Dear Rhonda,

Consider curve().

KeithC.

-----Original Message-----
From: Rhonda Reidy [mailto:rreidy at gmail.com] 
Sent: Saturday, February 13, 2010 11:36 AM
To: r-help at r-project.org
Subject: [R] Plot different regression models on one graph

The following variables have the following significant relationships (x is
the explanatory variable): linear, cubic, exponential, logistic. The linear
relationship plots without any trouble. 

Cubic is the 'best' model, but it is not plotting as a smooth curve using
the following code:

cubic.lm<- lm(y~poly(x,3))
lines(x,predict(cubic.lm),lwd=2)

How do I plot the data and the estimated curves for all of these regression
models in the same plot? 

x <- c(62.5,68.5,0,52,0,52,0,52,23.5,86,0,0,0,0,0,0,0,0,0,0)

y <-
c(0.054,0.055,0.017,0.021,0.020,0.028,0.032,0.073,0.076,0.087,0.042,0.042,0.
041,0.045,0.021,0.018,0.017,0.018,0.028,0.022)

Thanks in advance.

Rhonda Reidy

	[[alternative HTML version deleted]]



More information about the R-help mailing list