1. Simulate a data set with 40 observations: X ~ N(u = 3; v = 4), Y = 2 - 6X + e where
e ~ N(u = 0; v= 4). Use this data set to do a regression analysis
(a) Draw a scatter plot
(b) Write your own R code to calculate 0 and 1. (Don't use lm())
(c) Calculate condence interval for 0 and 1.(Don't use lm())
(d) Suppose there is a new X = 2:7, calculate the condence interval for E(Y jX = 2:7) and the
prediction interval. ((Don't use lm()))
(e) Use lm() to verify your answer in part (b)-(d).
如何将如下思路转换成代码?求代码b-d