r.user.05apr
r.user.05apr

Reputation: 5456

Extract glmnet's lambda matrix

I would like to extract the lambda-matrix of a ridge regression. I can plot it, but I cannot extract the values. The wanted matrix should include the lambdas (in rows) and the variables including names (in cols).

library(glmnet)

x1<-rnorm(200,5,4)
x2<-rnorm(200,45,3)
x3<-rnorm(200,-10,4)
y<-80+x2*3+rnorm(200,0,1)
X<-cbind(x1,x2,x3)

l.vec<-10^seq(10,-2,length=100)

my.ridge<-glmnet(x=X,y=y,alpha=0,
                 lambda=l.vec,
                 standardize=TRUE)

plot(my.ridge,xvar="lambda")

How can I re-direct the plot-information into a matrix?

Thx&kind regards

Upvotes: 0

Views: 155

Answers (1)

Hong Ooi
Hong Ooi

Reputation: 57697

Do you mean the coefficient matrix?

coef(my.ridge)

Upvotes: 1

Related Questions