The first parameter to the glmnet() function must be a matrix of features (which we can create using the R function, model.matrix()). The second parameter is a vector with the output variable. Finally, the alpha parameter is a switch between ridge regression (0) and lasso (1). The following code sets up for our example:
# --- load the package library(glmnet) # --- create our parameter data cars_train_mat <- model.matrix(Price ~ .-Saturn, cars_train)[,-1] lambdas <- 10 ^ seq(8, -4, length = 250)
# --- create regression model cars_models_ridge <- glmnet(cars_train_mat, ...