0
$\begingroup$

I'm struggling to get the same results from a lasso regression when using glmnet as when using l1ce from the lasso2 package. I've set a specific tuning parameter value for both, and tried to set all other inputs the same. Here is my code for l1ce:

data(Prostate)
l1ce.lasso <- l1ce(lpsa ~ ., 
                   data = Prostate,
                   bound = 0.44,
                   sweep = NULL,
                   standardize = FALSE,
                   absolute.t = FALSE)

And output:

l1ce.lasso Call: l1ce(formula = lpsa ~ ., data = Prostate, sweep.out = NULL, standardize = FALSE, bound = 0.44, absolute.t = FALSE)

Coefficients: (Intercept) lcavol lweight age lbph svi 0.000000000 0.559056488 0.393462929 0.000000000 0.042394403 0.198590534 lcp gleason pgg45 0.000000000 0.015171790 0.005224389

The relative L1 bound was : 0.44 The absolute L1 bound was : 1.213901 The Lagrangian for the bound is: 5.340326


And here is my code for glmnet:

 x.p <- as.matrix(Prostate[,1:8])
y.p <- as.matrix(Prostate[,9])

glmnet.lasso <- glmnet(x.p, y.p, family="gaussian", lambda=0.44, standardize=FALSE, intercept=TRUE)

glmnet.lasso$beta 8 x 1 sparse Matrix of class "dgCMatrix" s0 lcavol 0.27800206 lweight .
age .
lbph .
svi .
lcp .
gleason .
pgg45 0.01168761


I've tested out different lambda values, but cannot find a value that provides the same results. Is this due to different optimization methods, or something else?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.