[R] cv.glmnet errors

Peter Ehlers ehlers at ucalgary.ca
Sat Feb 19 02:09:44 CET 2011


On 2011-02-17 13:45, Brian Tsai wrote:
> Hi,
>
> I am trying to do multinomial regression using the glmnet package, but the
> following gives me an error (for no reason apparent to me):
>
> library(glmnet)
> cv.glmnet(x=matrix(c(1,2,3,4,5,6,1,2,3,4,5,6),
> nrow=6),y=as.factor(c(1,2,1,2,3,3)),family='multinomial',alpha=0.5,
> nfolds=2)
>
> The error i get is:
> Error in if (outlist$msg != "Unknown error") return(outlist) :
>    argument is of length zero
>
>
> If i change the number of folds to 1, i get a seg fault:
>   *** caught segfault ***
> address 0x0, cause 'memory not mapped'
>
> Traceback:
>   1: .Fortran("lognet", parm = alpha, nobs, nvars, nc, as.double(x),     y,
> offset, jd, vp, ne, nx, nlam, flmin, ulam, thresh, isd,     maxit, kopt, lmu
> = integer(1), a0 = double(nlam * nc), ca = double(nx *         nlam * nc),
> ia = integer(nx), nin = integer(nlam), nulldev = double(1),     dev =
> double(nlam), alm = double(nlam), nlp = integer(1),     jerr = integer(1),
> PACKAGE = "glmnet")
>   2: lognet(x, is.sparse, ix, jx, y, weights, offset, type, alpha,     nobs,
> nvars, jd, vp, ne, nx, nlam, flmin, ulam, thresh, isd,     vnames, maxit,
> HessianExact, family)
>   3: glmnet(x[!which, ], y_sub, lambda = lambda, offset = offset_sub,
> weights = weights[!which], ...)
>   4: cv.glmnet(x = matrix(c(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), nrow =
> 6),     y = as.factor(c(1, 2, 1, 2, 3, 3)), family = "multinomial",
> alpha = 0.5, nfolds = 1)
>
> Possible actions:

Update glmnet? What version are you using?

With glmnet 1.5.2, I just get a message reminding me that
   "nfolds must be bigger than 3; nfolds=10 recommended".

Peter Ehlers

>
>
>
> any ideas?
>
>
> Brian.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list