Learn R Programming

perry (version 0.1.1)

perryPlot: Plot resampling-based prediction error results

Description

Plot results of resampling-based prediction error measures.

Usage

perryPlot(x, ...)

## S3 method for class 'perry': perryPlot(x, method = c("box", "density", "dot"), select = NULL, seFactor = NA, ...)

## S3 method for class 'perrySelect': perryPlot(x, method = c("box", "density", "dot", "line"), subset = NULL, select = NULL, seFactor = x$seFactor, ...)

## S3 method for class 'default': perryPlot(x, method = c("box", "density", "dot", "line"), mapping, facets = attr(x, "facets"), ...)

## S3 method for class 'perry': autoplot(object, ...)

## S3 method for class 'perrySelect': autoplot(object, ...)

## S3 method for class 'perry': plot(x, ...)

## S3 method for class 'perrySelect': plot(x, ...)

Arguments

x
an object inheriting from class "perry" or "perrySelect" that contains prediction error results, or a data frame containing all necessary information for plotting (as generated by the corresponding
object
an object inheriting from class "perry" or "perrySelect".
method
a character string specifying the type of plot. Possible values are "box" to create a box plot, "density" to create a smooth density plot, "dot" to create a dot plot, or "line" to plot the (aver
subset
a character, integer or logical vector indicating the subset of models for which to plot the prediction error results.
select
a character, integer or logical vector indicating the columns of prediction error results to be plotted.
seFactor
a numeric value giving the multiplication factor of the standard error for displaying error bars in dot plots or line plots. Error bars in those plots can be suppressed by setting this to NA.
mapping
an aesthetic mapping to override the default behavior (see aes or aes_string)
facets
a faceting formula to override the default behavior. If supplied, facet_wrap or facet_grid is called depending on whether the form
...
for the generic function perryPlot, additional arguments to be passed down to methods. For the "perry" and "perrySelect" methods of perryPlot, additional arguments to be passed down to the defau

Value

  • An object of class "ggplot" (see ggplot).

Details

For objects with multiple columns of prediction error results, conditional plots are produced.

See Also

perryFit, perrySelect, perryTuning, ggplot, autoplot, plot

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 LS, MM and LTS regression

# perform cross-validation for an LS regression model
fitLm <- lm(Y ~ ., data = coleman)
cvLm <- repCV(fitLm, folds = folds, 
    cost = rtmspe, trim = 0.1)

# perform cross-validation for an MM regression model
fitLmrob <- lmrob(Y ~ ., data = coleman, k.max = 500)
cvLmrob <- repCV(fitLmrob, folds = folds, 
    cost = rtmspe, trim = 0.1)

# perform cross-validation for an LTS regression model
fitLts <- ltsReg(Y ~ ., data = coleman)
cvLts <- repCV(fitLts, folds = folds, 
    cost = rtmspe, trim = 0.1)

# combine results into one object
cv <- perrySelect(LS = cvLm, MM = cvLmrob, LTS = cvLts)
cv

# plot results for the MM regression model
plot(cvLmrob, method = "box")
plot(cvLmrob, method = "density")
plot(cvLmrob, method = "dot", seFactor = 1)

# plot combined results
plot(cv, method = "box")
plot(cv, method = "density")
plot(cv, method = "dot", seFactor = 1)

Run the code above in your browser using DataLab