Recompute resampling-based prediction error measures
Recompute prediction error measures for previously obtained objects that contain resampling-based prediction error results. This is useful for computing a different measure of prediction loss.
1 2 3 4 5 6 7
an object inheriting from class
a cost function measuring prediction loss.
It should expect the observed values of the response to
be passed as the first argument and the predicted values
as the second argument, and must return either a
non-negative scalar value, or a list with the first
component containing the prediction error and the second
component containing the standard error. The default is
to use the root mean squared prediction error (see
for the generic function, additional
arguments to be passed down to methods. For the methods,
additional arguments to be passed to the prediction loss
An object similar to
object containing the results
for the new measure of prediction loss.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
data("coleman") set.seed(1234) # set seed for reproducibility ## set up folds for cross-validation folds <- cvFolds(nrow(coleman), K = 5, R = 10) ## compare raw and reweighted LTS estimators for 50% and 75% ## subsets based on their RTMSPE with 25% trimming # 50% subsets fit50 <- ltsReg(Y ~ ., data = coleman, alpha = 0.5) cv50 <- perry(fit50, splits = folds, fit = "both", cost = rtmspe, trim = 0.25) # 75% subsets fit75 <- ltsReg(Y ~ ., data = coleman, alpha = 0.75) cv75 <- perry(fit75, splits = folds, fit = "both", cost = rtmspe, trim = 0.25) # combine results into one object cv <- perrySelect("0.5" = cv50, "0.75" = cv75) cv ## recompute the RTMSPE with 10% trimming reperry(cv50, cost = rtmspe, trim = 0.1) reperry(cv, cost = rtmspe, trim = 0.1)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.