Please do this task by R.
a) Revise the simulation shown in the lecture with the aim ofconstructing the empirical sampling distribution of beta_hat, basedon 5000 trials.
b) According to the lecture, the mean of that histogram issupposed to be approximately equal to the true slope. Is it? Showcode.
c) According to the lecture, the standard deviation of thathistogram is supposed to be approximately equal tosigma_eps/sqrt(Sxx). Is it? Show code.
d) According to the lecture, the distribution of the beta_hat issupposed to be normal with certain parameters. Use qqnorm() andabline() to confirm that it is normal.
not sure if this help or not,
n = 10
n.trial = 64
x = c(1:n)
y_true = 10 + 2*x
sigma_eps = 15
par(mfrow=c(8,8),mar=c(0,0,0,0))
set.seed(123)
for(trial in 1:n.trial){
y_obs = y_true + rnorm(n,0,sigma_eps)
lm.1 = lm(y_obs ~ x)
plot(x, y_obs)
abline(10,2, col=2)
abline(lm.1, col=4)
}