R/mlearn.R
mlearn.wsvm.cv.RdThis function performs a nested cross-validation (on tuning parameters) of weighted SVMs for multicategory treatment comparisons and estimating individualized treatment rules.
mlearn.wsvm.cv( data, idx, trts, max_size, delta, dist_mat, g_func, kernel = "rbfdot", kpar = "automatic", nfolds_outer = 3, nfolds_inner = 3, tuneGrid, propensity, foldid_outer = NULL )
| data | a data frame containing the ID ( |
|---|---|
| idx | a data frame of two columns |
| 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 |
| delta | a scalar, as defined in |
| dist_mat | a precalculated matrix of distances between subjects.
This matrix must include all subjects in |
| 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 |
| kernel | the kernel function used in SVMs. Supported argument values
can be found in |
| kpar | the list of hyper-parameters (kernel parameters). Valid
parameters for supported kernels can be found in |
| nfolds_outer | the number of folds in the outer layer of the nested cross-validation. Default: 3. |
| nfolds_inner | the number of folds in the inner layer (for tuning parameters) of the nested cross-validation. Values greater than or equal to 3 usually yield better results. Default: 3. |
| tuneGrid | a data frame of tuning parameter(s). Each column for each parameter. Usually, the first column is the cost of constraints violation ("C"-constant) in SVMs. |
| propensity | a data frame with |
| foldit_outer | (optional) a user-specified vector recording the split
of folds in the outer layer of the nested cross-validation. This vector
should match the number of rows in |
A list with 3 sublists as follows:
fit: a list with nfolds_outer sublists. The jth sublist contains
the inner cross-validation result of the weighted SVM that used the jth
fold of subjects as the test fold.
foldid_outer: a vector recording the split of folds in the
outer layer of the nested cross-validation.
prediction: a matrix with 5 columns recording ID(ID),
outcome (reward), observed treatment (treatment), recommended
treatment (vote), and the fold in the cross-validation(fold)
information of subjects.