Categorical predictors with matrix.model for cv.glmnet

Hi,

I'm new to R, and I'm currently trying to run a multinomial LASSO regression. All my predictors are categorical, so I tried to use matrix.model to create the matrix of predictors and I expected the command to automatically split the regressors into dummies. However, the predictors in the matrix still remain categorical. Here is the simple code:

#Create x matrix and y vector
x <- model.matrix(Y~., Lasso) [, -1]
y <- Lasso$Y

Am I missing something? Do you know what the problem might be? Thanks!

Try using tidymodels for this. Here is a worked example for you. We take care of the data processing steps for you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.