#Create a quadratic regression
stde <- 14
x <- rnorm(100, m=50, s=10)
y <- 0.2 - 02*x + 0.2*x^2 + stde*rnorm(100)
mod1 <- lm (y ~ poly(x, 2))
plot(x, y, main="The Quadratic Regression")
seqx <- plotSeq(x, length.out=10)
seqy <- predict(mod1, newdata=data.frame(x=seqx))
lines(seqx, seqy, col="red")
# Notice the bad result when a plotting sequence is
# not used.
plot(x, y, main="Bad Plot Result")
seqy <- predict(mod1)
lines(x, seqy, col="green")
Run the code above in your browser using DataLab