Answered step by step
Verified Expert Solution
Link Copied!

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.
Carseats_Filtered <- Carseats %>% select("Sales", "Price",
"Advertising","Population","Age","Income","Education")
1) 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? (Hint1: Do not forget to scale your input attributes you can use the caret preprocess() function to scale and center the data. Hint 2: glment library expect the input attributes to be in the matrix format. You can use the as.matrix() function for converting
2) What is the coefficient for the price (normalized) attribute in the best model (i.e. model with the optimal lambda)?
3) How many attributes remain in the model if lambda is set to 0.01? How that number changes if lambda is increased to 0.1? Do you expect more variables to stay in the model (i.e., to have non-zero coefficients) as we increase lambda?
4) Build an elastic-net model with alpha set to 0.6. What is the best value of lambda for such
a model?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago