pbreheny / grpreg

Regularization paths for regression models with grouped covariates
http://pbreheny.github.io/grpreg/
34 stars 14 forks source link

BUG: pass lambda explicitly to cv.grpreg #1

Closed vincentarelbundock closed 9 years ago

vincentarelbundock commented 10 years ago

Bug occurence:

library(grpreg)
X = matrix(rnorm(10000), ncol=10)
y = rnorm(1000)
mod = grpreg(X,y,1:ncol(X),lambda=c(2,1))
mod_cv = cv.grpreg(X,y,1:ncol(X),lambda=c(2,1))
> Error in grpreg(X1, y1, g, lambda = fit$lambda, warn = FALSE, ...) : 
>  formal argument "lambda" matched by multiple actual arguments

Reason:

Line 46 of cv.grpreg:

fit.i <- grpreg(X1, y1, g, lambda=fit$lambda, warn=FALSE, ...)

Which passes lambda twice, once explicitly, and once more implicitly through ...

Solution: Just make lambda explicit in the cv.grpreg call.

pbreheny commented 9 years ago

I never saw this pull request -- sorry about that! Anyway, I agree that the user should be able to specify lambda in cv.grpreg, although the necessary fix is a little more complex than what you have, because mod_cv$lambda needs to match mod_cv$fit$lambda. Anyway, it's all fixed and on its way to CRAN now -- thanks for the suggestion, and my apologies again for the extreme delay in responding to you!

vincentarelbundock commented 9 years ago

thanks for the fix!