Learn R Programming

earth (version 2.3-0)

plotd: Plot the distribution of predictions for each class

Description

Draw a plot of the distribution of the predicted values for each class.

Usage

plotd(object, hist = FALSE, type="response", thresh = .5, xlim = NULL, 
    main=NULL, xlab="Predicted Value", ylab=if(hist) "Count" else "Density",
    lty = 1, col = c("grey60", 1, "lightblue", "brown", "pink", 2, 3, 4),
    borders = NULL, zero.line=FALSE,
    legend = TRUE, legend.names = NULL, legend.pos = NULL,
    legend.cex = .8, legend.bg = "white", legend.extra = FALSE,
    vline.col = 0, vline.thresh = thresh, vline.lty = 1,
    ...)

Arguments

object
model object. Typically a model which predicts a class or a class probability.
hist
FALSE (default) to call density internally TRUE to call hist internally
type
type parameter passed on to predict. Default is "response". See the predict method for your object to see other values; for example see p
thresh
Passed to predict.earth (only used if type="class"). Default is .5. Also used as a default for the vline.thresh argument (see below).
xlim
limits of the x axis. The default NULL means determine these limits automatically, else specify c(xmin,xmax).
main
main graph title. Values: "string" string "" no title NULL (default) generate a title from the $call component of the model object.
xlab
x axis label. Default is "Predicted Value".
ylab
y axis label. Default is if(hist) "Count" else "Density".
lty
per class line types for the plotted lines. Default is 1 for all lines.
col
per class graph colors. The first few colors of the default are intended to be easily distinguishable on both color displays and monochrome printers.
borders
per class border colors for hist plot. Only used if hist=TRUE. The default NULL means use the values in the col argument.
zero.line
parameter for plot.density. Only used if hist=FALSE. Default is FALSE.
legend
TRUE (default) to draw a legend
legend.names
class names in legend. The default NULL means determine these automatically.
legend.pos
position of the legend. The default NULL means try to position the legend automatically, else specify c(x,y).
legend.cex
cex for legend. Default is .8. Make this smaller for a smaller legend.
legend.bg
bg color for legend. Default is "white".
legend.extra
show number of occurrences of each class. Default is FALSE.
vline.col
color of vertical line. Default is 0, meaning no vertical line. The vertical line is intended to indicate class separation.
vline.thresh
x position of vertical line. Default is thresh.
vline.lty
line type of vertical line. Default is 1.
...
extra arguments passed to density or hist. Arguments for hist which affect only plotting are not allowed

See Also

earth, plot.earth, plotmo density, plot.density hist, plot.histogram

Examples

Run this code
old.par <- par(no.readonly=TRUE); par(mfrow=c(2,2)); 
par(mar=c(4, 3, 1.7, 0.5)); par(mgp=c(1.6, 0.6, 0))
data(etitanic)
a <- earth(survived ~ ., data=etitanic, degree=2, glm=list(family=binomial))

plotd(a, main="plotd default")

plotd(a, main="histogram", hist=TRUE, legend.pos=c(.25,220))

plotd(a, main="histogram, type=class", hist=TRUE, type="class",
      legend.pos=c(.14,500), legend.extra=TRUE)

par(old.par)

Run the code above in your browser using DataLab