Home / Expert Answers / Computer Science / please-solve-using-r-studio-we-will-use-the-carseats-dataset-that-is-part-of-the-islr-package-we-m-pa559

(Solved): Please solve using R studio We will use the Carseats dataset that is part of the ISLR package. We m ...



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?



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe