R/model_continuous_svm_linear.R

Defines functions model_continuous_svm_linear

Documented in model_continuous_svm_linear

#' @title model_continuous_svm_linear
#' @description model continuous linear support vector machine
#' @concept model_continuous
#' @param data clean data.frame of predictors and outcome to be analyzed
#' @param y continuous outcome name within the data.frame
#'
#' @return linear svm model
#' @export
#' @import e1071 dplyr
#' @examples
#' # to be added
model_continuous_svm_linear <- function(data, y) {
 x <- data %>% select(-y) %>% as.matrix()
 y <- data %>% select(y) %>% as.matrix()

 model <- svm(x = x, y = y, kernel = "linear", type = "eps-regression")
 model$w <- t(model$coefs) %*% model$SV
 return(model)
}
epongpipat/eepR documentation built on June 5, 2024, 10:03 a.m.