This function is called by several graphical functions in the car package to mark extreme points in a 2D plot. Although the user is unlikely to call this function directly, the documentation below applies to all these other functions.
Plotted horizontal coordinates.
Plotted vertical coordinates.
Plotting labels. When called from within a car plotting function, the labels are automatically obtained from the row names in the data frame used to create the modeling object. If
How points are to be identified. See Details below.
Number of points to be identified. If set to 0, no points are identified.
Controls the size of the plotted labels. The default is
Controls the color of the plotted labels. The default is the first element returned by
Where should the label be drawn? The default is
method determine how the points
to be identified are selected. For the default value of
identify function is used to identify points
interactively using the mouse. Up to
n points can be identified,
n=0, which is the default in many functions in the car
package, then no point identification is done.
Automatic point identification can be done depending on the value of the
method = "x" select points according to their value of
abs(x - mean(x))
method = "y" select points according to their value of
abs(y - mean(y))
method = "r" select points according to their value of
abs(y), as may be
appropriate in residual plots, or others with a meaningful origin at 0
method = "mahal" Treat
(x, y) as if it were a bivariate sample, and
select cases according to their Mahalanobis distance from
method can be a vector of the same length as
x consisting of
values to determine the points to be labeled. For example, for a linear model
method=cooks.distance(m) will label the
points corresponding to the largest values of Cook's distance, or
method = which(abs(residuals(m, type="pearson")) > 2 would label
all observations with Pearson residuals greater than 2 in absolute value.
Warning: If missing data are present, points may be incorrectly labelled.
method can be a vector of case numbers or case-labels, in which case
those cases will be labeled. Warning: If missing data are present, a list of
case numbers may identify the wrong points. A list of case labels, however,
will work correctly with missing values.
method = "none" causes no point labels to be shown.
method argument can be a list, so, for
method=list("x", "y") would label according to the horizontal
and vertical axes variables.
Finally, if the axes in the graph are logged, the function uses logged-variables where appropriate.
A function primarily used for its side-effect of drawing point labels on a plot. Returns invisibly the labels of the selected points, or NULL if no points are selected. Although intended for use with other functions in the car package, this function can be used directly.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
1 2 3 4 5 6 7 8
plot(income ~ education, Prestige) with(Prestige, showLabels(education, income, labels = rownames(Prestige), method=list("x", "y"), n=3)) m <- lm(income ~ education, Prestige) plot(income ~ education, Prestige) abline(m) with(Prestige, showLabels(education, income, labels=rownames(Prestige), method=abs(residuals(m)), n=4))
Loading required package: carData university.teachers physicians veterinarians general.managers 21 24 25 2 physicians lawyers 24 17 general.managers physicians lawyers 2 24 17 osteopaths.chiropractors 26
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.