1. First we will write some R code to evaluate SSE for my ad hoc line: \(Y = 2X+1\). Use the result to calculate SSE for my Ad Hoc line. (You already know that the final answer is 6.) We are making sure our code works before calculating the SSE for the least-squares line.
# Enter data vectors X, Y
# Make a vector called y_hat_robin and a vector of the errors, maybe call it e_hat_robin
# sum(V^2) will produce the sum of the squares of the elements of the vector V.
# Use this to write code for SSE
2. Next make code to calculate \(b_1\) and \(b_2\).
# Necessary preliminary calculations for r_xy, s_x, s_y, xbar, ybar
# Calculation of b_1 and b_0
# Print b_1 and b_0
3. Now modify the code for Number 1 to calculate SSE for the least squares line. You should be able to copy-paste and make a couple of small changes to produce the code.