Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the code below to select the first 40 predictors in the meatspec dataset. Use the glmnet package to perform Ridge and LASSO analyses on

Use the code below to select the first 40 predictors in the meatspec dataset. Use the glmnet package to perform Ridge and LASSO analyses on the 40 predictors. You do not need to build training and test data sets for this exercise.Use 10-fold Cross Validation to pick the optimal lambdas.

Submit your program, output, and any graphs that are generated, and a short paragraph summarizing your results.

library(faraway)

library(glmnet)

data(meatspec,package="faraway")#the dataset meatspec is found in the faraway package

# Getting the dependent variable

y_var <- meatspec$fat

y_var

# Getting the independent variables

x_var <- as.matrix(meatspec[,(1:40)]) #includes the 40 variables V1 - V40

head(x_var,1L)

#continue with program to perform Ridge and LASSO.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Differential Equations With Boundary-Value Problems

Authors: Dennis G Zill, Brad Strong, Michael Cullen

7th Edition

1111798524, 9781111798529

More Books

Students also viewed these Mathematics questions

Question

13. Give four examples of psychological Maginot lines.

Answered: 1 week ago