I'm trying to understand how I can get my data into a format that allows me to do svm
regression. I have a time series that looks like
data
[1] 1.20962 1.21036 1.21006 1.20873 1.20658 1.20676 1.20576 1.20555 1.20526 1.20504 1.20516
[12] 1.20581 1.20456 1.20558 1.20496 1.20547 1.20382 1.20312 1.20259 1.20306 1.20137 1.20089
I do a rev
and then diff
on it
data <- rev(data)
data <- diff(data)
data
[1] -0.00040 0.00092 -0.00095 -0.00045 0.00013 0.00247 0.00055 -0.00058 0.00106 0.00188
[11] 0.00110 -0.00002 0.00069 0.00019 -0.00058 0.00080 -0.00021 -0.00079 -0.00007 0.00123
But it's not in the right format to use with svm
library(e1071)
svm.model <- svm(data=data, type="nu-regression", kernel="radial" )
Error in inherits(x, "Matrix") : argument "x" is missing, with no default
I'm not sure how to manipulate it into a data.frame or another way that it's looking for.
EDIT: I was looking for something like this
data <- matrix(unlist(data), ncol = 2, byrow = TRUE)
svm.model <- svm(x=data[,1],y=data[,2],data=data, type="nu-regression", kernel="radial" )
svm
command needs to know what the dependent and independent variables are, and it looks like you only have one variable. See, e.g., rischanlab.github.io/SVM.html that showssvm
onSpecies ~ .
. - mysteRious