\begin{Schunk}
\begin{Sinput}
 x <- rnorm(100, m = 50, s = 20)
 y <- 3 + 0.2 * x + 15 * rnorm(100)
 mp1 <- lm(y ~ x)
 ndf <- data.frame(x = plotSeq(x,40))
 p1 <- as.data.frame(predict(mp1, interval="conf", newdata = ndf))
 p2 <- as.data.frame(predict(mp1, interval="pred", newdata = ndf))
 plot(x, y, ylim = magRange(y, 1.3))
 lines(ndf$x, p1$fit, col = "black", lwd=3)
 lines(ndf$x, p1$lwr, col = "red", lwd = 3, lty = 4)
 lines(ndf$x, p1$upr, col = "red", lwd = 4, lty = 4)
 lines(ndf$x, p2$lwr, col = "purple", lwd = 4, lty = 3)
 lines(ndf$x, p2$upr, col = "purple", lwd = 4, lty = 3)
 legend("topleft", legend = c("predicted","Conf. Interval", "Pred. Interval"), col = c("black", "red", "purple"), lty = c(1, 4,3), cex = 0.8, lwd = 3)
\end{Sinput}
\end{Schunk}
