3
$\begingroup$

Is it possible to do a lasso model with both penalized and un-penalized covariates? That is, I want to do an estimate with Y ~ gamma * X + beta * Z, where X is a n*p penalized features and Z a n*q un-penalized covariates of continues or factor variables.

$\endgroup$

1 Answer 1

9
$\begingroup$

One way to learn about the functionality of an R package is to look at its documentation.

The command ?glmnet takes us to the help page for the function. Here, we are presented with a number of options pertaining to the function, and an exhaustive list of the additional arguments one may pass to it.

Of particular interest is this entry:

penalty.factor
Separate penalty factors can be applied to each coefficient. This is a number that multiplies lambda to allow differential shrinkage. Can be 0 for some variables, which implies no shrinkage, and that variable is always included in the model. Default is 1 for all variables (and implicitly infinity for variables listed in exclude). Note: the penalty factors are internally rescaled to sum to nvars, and the lambda sequence will reflect this change.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.