Learn R Programming

perry (version 0.1.1)

reperry: Recompute resampling-based prediction error measures

Description

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.

Usage

reperry(object, ...)

## S3 method for class 'perry': reperry(object, cost = rmspe, ...)

## S3 method for class 'perrySelect': reperry(object, cost = rmspe, ...)

Arguments

object
an object inheriting from class "perry" or "perrySelect" that contains prediction error results.
cost
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
...
for the generic function, additional arguments to be passed down to methods. For the methods, additional arguments to be passed to the prediction loss function cost.

Value

  • An object similar to object containing the results for the new measure of prediction loss.

See Also

perryFit, perryTuning, perrySelect

Examples

Run this code
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 <- repCV(fit50, folds = folds, fit = "both", 
    cost = rtmspe, trim = 0.25)

# 75\% subsets
fit75 <- ltsReg(Y ~ ., data = coleman, alpha = 0.75)
cv75 <- repCV(fit75, folds = 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)

Run the code above in your browser using DataLab