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)
{
  sqrt(mean(error^2))
}

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

0 Answers