C W
2013-May-25 20:14 UTC
[R] What does this say? Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument
Dear list, I am using glmnet. I have no idea what this error is telling me. Here's my code,> bob <- matrix(rnorm(100*180), nrow=180) > yyy <- rnorm(180) > fit1 <- cv.glmnet(bob, yyy, family="mgaussian")Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument In fact, I peeked inside cv.glmnet() using,> glmnet:cv.glmnetCan't even find the error message in the code. I am clueless at the moment. Thanks in advance, Mike
Thomas Stewart
2013-May-26 01:09 UTC
[R] What does this say? Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument
Mike- You can use the traceback function to see where the error is:> bob <- matrix(rnorm(100*180), nrow=180) > yyy <- rnorm(180) > fit1 <- cv.glmnet(bob, yyy, family="mgaussian")Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument> traceback()6: predict.multnet(object, newx, s, type, exact, offset, ...) 5: predict.mrelnet(glmnet.object, type = "nonzero") 4: predict(glmnet.object, type = "nonzero") 3: lapply(X = X, FUN = FUN, ...) 2: sapply(predict(glmnet.object, type = "nonzero"), length) 1: cv.glmnet(bob, yyy, family = "mgaussian") So, thee error is in the predict.multnet function. If you peak at that function, you see where the function falls apart. It seems that the function wants a0 to be a matrix but in this example it is a vector. I'm not familiar enough with the package to offer advice on how to fix this. -tgs On Sat, May 25, 2013 at 4:14 PM, C W <tmrsg11@gmail.com> wrote:> Dear list, > I am using glmnet. I have no idea what this error is telling me. > Here's my code, > > > bob <- matrix(rnorm(100*180), nrow=180) > > yyy <- rnorm(180) > > fit1 <- cv.glmnet(bob, yyy, family="mgaussian") > Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument > > In fact, I peeked inside cv.glmnet() using, > > glmnet:cv.glmnet > > Can't even find the error message in the code. I am clueless at the > moment. > Thanks in advance, > Mike > > ______________________________________________ > R-help@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. > > >[[alternative HTML version deleted]]