Question: Need r code plz 6. This exercise will help you understand what is a 95% confidence interval. Suppose that the population regression line is known

Need r code plz
6. This exercise will help you understand what is a 95% confidence interval. Suppose that the population regression line is known as E(Y) = 0 + 1x, where -5 and A-10, and z is uniformly generated from [0,1]. The sample size used to estimate this line is n 100 Try to finish the following simulation code to construct 95% confidence intervals for A and check the coverage rate, i.e., the percentage of confidence intervals covering the true value of B n - 100 x - seq(O, 1, length-100) beta= 5 beta1-10 Ey = b eta0 betal * x nsm = 100 #bivec is a vector keeping track of the estimate bl for each simulation b1vec1:nsim 0 #msevec is a vector keeping track of MSE (mean square error) for each simulation coverage0 for(i in 1:nsim) y - Ey + rnorm(n) 2 #your code to regress y on x and find bl bivec[i]-b1 #your code to construct a 95% confidence interval for beta1 #your code to compute mse msevecLi]mse #the confidence interval is named as ci-b1 if (ci b1[1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
