Learn R Programming

earth (version 2.5-1)

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, nresponse = 1,
     caption = if(do.par) NULL else "",
     col.rsq = "lightblue", col.loess = col.rsq,
     col.qq = col.rsq, col.grid = "grey",
     col.vline = "grey", lty.vline = 3,
     col.legend = 1, col.npreds = 1,
     nresiduals = 1000, cum.grid = "percentages", rlim = c(-1,-1),
     id.n = 3, labels.id = rownames(residuals(x, warn=FALSE)),
     legend.pos = NULL, do.par = TRUE,
     main = NULL, pch = 1, ...)

Arguments

x
An earth object. This is the only required argument. (This 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 plot) 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 nrespons
caption
Overall caption. The default value is if(do.par) NULL else "". Values are: "string" string "" no caption NULL generate a caption from the $call component of the earth obj
For all the col arguments, 0 means don't plot the corresponding graph element.
col.rsq
Color of RSq line in model selection plot. Default is "lightblue".
col.loess
Color of loess line in residuals plot. Default is col.rsq. Generating the loess line occasionally causes warnings such as "Warning: pseudoinverse used". To get rid of these warnin
col.qq
Color of QQ line. Default is col.rsq.
col.grid
Color of grid lines in cumulative distribution plot. Default is "grey".
col.vline
Color of vertical line at best model in model plot. Default is "grey".
lty.vline
Line type of vertical line at best model in model plot. Default is 3.
col.legend
Color of legend (inside plot area) of model plot. Default is 1, meaning draw a legend. Use 0 for no legend.
col.npreds
Color of the "number of predictors" plot within the model plot. Default is 1. Use 0 for no "number of predictors" plot.
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 include
cum.grid
Specify grid on cumulative distribution graph. Values are: "none" no grid on cumulative distribution plot "grid" add grid "percentages" (default) add grid and percentage labels to quantile lines.
rlim
Two element vector c(min,max) specifying min and max values on the y axis of the RSq plot. Default is c(-1,-1).

Special value min=-1 means the minimum y axis value is the smallest GRSq or RSq value e

id.n
Number of largest residuals to be labeled. Default is 3.
labels.id
Residual names. Default is rownames(residuals(x)).
legend.pos
NULL (default) means position legend automatically. Else specify c(x,y) in user coordinates, or use "topleft" etc. as explained in legend. The following se
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 for QQ and residuals plot. Default is 1.
...
Extra arguments passed to plotting functions.

See Also

earth, plot.earth.models, plotd, plotmo

Examples

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

Run the code above in your browser using DataLab