6.6 Draw a Random Sample and Plot Them All!

x <- runif(50, -1, 1)
x <- sort(x)
w <- rnorm(50, 0, 1)
d <- data.frame( x,  y = 10 * x^2 + w)

plot(d$x, d$y, type = "p", pch = 1, 
     main = "Scatter plot", xlab = "x", ylab = "y")
 lines(c(-100:100)/100, CEF(c(-100:100)/100), col="black", lwd=0.5)
 #lines(c(-100:100)/100, BLP(c(-100:100)/100), col="red", lwd=0.5, lty = 2)
 abline(lm(y ~ x, data = d), col = "red", lwd = 2)
 lines(x, predict(lm(y~I(x^2),data =d)), col='green', lwd=2)