[R] lasso and ridge regression
Gafar Matanmi Oyeyemi
gmoyeyemi at gmail.com
Tue Oct 31 07:02:40 CET 2017
Dear All
The problem is about regularization methods in multiple regression when the
independent variables are collinear. A modified regularization method with
two tuning parameters l1 and l2 and their product l1*l2 (Lambda 1 and
Lambda 2) such that l1 takes care of ridge property and l2 takes care of
LASSO property is proposed
The proposed method is given
<https://i.stack.imgur.com/Ta8FR.jpg>
The problem is how to adapt "glmnet" to accomplish our task.
The extract of the code used is reproduced as follows;
cv.ridge<- glmnet(x, y, family="gaussian", alpha=0,
lambda=lambda1, standardize=TRUE)
cv.lasso<- glmnet(x, y, family="gaussian", alpha=1,
lambda=lambda2, standardize=TRUE)
##weight
a=1/abs(matrix(coef(cv.ridge, s=lambda1)[, 1][2:(ncol(x)+1)]
))^1
b=1/abs(matrix(coef(cv.lasso, s=lambda2)[, 1][2:(ncol(x)+1)]
))^1
c=a*b
w4 <-a+b+c
w4[w4[,1] == Inf] <- 9
# Fit modified procedure
fit<- glmnet(x, y, family="gaussian",
alpha=alpha,lambda=lambda1+lambda2, penalty.factor=w4)
The question is; Does the code address the modified procedure in as shown
in the equation? If not, suggestions are please welcome.
Thanks
--
OYEYEMI, Gafar Matanmi (Ph.D)
Reader
Department of Statistics
University of Ilorin.
Area of Specialization: Multivariate Analysis, Statistical Quality Control
& Total Quality Management.
Tel: +2348052278655, +2348068241885
[[alternative HTML version deleted]]
More information about the R-help
mailing list