p < 0 when using SVM for regression with R I am working on a regression problem, trying to predict the age of subjects from a set of biomarkers. I've employed various methods of both feature selection/dimensional reduction (RFE, PCA, PCA/ICA and Relief) and regression (RF, SVM, CART) plus Elastic net for both.
I'm repeating for ten times a 10-fold cross validation to check the performance of each model. On each fold I perform feature selection, hyperparameters tuning and then prediction.
In the eighth fold of RFE I get this error: 

Error in svm.default(x, y, scale = scale, ..., na.action = na.action)
  :    p < 0!

I found this question, and I tried to eliminate any 0 from both my gridsearches (epsilon and cost), but the error persists and I don't know how to fix it.
Here's the code:
#function to calculate RMSE
RMSE <- function(y1, y2) { sqrt(mean((y1 - y2)^2)) }

#function to calculate MAE
MAE <- function(y1, y2) { mean(abs(y1 - y2)) }

curr_path=getwd()
filepath <- file.path(curr_path, 'datafile.xlsx')

data <- read.xlsx(filepath, 1)

df_numeric <- df[-2][, sapply(df[-2], is.numeric)]

nfolds = 10

#CV vif cor + SVM

rmse_vifcorsvm <- c()
mae_vifcorsvm <- c()

epsilon_range <- seq(0.1,1,0.1)
cost_range <- 2^(seq(0.5,8,.5))


for (k in 1:10) { 
  yourData <- df_numeric[sample(nrow(df_numeric)),]

  #Create 10 equally size folds
  folds <- cut(seq(1,nrow(yourData)),breaks=nfolds,labels=FALSE)

  #Perform 10 fold cross validation
  for(i in 1:10){
    #Segment your data by fold using the which() function 
    testIndexes <- which(folds==i,arr.ind=TRUE)

    #x
    testData <- yourData[testIndexes, ]
    trainData <- yourData[-testIndexes, ]

    #y
    test.y <- df[testIndexes, 2]
    train.y <- df[-testIndexes, 2]

    # feature selection
    res_vif <- usdm::vif(trainData)  # calculates vif for the variables in r
    v1 <- usdm::vifcor(trainData, th=0.9) # identify collinear variables that should be excluded
    print(v1)

    names.use1 <- names(df)[names(df) %in% v1@results[,1]]
    v1_train <- data.frame(train.y, trainData[, names.use1])
    b <- paste0(names.use1, collapse = " + ")

    # hyperparameters tuning
    tune_svmagev1 <- e1071::tune(svm, as.formula(paste("train.y ~ ", b)), data = v1_train, ranges = list(epsilon = epsilon_range, cost = cost_range))
    tuneResult_svmagev1 <- e1071::tune(svm, as.formula(paste("train.y ~ ", b)),  data = v1_train, 
                                       ranges = list(epsilon = seq(tune_svmagev1$best.model$epsilon-.15, tune_svmagev1$best.model$epsilon+.15, 0.01), 
                                                     cost = seq(2^(log2(tune_svmagev1$best.model$cost)-1), 2^(log2(tune_svmagev1$best.model$cost)+1), length=6)))

    # fit models
    tunedVals_svmagev1 <- tuneResult_svmagev1$best.model

    # prediction
    predicted.y_svmagev1 <- predict(tunedVals_svmagev1, as.matrix(testData))

    print(predicted.y_cartagev1)

    rmse_vifcorsvm <- c(rmse_vifcorsvm, RMSE(test.y, predicted.y_svmagev1))
    mae_vifcorsvm <- c(mae_vifcorsvm, MAE(test.y, predicted.y_svmagev1))

  }
}

 A: It is still difficult to follow exactly what happens without the datafile.xlsx, but I could track down the error (it is in the C-code of the e1071 library) the parameter 'p' in the C-code refers to the parameter 'epsilon' in the R-code. 
So in tuning your parameters your second pass contains ranges = list(epsilon = seq(tune_svmagev1$best.model$epsilon-.15, tune_svmagev1$best.model$epsilon+.15, 0.01) which may result in a negative value for epsilon. Maybe you could better do something like a multiplication rather than subtraction and addition. E.g  ranges = list(epsilon = seq(tune_svmagev1$best.model$epsilon*0.5, tune_svmagev1$best.model$epsilon*1.5, length.out = 31)
Note that when solving vague errors in R, and google/stackexchange do not give the answer, you can try and look it up in the source-code. For the code see "https://github.com/cran/e1071/" The relevant lines are
R/svm.R
if (cret$error != empty_string)
stop(paste(cret$error, "!", sep="")) 

src/Rsvm.c
par.p = *epsilon;
...
s = svm_check_parameter(&prob, &par);

src/svm.cpp
if(svm_type == EPSILON_SVR)
if(param->p < 0)
return "p < 0";

