I am trying to optimize SVM paramters for a regression problem using PSO in R. I am getting this weird error. Any suggestion on how to fix this error would be greatly appreciated.

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

I am using e1071 and psoptim packages in R to optimize gamma, cost and epsilon parameters. I am not sure what p<0! indicate

data<- pca.train
train<-data.matrix(pca.train, rownames.force = NA)

rmse <- function(error)

f <- function(V1, V2,V3,x,y)
  V1 <-  log10(B1)
  V2 <-  log10(B2)
  V3 <-  log10(B3)

  svm.model <- svm(x=train, y=data$y1,scale=F, type= "eps-regression",kernel="radial",cost = V1,epsilon= V2,gamma= V3)
  error<- pca.train$y1- svm.model$fitted
  return (rmse(error))

B3<-  seq(1, 2,0.1)
B1<-  2^(2:9)
B2 <- seq(0.1,1, 0.1)

n <- 50
m.l <- 50
w <- 0.95
c1 <- 0.2
c2 <- 0.2
xmin <- c(-5.12, -5.12)
xmax <- c(5.12, 5.12)
vmax <- c(4, 4)

optimum <-psoptim(f, n=n, max.loop=m.l, w=w, c1=c1, c2=c2,xmin=xmin, xmax=xmax, vmax=vmax, seed=5, anim=FALSE)
OPTIMIM.VALUE<- f(optimum)

Also any suggestion on how to get the optimized values of gamma, cost and epsilon parameters after optimization would be greatly helpful


closed as off-topic by jbowman, Michael Chernick, whuber Apr 23 at 2:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – jbowman, Michael Chernick, whuber
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ p in svm refers to epsilon. I had negative values in v2 which resulted in such error. I was able to fix the error when I changed v2 values. Hope this will help someone in future. $\endgroup$ – Madhumitha Apr 22 at 18:46

Browse other questions tagged or ask your own question.