plot.earth {earth}R Documentation

Plot an "earth" object

Description

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

Usage

## S3 method for class 'earth'
plot(x = stop("no 'x' arg"),
    which = 1:4, nresponse = 1,
    caption = if(do.par) NULL else "",
    col.grsq = 1, lty.grsq = 1, col.rsq = "lightblue",
    lty.rsq = 5, col.vline = col.grsq, lty.vline = 3,
    col.npreds = if(is.null(x$cv.oof.rsq.tab)) 1 else 0, lty.npreds = 2,
    col.mean.oof.rsq = "palevioletred", col.oof.rsq = "mistyrose2",
    col.oof.vline = col.mean.oof.rsq, col.oof.labs = 0,
    col.pch.max.oof.rsq = 0, col.pch.cv.rsq = 0,
    col.mean.infold.rsq = 0, col.infold.rsq = 0, col.sel.grid = 0,
    ylim = c(-1,-1),
    col.legend = 1, cex.legend = NULL, legend.pos = NULL,
    col.cum.grid = "lightgray", cum.grid = "percentages",
    id.n = 3, labels.id = rownames(residuals(x, warn=FALSE)),
    col.residuals = 1, col.loess = col.rsq, nresiduals = 1000,
    col.qq = col.rsq,
    do.par = TRUE, main = NULL, pch = 1, rlim = NA, col.grid = NA, ...)

Arguments

x

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

which

Which plots to plot. Default is 1:4, meaning all.
1) model selection (GRSq versus number of terms)
2) cumulative distribution of absolute values of residuals
3) residuals versus fitted values
4) QQ plot of residuals

nresponse

Specify which column of the response to plot if the model has multiple responses. Default is 1. This argument does not affect the Model Selection plot which is always across all responses.
[TODO There is an issue in the handling of nresponse for multiple level factor responses. Does nresponse refer to the column in the observed or predicted response?]

caption

Overall caption. The default value is if(do.par) NULL else "". Values are:
"string" string
"" no caption
NULL generate a caption automatically.

col.grsq

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

lty.grsq

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

col.rsq

Color of RSq line (in the Model Selection plot). Default is "lightblue". Use 0 for no Rsq line.

lty.rsq

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

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.

lty.vline

Line type of vertical line at selected model (in the Model Selection plot). Default is 3.

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.

lty.npreds

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

col.mean.oof.rsq

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. Default "palevioletred". Use 0 to not plot this line.

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". 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.oof.labs

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

col.pch.max.oof.rsq

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

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 0, point not plotted.

col.mean.infold.rsq

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

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.sel.grid

Color of grid lines in the Model Selection graph. Default is 0, no grid. Try something like "lightgray", "linen", or "seashell". See also col.cum.grid, for the grid in the Cumulative Distribution plot.

ylim

Two element vector c(min,max) specifying min and max values on the y axis in the Model Selection plot. This is useful if you want to focus on a specific region of the curve. Default is c(-1,-1).
Special value min=-1 means the minimum y axis value is the smallest GRSq or RSq value excluding the intercept values.
Special value max=-1 means the maximum y axis value is the largest GRSq or RSq value.

col.legend

Legend color. Default is 1. Use 0 for no legend.

cex.legend

Legend cex. Default is NULL, meaning choose automatically.

legend.pos

Legend position. Default NULL, meaning position the legend automatically. Else specify c(x,y) in user coordinates, or use "topleft" etc. as explained in legend.

col.cum.grid

Color of grid lines in the Cumulative Distribution plot. Default is "lightgray". See also col.sel.grid, for the grid in the Model Selection plot.

cum.grid

Specify grid type in the Cumulative Distribution plot. Values are:
"none" no grid on Cumulative Distribution plot
"grid" add grid
"percentages" (default) add grid and percentage labels to quantile lines.

id.n

The largest id.n residuals will be labeled in the plot. Default is 3.

labels.id

Residual names. Default is rownames(residuals(x)). Only used if id.n > 0.

col.loess

Color of loess line in the Residuals plot. Default is col.rsq. (Actually lowess is used rather than loess, to avoid ugly warnings issued by loess. The arguments is so named for backward compatibility.)

col.residuals

Color of the residual points in the Residuals and QQ plots. Default is 1. Can be vectorized, for example col.residuals=iris$Species.

nresiduals

Maximum number of residuals to plot. Use -1 for all. Default is 1000 (not all to reduce over-plotting). A systematic sample of size nresiduals is taken but the largest few residuals are always included. This parameter applies to the Residuals and Normal QQ plots; the Cumulative Distribution plot uses all residuals.

col.qq

Color of QQ line (in the QQ plot). Default is col.rsq. Use 0 for no QQ line.

do.par

Call par() for global settings as appropriate. Default is TRUE, which sets mfrow, mar=c(4,4,2,1), mgp=c(1.6,0.6,0), cex=0.7. Set to FALSE if you want to append figures to an existing plot.

main

Title of each plot. Default is NULL, meaning generate figure headings automatically.

pch

Plot character in the QQ and Residuals plot. Default is 1.

rlim

Deprecated. Please use ylim instead.

col.grid

Deprecated. Please use col.cum.grid instead.

...

Extra arguments passed to plotting functions.

Note

For details on interpreting the graphs, please see the earth package vignette “Notes on the earth package”.

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

See Also

earth, plot.earth.models, plotd, plotmo

Examples

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

[Package earth version 3.2-7 Index]