I have dataset:
SalesPrice SqFeet Beds Baths AirCond Garage Pool Year Quality Style Lot Highway
1: 360.0 3.032 4 4 1 2 0 1972 2 1 22.221 0
2: 340.0 2.058 4 2 1 2 0 1976 2 1 22.912 0
3: 250.0 1.780 4 3 1 2 0 1980 2 1 21.345 0
4: 205.5 1.638 4 2 1 2 0 1963 2 1 17.342 0
5: 275.5 2.196 4 3 1 2 0 1968 2 7 21.786 0
I want to create a model:
model.lm2 <- glmnet(x = xvars,y = df[,SalesPrice],alpha = 1,family = 'gaussian',lambda = CV$lambda.1se)
But in my case I have factor variable "Style" and if I won't change it to dummy variable glmnet function will work with it as with numerical variable.
So how can I create create dummy variables for glmnet(LASSO) by model.matrix?