PLease use R and provide code with output and explanation
Simulation from the SLR Model
Use the rnorm function in R to generate 100 samples of X ~ N(0,2) (for help use ?rnorm ) and for each draw, simulate Yi from the simple linear regression model Yi = 2.5 - 1.0Xi + ei, where ei ~N(0,3).
(i) Show the scatter plot of Y versus X along with the true regression line.
(ii) Split the sample into 2 subsets of size 25 and 75. For each subset, run the regression of Y on X. Add each fitted regression line (use color) to your plot from (i). Why are they not the same?
(iii) What is the marginal sample mean for Y ? What is the true marginal mean?
(iv) Add the bounds of the true 90% prediction interval to your plot (use qnorm for help with quantiles and and lty=2 in lines() to get a dashed line). What percentage of your observations are outside of this interval?