Learn R Programming

earth (version 4.1.0)

plot.earth: 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,
    info = FALSE, delever = FALSE, pearson = FALSE, level = 0, versus = NULL,
    nresponse = 1, npoints = 1000, id.n = 3,
    labels.id = rownames(residuals(object, warn=FALSE)),
    center = TRUE, loess.f = .5,
    do.par = length(which) > 1, xlim = NULL, ylim = NULL,
    main = NULL, cex.main = 1.2, caption = if(do.par) NULL else "",
    xlab = NULL, ylab = NULL,
    pch = 20, col.line = "lightblue",
    col.loess = NULL, lwd.loess = NULL, col.cv = "red",
    col.qq = col.line, col.grid = "lightgray", col.points = 1, cex.points = NULL,
    shade.pints = "mistyrose2", shade.cints = "mistyrose4",
    cum.grid = "percentages",
    col.rsq = NA, col.residuals = NA, nresiduals = NA,
    # following are passed to plot.model.selection
    legend.pos = NULL, cex.legend = NULL, col.grsq = 1, 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.sel.grid = 0,
    col.vline = col.grsq, col.vseg = 0, lty.grsq = 1, lty.npreds = 2,
    lty.rsq = 5, lty.vline = 3, col.legend = 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. 1) Model selection (GRSq versus number of terms) 2) Cumulative distribution of abs residuals 3) Residuals versus fitted 4) QQ plot of residuals 5) Abs residuals versus fitted 6) Abs residuals versus log fi
info
Print some additional information in the Residuals plot. Default is FALSE. (1) Plot the distribution of the residuals along the bottom of the plot. (2) Show the Spearman Rank Correlation of the absolute residuals with the fitted value
delever
Default is FALSE. Divide the residuals by sqrt(1 - h_ii), where h_ii are the diagonal entries of the hat matrix. The hat matrix here is from the linear fit on earth's basis matrix bx. (No
pearson
Default is FALSE. Divide each residual by its estimated standard deviation. Requires that the model was built with the varmod.method argument, because we need the residual model to get the standard deviations. Doe
level
Plot prediction intervals at the given confidence level. Default is 0 meaning do not plot the bands. A typical value is level=.95. Requires that the model was built with the varmod.method argument. The color
versus
What do we plot the residuals against? One of: NULL Default. Plot the residuals versus the fitted values (the log fitted values when which=6 to 8). "" Residuals versus the predictors (multiple plots i
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.
npoints
Maximum number of points to display in residual and other plots. 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
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.
center
Default is TRUE, meaning center the horizontal axis in the residuals plot, so asymmetry in the residual distribution is more obvious.
loess.f
Smoothing parameter for the light blue smooth line in the residuals plot. Default .5. Lower values make the line bumpier. This argument is passed as f in the internal call to lowes
do.par
If TRUE, start a new page and call par as appropriate. Default is length(which) > 1, i.e., call par if drawing more than one plot. Use FALSE to use the cu
xlim
Horizontal axis limits. The default is NULL, meaning automatic.
ylim
Vertical axis limits. The default is NULL, meaning automatic. If which has more than one element, this argument applies only to the Model Selection plot. In the model selection plot, the special value min=-1 means the
main
Heading of each plot. Default is NULL, meaning generate the headings automatically.
cex.main
Size of plot titles. Default is 1.2. Used only if do.par is TRUE (default).
caption
Overall caption. The default value is if(do.par) NULL else "". One of: "string" string "" no caption NULL generate a caption automatically.
xlab
Default is NULL, meaning label the x axis automatically.
ylab
Default is NULL, meaning label the y axis automatically.
pch
Default is 20.
col.line
Color of lines such as the RSq line in the Model Selection plot. Default is "lightblue" Use 0 for no RSq line.
col.loess
Color of loess line in the residuals plot. Default is NULL, meaning automatic. (Actually lowess is used rather than loess,
lwd.loess
Line width of the loess line. Default is NULL, meaning automatic.
col.cv
Default is "red". Color of cross validation line in the residuals plot. This is the residual of the mean out-fold-predicted value.
col.qq
Color of QQ line in the QQ plot. Default is col.line. Use 0 for no QQ line.
col.grid
Color of grid lines in the various plots. Default is "lightgray". Use 0 for no grid.
col.points
Color of plotted points. Default is 1
cex.points
Size of the plotted points. Default is NULL, meaning automatic.
shade.pints
Only used if the level argument was used. Color of the prediction intervals. Default is "mistyrose2"
shade.cints
Only used if the level argument was used. Color of the confidence intervals. Default is "mistyrose4"
cum.grid
Specify grid type in the Cumulative Distribution plot. One of: "none" no grid on Cumulative Distribution plot "grid" add grid "percentages" (default) add grid and percentage labels to quantile lines.
col.rsq
Deprecated, please use col.line instead. Default is NA.
col.residuals
Deprecated, please use col.points instead. Default is NA.
nresiduals
Deprecated, please use npoints instead. Default is NA. The following are passed to plot.model.selection.
legend.pos
Legend position. Default is NULL, meaning automatic. Else specify c(x,y) in user coordinates, or use "topleft" etc. as explained in legend.
cex.legend
Legend cex. Default is NULL, meaning automatic.
col.grsq
Color of GRSq line in the Model Selection plot. Default is 1. Use 0 for no GRSq 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
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 is "palevioletred". U
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. U
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.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 Cumula
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 3.
col.legend
Legend color. Default is 1. Use 0 for no legend.
...
Unused, but provided for generic/method consistency.

See Also

earth, plot.earth.models, plotd, plotmo

Examples

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

Run the code above in your browser using DataLab