1
$\begingroup$

People often ask if it is appropriate when interaction effect is included when the corresponding main effect is not. When I do LASSO in R or Python, can I force one variable should be included if some other specific variable is included?

I'd like to know how to do this in the computer or theoretically. (So if it is not implemented in the existing package, I could write a code for it)

$\endgroup$
0

1 Answer 1

0
$\begingroup$

You can use the "group lasso", which forces groups of variables to be taken as a whole into the regression. There's two good packages for the group lasso in R, grplasso and gglasso.

(That is, you assign one group to your specific main effect variable and its interaction term, and all of the other variables are in their own groups of size 1.)

$\endgroup$
1
  • $\begingroup$ I appreciate your valuable advice, but it does not seem to solve my problem. In the 'group lasso' you mentioned, a group of variables must be included together or excluded together. In my problem, however, there is priority. For example, main effects have the highest priority and interaction terms and quadratic terms are the second. If X2^2 should be included, then X2 must be included. But including X2 and excluding X2^2 is okay. This is the difference from the group lasso you mentioned. $\endgroup$
    – user67275
    Nov 13, 2019 at 1:37

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.