plot.earth: Plot an earth object

View source: R/plot.earth.R

plot.earthR Documentation

Plot an earth object

Description

Plot an earth object. By default the plot shows model selection, cumulative distribution of the residuals, residuals versus fitted values, and the residual QQ plot.

This function calls plotres internally. The first arguments are identical to plotres.

Usage

## S3 method for class 'earth'
plot(x = stop("no 'x' argument"),

  # the following are identical to plotres arguments

  which = 1:4, info = FALSE, versus = 1, standardize = FALSE, delever = FALSE,
  level = 0, id.n = 3, labels.id = NULL, smooth.col = 2, grid.col = 0,
  jitter = 0, do.par = NULL, caption = NULL,
  trace = 0, npoints = 3000, center = TRUE, type = NULL, nresponse = NA,

  # the following are earth specific

  col.cv = "lightblue", col.grsq = 1, col.rsq = 2, col.infold.rsq = 0,
  col.mean.infold.rsq = 0, col.mean.oof.rsq = "palevioletred",
  col.npreds = if(is.null(object$cv.oof.rsq.tab)) 1 else 0, col.oof.labs = 0,
  col.oof.rsq = "mistyrose2", col.oof.vline = col.mean.oof.rsq,
  col.pch.cv.rsq = 0, col.pch.max.oof.rsq = 0, col.vline = col.grsq,
  col.vseg = 0, lty.grsq = 1, lty.npreds = 2, lty.rsq = 5, lty.vline = "12",
  legend.pos = NULL, ...)

earth_plotmodsel( # for internal use by plotres
  x, col.rsq = 2, col.grsq = 1, col.infold.rsq = 0,
  col.mean.infold.rsq = 0, col.mean.oof.rsq = "palevioletred",
  col.npreds = NULL, col.oof.labs = 0, col.oof.rsq = "mistyrose2",
  col.oof.vline = col.mean.oof.rsq, col.pch.cv.rsq = 0,
  col.pch.max.oof.rsq = 0, col.vline = col.grsq, col.vseg = 0,
  lty.grsq = 1, lty.npreds = 2, lty.rsq = 5, lty.vline = "12",
  legend.pos=NULL, add = FALSE, jitter = 0,
  max.nterms = length(object$rss.per.subset),
  max.npreds=max(1,get.nused.preds.per.subset(object$dirs,object$prune.terms)),
  ...)

Arguments

x

An earth object. This is the only required argument. (It is called "x" for consistency with the generic plot.)

which, info, versus

These arguments are identical to plotres. Please see the help page for plotres.

standardize, delever, level

.

id.n, labels.id, smooth.col

.

grid.col, jitter

.

do.par, caption, trace

.

npoints, center

.

type, nresponse

.

col.cv

Default "lightblue". Color of cross validation line in the residuals plot. This is the residual of the mean out-fold-predicted value.

The following arguments are for the model selection plot.

col.grsq

Default 1. Color of GRSq line in the Model Selection plot. Use 0 for no GRSq line.

col.rsq

Default 2. Color of the RSq line in the Model Selection plot. Use 0 for no RSq line.

col.infold.rsq

Color of in-fold RSq lines for each fold in the Model Selection plot. Applies only if nfold and keepxy were used in the original call to earth. Default is 0, lines not plotted.

col.mean.infold.rsq

Color of mean in-fold RSq for each number of terms in the Model Selection plot. Default is 0, line not plotted. Applies only if nfold and keepxy were used in the original call to earth.

col.mean.oof.rsq

Default "palevioletred". Color of mean out-of-fold RSq for each number of terms in the Model Selection plot. Applies only if nfold and keepxy were used in the original call to earth. Use 0 to not plot this line.

col.npreds

Color of the "number of predictors" plot in the Model Selection plot. The default displays the number of predictors unless the oof.rsq's are displayed. Use 0 for no "number of predictors" plot.

col.oof.labs

Color of fold number labels on the oof.rsq lines. Default is 0, no labels.

col.oof.rsq

Color of out-of-fold RSq lines for each fold in the Model Selection plot. Applies only if nfold and keepxy were used in the original call to earth. Default is "mistyrose2", a pale pink. Use 0 to not plot these lines. May be a vector of colors, which will be recycled if necessary.

col.oof.vline

Color of vertical line at the maximum oof.rsq in the Model Selection plot. Default is col.mean.oof.rsq.

col.pch.cv.rsq

Color of point plotted on the oof.rsq line to indicate the cv.rsq. for that fold (i.e., it is plotted at the number of terms selected by the in-fold GCV). Default is 0, point not plotted.

col.pch.max.oof.rsq

Color of point plotted on the oof.rsq line to indicate the maximum oof.rsq for that fold. Default is 0, point not plotted.

col.vline

Color of the vertical line at selected model in the Model Selection plot. Default is col.grsq. This will be at the maximum GRSq unless pmethod="none". Use 0 for no vertical line.

col.vseg

Default is 0. Color of triangular marker at top of vertical line for best GRSq.

lty.grsq

Line type of GRSq line in the Model Selection plot. Default is 1

lty.npreds

Line type of the "number of predictors" plot in the Model Selection plot. Default is 2.

lty.rsq

Line type of RSq line in the Model Selection plot. Default is 5.

lty.vline

Line type of vertical line at selected model in the Model Selection plot. Default is "12".

legend.pos

Position of the legend in the Model Selection plot. Default is NULL meaning automatic. Use legend.pos=NA or 0 for no legend. Can be something like legend.pos="topleft" or legend.pos=c(6, .75).

add, max.nterms, max.npreds

earth_plotmodsel arguments for internal use by plotres.


...

Please see plotres for the details on the dots arguments.

The ylim argument is treated specially in the model selection plot: ymin equal to -1 means use the smallest GRSq or RSq value, excluding the intercept, and ymax equal -1 means use the largest GRSq or RSq value.

Note

For details on interpreting the graphs, please see the earth package vignettes “Notes on the earth package” and “Variance models in earth”.

Note that cross-validation data will not be displayed unless both nfold and keepxy were used in the original call to earth.

To remove the Number of used predictors from the Model Selection graph (to reduce clutter), use col.npreds=0.

earth_plotmodsel is provided for use by plotres.

Acknowledgment

This function incorporates the function spread.labs from the orphaned package TeachingDemos written by Greg Snow.

See Also

earth, plot.earth.models, plotd, plotmo

Examples

data(ozone1)
earth.mod <- earth(O3 ~ ., data = ozone1, degree = 2)
plot(earth.mod)

earth documentation built on Oct. 6, 2024, 1:08 a.m.

Related to plot.earth in earth...