1

I have a matrix X and vector Y which I use as arguments into the rfe function from the caret package. It's as simple as:

I get a weird error which I can't decipher:

promise already under evaluation: recursive default argument reference or earlier problems?

EDIT: Here is a reproducible example for the first 5 rows of my data:

library(caret)

X_values = c(29.04,96.57,4.57,94.23,66.81,26.71,69.01,77.06,49.52,97.59,47.57,64.07,24.25,11.27,77.30,90.99,44.05,30.96,96.32,16.04)
X = matrix(X_values, nrow = 5, ncol=4)
Y = c(5608.11,2916.61,5093.05,3949.35,2482.52)

rfe(X, Y)

My R version is 3.2.3. Caret package is 6.0-76.

Does anybody know what this is?

David Heckmann
  • 2,899
  • 2
  • 20
  • 29
Aleksandar Jovanovic
  • 1,127
  • 1
  • 11
  • 14

1 Answers1

4

There are two problems with your code.

  1. You need to specify the function/algorithm that you want to fit. (this is what causes the error message you get. I am unsure why rfe throws such a cryptic error message; it makes it difficult to debug, indeed.)
  2. You need to name your columns in the input data.

The following works:

library(caret)

X_values = c(29.04,96.57,4.57,94.23,66.81,26.71,69.01,77.06,49.52,97.59,47.57,64.07,24.25,11.27,77.30,90.99,44.05,30.96,96.32,16.04)
X = matrix(X_values, nrow = 5, ncol=4)
Y = c(5608.11,2916.61,5093.05,3949.35,2482.52)

ctrl <- rfeControl(functions = lmFuncs)
colnames(X) <- letters[1:ncol(X)]

set.seed(123)
rfe(X, Y, rfeControl = ctrl)

I chose a linear model for the rfe. The reason for the warning messages is the low number of observations in your data during cross validation. You probably also want to set the sizes argument to get a meaningful feature elimination.

David Heckmann
  • 2,899
  • 2
  • 20
  • 29
  • I get the same error if I try to call `rfe(X, Y, ctrl)` rather than `rfe(X, Y, rfeControl=ctrl)` – Brian D Dec 15 '17 at 21:58