(Note: you might want to use the knitr for this assignment. It is not required, however.) In this problem, you will write Rcode that measures the bias and variance of a simple linear model in the situation in which the truth is linear.
The truth will be f(x) = 3 - 5x and Y = f(x) + epsilon
where epsilon is N(0,10).
a) Generate a sample of n = 50 for the values x = 1:10
b) Estimate the bias at x_0=7. You should run 1000 simulations. You do not need to turn in your code, but you should turn in (i) your estimate of the bias and (ii) an explanation of how you came up with that estimate. Your explanation could be a histogram or some other analysis of your results from the simulation.
c) Estimate the variance of the model at x_0 = 7. Turn in your estimate and an explanation of how you came up with that estimate.
d) Suppose the truth was actually f(x) = 3 - 5x + 7z. Without doing a simulation, how would the bias change and why?