0

I'm using caret package to tune alpha and lambda parameters for glmnet model. My features are in X (dataframe, 47 obs. of 14474 variables, a p>>N problem) and the dependent variable, y is a dataframe of 47 obs. of 1 variable.

When I try

   trC = trainControl(method=cv, number=10)  
   fitModel = train(X, y, trControl=trC, method="glmnet")  

I get

 Error en switch(tolower(trControl$method), oob = NULL, alt_cv = , cv = createFolds(y,:   
   EXPR must be a length 1 vector
 Además: Mensajes de aviso perdidos
 In if (trControl$method == "oob" & !(method %in% c("rf", "treebag",  :
 la condición tiene longitud > 1 y sólo el primer elemento será usado

I've tried transposing y, and also changing to class(y) = "numeric", instead of "data.frame" but I get the same error, that I don't understand. Any clue?

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
PGreen
  • 3,239
  • 3
  • 24
  • 29
  • I would have guessed that it should be trainControl(method='cv', number=10), unless of course there is a `cv`-named object in your workspace that you have not told us about. – IRTFM Sep 18 '13 at 16:30
  • If I am correct then this question ought to be deleted since it is just "user error" of the simplest kind. No lesson here other than "need to quote arguments that are supposed to be quoted". – IRTFM Sep 18 '13 at 16:36
  • @DWin yes you're right. I was following someone else's example and it was written like this. Now that I see the help, I see that `method` uses "". Thanks @topepo too. If you consider better to be deleted, go on. – PGreen Sep 19 '13 at 08:09

1 Answers1

0

Use method = "cv" not method = cv.

Max

topepo
  • 13,534
  • 3
  • 39
  • 52