Search code examples
rr-caretglmnetstandardized

R caret glmnet standardize = FALSE


I'm trying to use the caret package to play with alpha levels for a glmnet model. The problem is that the data I'm using is all dummy variables and I don't want glmnet to standardize them. Usually if I was just using glmnet or cv.glmnet on its own, I'd just add

standardize = FALSE

Is there a setting in caret to turn off standardize?


Solution

  • In caret, you can feed original function arguments into caret::train thanks to the ellipsis ... mechanism.

    For example this code will fit a regularized regression on non standardized data

    require(caret)
    require(mlbench)
    data(BostonHousing)
    
    enet <-  train(medv ~ .,
                   data = BostonHousing, 
                   method = "glmnet",
                   standardize = FALSE)