perry (version 0.3.1)

perryPlot: Plot resampling-based prediction error results

Description

Plot results of resampling-based prediction error measures.

Usage

perryPlot(object, ...)

# S3 method for perry perryPlot( object, which = c("box", "density", "dot"), select = NULL, seFactor = NA, ... )

# S3 method for perrySelect perryPlot( object, which = c("box", "density", "dot", "line"), subset = NULL, select = NULL, seFactor = object$seFactor, ... )

# S3 method for setupPerryPlot perryPlot(object, mapping = object$mapping, facets = object$facets, ...)

# S3 method for perry autoplot(object, ...)

# S3 method for perrySelect autoplot(object, ...)

# S3 method for perry plot(x, ...)

# S3 method for perrySelect plot(x, ...)

Arguments

object, x

an object inheriting from class "perry" or "perrySelect" that contains prediction error results, or an object of class "setupPerryPlot" containing all necessary information for plotting (as generated by setupPerryPlot).

additional arguments to be passed down, eventually to geom_boxplot, geom_density, geom_pointrange, or geom_line.

which

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 (average) results for each model as a connected line (for objects inheriting from class "perrySelect"). Note that the first two plots are only meaningful in case of repeated resampling. The default is to use "box" in case of repeated resampling and "dot" otherwise.

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.

subset

a character, integer or logical vector indicating the subset of models for which to plot the prediction error results.

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 formula is one-sided or two-sided.

Value

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

Details

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

See Also

setupPerryPlot,

perryFit, perrySelect, perryTuning,

ggplot, autoplot, plot

Examples

Run this code
# NOT RUN {
library("perryExamples")
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 <- perry(fitLm, splits = folds,
              cost = rtmspe, trim = 0.1)

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

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

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

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

# plot combined results
plot(cv, which = "box")
plot(cv, which = "density")
plot(cv, which = "dot", seFactor = 2)
# }

Run the code above in your browser using DataLab