rm(list=ls())
numPts = 10
vareps = 1
X = rnorm(numPts)
Y_true = 2 * X
Y_resp = Y_true + rnorm(numPts,0,sqrt(vareps))
plot(X,Y_resp)
# don't worry too much about the following four lines of code,
# at least for now... You are going to see them *A LOT* in the
# next classes ;-)
fit = lm(Y_resp~X)
summary(fit)
abline(fit)
Y_hat = coef(fit)[1] + coef(fit)[2] * X
cat("E(Y_resp - Y_hat) = ", mean((Y_resp - Y_hat)^2), "\n")
cat("E(Y_true - Y_hat) = ", mean((Y_true - Y_hat)^2), "\n")
cat("var(eps) = ", var(Y_true - Y_resp), "\n")