My problem is solved as follows: the kernel codes are correct, I should directly define a function(x,y), and declare its class as "kernel". The problem is even in the doc the ksvm does support x,y styles, they actually do not work. Changing it to formula-data style can finally get things running:
fit <- ksvm(Freq~lat+lon,data=train[,2:4],kernel=roundrbf,type='eps-svr')
Moreover, I also read the source code of rbfdot, and other kernels defined in the kernlab itself. Notice their codes style is like this:
function(params){
val <- function(x,y){
# True kernel defined here
}
return (new ("kernel_name",.Data=val,kpar=list(params)))
}
But seriously, I tried, and making the kernel functions in this style won't work. The working way is like this style directly:
k <- function(x,y){
#calculate the result
}
class(k) <- "kernel"