| cvSLOPE | R Documentation |
This function trains a model fit by SLOPE() by tuning its parameters
through cross-validation.
Cross-validation generates the alpha path or converts supplied relative
alphas on the full data for each grid point. It uses the absolute alpha
candidates in every fold and the selected absolute alpha in the final refit.
cvSLOPE(
x,
y,
q = 0.2,
gamma = 0,
n_folds = 10,
n_repeats = 1,
measure = c("mse", "mae", "deviance", "misclass", "auc"),
refit = TRUE,
...,
weights = NULL
)
x |
the design matrix, which can be either a dense matrix of the standard matrix class, or a sparse matrix inheriting from Matrix::sparseMatrix. Data frames will be converted to matrices internally. |
y |
the response, which for |
q |
a vector of quantiles for the |
gamma |
relaxation parameter for SLOPE. Default is |
n_folds |
number of folds (cross-validation) |
n_repeats |
number of folds (cross-validation) |
measure |
DEPRECATED |
refit |
logical; if |
... |
other arguments to pass on to |
weights |
observation weights as in |
An object of class "TrainedSLOPE", with the following slots:
summary |
a summary of the results with means, standard errors, and 0.95 confidence levels |
data |
the raw data from the model training |
optima |
a |
measure |
a |
model |
the model fit to the entire dataset using optimal parameters
(only present if |
training_data |
the training data used for tuning ( |
family |
the model family used for tuning |
call |
the call |
Other model-tuning:
plot.TrainedSLOPE(),
refit(),
summary.TrainedSLOPE(),
trainSLOPE()
# 8-fold cross-validation
tune <- cvSLOPE(
subset(mtcars, select = c("mpg", "drat", "wt")),
mtcars$hp,
q = c(0.1, 0.2),
n_folds = 8,
n_repeats = 2,
measure = "mse"
)
# Access the refitted model
tune$model
# Or use refit() to refit with different measure
fit <- refit(
tune,
subset(mtcars, select = c("mpg", "drat", "wt")),
mtcars$hp
)
coef(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.