How can I force cv.glmnet not to drop one specific variable?
问题 I am running a regression with 67 observasions and 32 variables. I am doing variable selection using cv.glmnet function from the glmnet package. There is one variable I want to force into the model. (It is dropped during normal procedure.) How can I specify this condition in cv.glmnet? Thank you! My code looks like the following: glmntfit <- cv.glmnet(mydata[,-1], mydata[,1]) coef(glmntfit, s=glmntfit$lambda.1se) And the variable I want is mydata[,2]. 回答1: This can be achieved by providing a