This might be a weird question and I understand that LASSO is mainly using as a variable selection method.
But I want to know that is it possible to check non-linear effects of a LASSO logistic regression model .
In GLM setting , we usually do this by fitting two uni variate models. First model with linear effects and the second model with non linear effects . Then chi square test can be used to check whether the non linear effects are significant.
I tried to do the same thing using glmnet package as follows,
My multiple Lasso logistic regression model :
y <- Smarket$Direction
x <- model.matrix(Direction ~ Lag1 + Lag2 + Lag3 + Lag4 + Volume, Smarket)[, -1]
lasso.mod <- glmnet(x,y, alpha = 1, lambda = 0.002,family='binomial')
lasso.mod$beta
5 x 1 sparse Matrix of class "dgCMatrix"
s0
Lag1 -0.065571799
Lag2 -0.035641706
Lag3 0.003564320
Lag4 0.001534812
Volume 0.110035335
Then i tried to check non linear effects for each predictor , by first fitting a uni variate LASSO regression model
y <- Smarket$Direction
x1<- model.matrix(Direction ~ Lag1 , Smarket)
lasso.mod1 <- glmnet(x1,y, alpha = 1, lambda = 0.002,family='binomial')
lasso.mod1$beta
2 x 1 sparse Matrix of class "dgCMatrix"
s0
(Intercept) .
Lag1 -0.06312753
After this , is there way to fit univariate lasso model with non linear effects ? Also after fitting that what test can we used to check the non linear effects (can we use chi square test ?) ?
Thank you