This function fits a set of weighted kernel SVMs for binary treatment comparisons.

mlearn.wsvm(
  train_data,
  test_data,
  idx,
  trts,
  max_size,
  delta,
  dist_mat,
  g_func,
  kernel = "rbfdot",
  kpar = "automatic",
  C
)

Arguments

train_data

a data frame for subjects in training fold(s), containing the ID (ID), outcome (reward), outcome residual (reward_res), observed treatment (treatment), and health feature information.

test_data

a data frame for subjects in test fold(s), containing the ID (ID), outcome (reward), outcome residual (reward_res), observed treatment (treatment), and health feature information.

idx

a data frame of two columns ID and index. ID records the IDs of subjects in train_data. index records the column indices of these subjects in dist_mat.

trts

a vector of treatment names.

max_size

an integer indicating the upper limit of the sizes of all matched sets. The default setting is max_size=1 which means finding the nearest neighbors of subjects.

delta

a scalar, as defined in equation (6) in Section 2.2 of the manuscript, indicating the upper limit of distances between a subject and the subjects in its matched set.
In future versions, we will extend this argument to a vector which means the upper limit can vary with subjects.

dist_mat

a precalculated matrix of distances between subjects. This matrix must include all subjects in train_data.

g_func

a function that transforms the differences between outcomes of a set of subjects and the subjects in their matched sets to the weights in SVMs. In equation (7) in Section 2.2 of the manuscript, g(.) = |.| and the weights are |Rj-Ri|.

kernel

the kernel function used in SVMs. Supported argument values can be found in ksvm and dots. Default: "rbfdot".

kpar

the list of hyper-parameters (kernel parameters). Valid parameters for supported kernels can be found in ksvm and dots. Default: "automatic".

C

a scalar that is the cost of constraints violation in SVMs. This is the "C"-constant of the regularization term in the Lagrange formulation.

Value

A list with 2 sublists as follows:

  • model: a list with K(K-1)/2 sublists. Each sublist is a weighted SVM (trained on train_data) for the corresponding binary treatment comparison.

  • prediction: a matrix with K(K-1)/2 columns. Each column is the recommendations between the corresponding treatment pair for subjects in test_data.

See also

ksvm and dots for kernel. weighted.ksvm for fitting weighted SVMs.