Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve using R studio We will use the Carseats dataset that is part of the ISLR package. We may also need the following packages:
Please solve using R studio
We will use the Carseats dataset that is part of the ISLR package. We may also need the following packages: caret, dplyr and glmnet
For this assignment, we only need the following attributes: "Sales", "Price", "Advertising", "Population",
"Age", "Income" and "Education". The goal of the assignment is to build models to predict the sales of the
carseats Sales attribute using the other attributes.
We can use the dplyr select function to select these attributes.
CarseatsFiltered Carseats selectSales "Price",
"Advertising","Population","Age","Income","Education"
Build a Lasso regression model to predict Sales based on all other attributes Price "Advertising", "Population", "Age", "Income" and "Education" What is the best value of lambda for such a lasso model? Hint: Do not forget to scale your input attributes you can use the caret preprocess function to scale and center the data. Hint : glment library expect the input attributes to be in the matrix format. You can use the asmatrix function for converting
What is the coefficient for the price normalized attribute in the best model ie model with the optimal lambda
How many attributes remain in the model if lambda is set to How that number changes if lambda is increased to Do you expect more variables to stay in the model ie to have nonzero coefficients as we increase lambda?
Build an elasticnet model with alpha set to What is the best value of lambda for such
a model?
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