View source: R/regmest_regression.R
| regmest_cv | R Documentation |
Perform (repeated) K-fold cross-validation for regmest().
adamest_cv() is a convenience wrapper to compute adaptive elastic-net M-estimates.
regmest_cv(
x,
y,
standardize = TRUE,
lambda,
cv_k,
cv_repl = 1,
cv_type = "naive",
cv_metric = c("tau_size", "mape", "rmspe", "auroc"),
fit_all = TRUE,
cl = NULL,
...
)
adamest_cv(x, y, alpha, alpha_preliminary = 0, exponent = 1, ...)
x |
|
y |
vector of response values of length |
standardize |
whether to standardize the |
lambda |
optional user-supplied sequence of penalization levels.
If given and not |
cv_k |
number of folds per cross-validation. |
cv_repl |
number of cross-validation replications. |
cv_type |
what kind of cross-validation should be performed:
robust information sharing ( |
cv_metric |
only for |
fit_all |
only for |
cl |
a parallel cluster. Can only be used in combination with
|
... |
Arguments passed on to
|
alpha |
elastic net penalty mixing parameter with |
alpha_preliminary |
|
exponent |
the exponent for computing the penalty loadings based on the preliminary estimate. |
The built-in CV metrics are
"tau_size"\tau-size of the prediction error, computed by
tau_size() (default).
"mape"Median absolute prediction error.
"rmspe"Root mean squared prediction error.
"auroc"Area under the receiver operator characteristic curve (actually 1 - AUROC). Only sensible for binary responses.
adamest_cv() is a convenience wrapper which performs 3 steps:
compute preliminary estimates via regmest_cv(..., alpha = alpha_preliminary),
computes the penalty loadings from the estimate beta with best prediction performance by
adamest_loadings = 1 / abs(beta)^exponent, and
compute the adaptive PENSE estimates via
regmest_cv(..., penalty_loadings = adamest_loadings).
a list-like object as returned by regmest(), plus the following components:
cvresdata frame of average cross-validated performance.
a list-like object as returned by adamest_cv() plus the following components:
exponentvalue of the exponent.
preliminaryCV results for the preliminary estimate.
penalty_loadingspenalty loadings used for the adaptive elastic net M-estimate.
regmest() for computing regularized S-estimates without cross-validation.
coef.pense_cvfit() for extracting coefficient estimates.
plot.pense_cvfit() for plotting the CV performance or the regularization path.
Other functions to compute robust estimates with CV:
change_cv_measure(),
pense_cv()
Other functions to compute robust estimates with CV:
change_cv_measure(),
pense_cv()
# Compute the PENSE regularization path for Freeny's revenue data
# (see ?freeny)
data(freeny)
x <- as.matrix(freeny[ , 2:5])
regpath <- regmest(x, freeny$y, alpha = c(0.5, 0.85), scale = 2)
plot(regpath)
# Extract the coefficients at a certain penalization level
coef(regpath, alpha = 0.85, lambda = regpath$lambda[[2]][[40]])
# What penalization level leads to good prediction performance?
set.seed(123)
cv_results <- regmest_cv(x, freeny$y, alpha = c(0.5, 0.85), scale = 2,
cv_repl = 2, cv_k = 4)
plot(cv_results, se_mult = 1)
# Print a summary of the fit and the cross-validation results.
summary(cv_results)
# Extract the coefficients at the penalization level with
# smallest prediction error ...
coef(cv_results)
# ... or at the penalization level with prediction error
# statistically indistinguishable from the minimum.
coef(cv_results, lambda = '1-se')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.