Question
(Please use Rmarkdown to answer (e) and (f) ) Create some simulated data and will fit a linear regression models to it. Make sure to
(Please use Rmarkdown to answer (e) and (f) )
Create some simulated data and will fit a linear regression models to it. Make sure to use set.seed(1) prior to starting part (a) to ensure consistent results. a. Using the rnorm() function, make a vector, X, containing 100 observations drawn from a N(0,1) distribution. This represents a feature, X. b. Using the rnorm() function, make a vector ,containing 100 observations drawn from a N(0,0.25) distribution i.e. a normal distribution with mean zero and variance 0.25. c. Using x and ,generate a vector y according to the model Y= 1 + 0 .5X+ . What is the length of the vector y? What are the values of 0,1 in this linear model? d. Make a scatterplot displaying the relationship between x and y. Fit a least squares linear model to predict y using x. Display the least squares line on the scatterplot. Draw the population regression line on the plot, in a different color. Use the legend() command to make an appropriate legend. e. Then fit a separate quadratic regression, i.e. Y= 0 + 1 X + 2 X2 + .Consider the training residual sum of squares (RSS) for the linear regression, and also the training RSS for the quadratic regression. Would we expect one to be lower than the other, would we expect them to be the same, or is there not enough information to tell? Justify your answer. f. Answer (e) using a test rather than RSS.
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