R/mlearn.R
mlearn.wsvm.tune.RdThis function performs a cross-validation (on tuning parameters) of weighted SVMs for multicategory treatment comparisons.
mlearn.wsvm.tune( data, idx, trts, max_size, delta, dist_mat, g_func, kernel = "rbfdot", kpar = "automatic", nfolds_inner = 3, tuneGrid, propensity )
| 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_inner | the number of folds in the 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 |
A list with 7 sublists as follows:
best_fit: the final weighted SVM using the best tuning parameter(s).
params: the list of tuning parameter(s) used to train the model.
Same as tuneGrid.
best_param: the best tuning parameter(s).
best_idx: the index of the best tuning parameter(s) in tuneGrid/params.
cv_mat: the matrix of the metric values for the cross-validation.
cv_est: the cross-validation estimators (row means of cv_mat).
foldid_inner: a vector recording the split of folds.