Question
** You must use R (e.g., RStudio) to complete this problem ** #1 - Assume y = 5 + 0.9x 1 + 3x 2 +
** You must use R (e.g., RStudio) to complete this problem **
#1 - Assume y = 5 + 0.9x1+ 3x2+ . Generate data with x1 norm(2, 0.52), x2 norm(1, 0.12), and x3=x1*x2,and norm(0, = 1). Use sample size n = 200.
Run the following R code:
set.seed(123) n <- 200 s <- 1 x1 <- rnorm(n, 2, 0.52) x2 <- rnorm(n, -1, 0.12) x3 <- x1*x2 e <- rnorm(n, 0, s) y <- 5 + 0.9*x1 + 3*x2 + e#true model summary(y)
Summary(y) must produce the following, if it does not, run it again until it does:
## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 0.8576 3.0472 3.9772 3.8429 4.5566 7.1697
Run model 1 which is y ~ x1+ x2+x3. What is the R2for this model? Enter your answer to 4 decimal places.
Run model 2 which is y ~ x1+ x2. What is the R2for this model? Enter your answer to 4 decimal places.
Run model 3 which is y ~ x1+ x3. What is the R2for this model? Enter your answer to 4 decimal places.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started