0
$\begingroup$

Having read this question and this link, I already know that model.matrix can help convert data frame with factors into a design matrix.

My question is if you pass this model.matrix into glmnet or cv.glmnet function with the argument standardize set to TRUE, it still scales those dummy variable columns, am I correct ? So it means that glmnet still cannot differentiate the categorical variables from the continuous variables and handle them differently. So how can I make glmnet standardize the non-categorical columns but not the categorical columns ?

$\endgroup$
3
  • $\begingroup$ I think this is probably meant to be on SO... Anyway, the obvious thing would be to pass to glmnet a model matrix where only the variable you wish to be standardised are standardised and set the argument standardize to FALSE. $\endgroup$ – usεr11852 Jul 15 '17 at 12:08
  • $\begingroup$ Yes but we are suppose to standardise the validation set when we train the model during cross validation . By setting 'standardise' to 'FALSE' , does it mean we are skipping this step in the 'cv.glmnet' function ? This standardization thing really bugs me.l because it makes me feel like I am implementing something that is not entirely correct . $\endgroup$ – mynameisJEFF Jul 15 '17 at 13:00
  • $\begingroup$ I probably misinterpreter something...What would you train on a non-standardised set and then validate on a standardised one? You might use caret and define your own cross-validation procedure if you are bothered so you don't use cv.glmnet at all. $\endgroup$ – usεr11852 Jul 15 '17 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.