Description Usage Arguments Details Value Author(s) References See Also Examples
This function creates a “bubble” plot of functions, R = log(Studentized residuals^2) by L = log(H/p*(1-H)) of the hat values, with the areas of the circles representing the observations proportional to Cook's distances.
This plot, suggested by McCulloch & Meeter (1983) has the attractive property that contours of equal Cook's distance are diagnonal lines with slope = -1. Various reference lines are drawn on the plot corresponding to twice and three times the average hat value, a “large” squared studentized residual and contours of Cook's distance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | lrPlot(model, ...)
## S3 method for class 'lm'
lrPlot(model, scale = 12,
xlab = "log Leverage factor [log H/p*(1-H)]",
ylab = "log (Studentized Residual^2)",
xlim = NULL, ylim,
labels,
id.method = "noteworthy",
id.n = if (id.method[1] == "identify") Inf else 0,
id.cex = 1, id.col = palette()[1],
ref = c("h", "v", "d", "c"), ref.col = "gray",
ref.lty = 2, ref.lab = TRUE,
...)
|
model |
a linear or generalized-linear model. |
scale |
a factor to adjust the radii of the circles, in relation to |
xlab, ylab |
axis labels. |
xlim, ylim |
Limits for x and y axes. In the space of (L, R) very small residuals
typically extend the y axis enough to swamp the large residuals, so the default for
|
labels, id.method, id.n, id.cex, id.col |
settings for labelling
points; see |
ref |
Options to draw reference lines, any one or more of |
ref.col, ref.lty |
Color and line type for reference lines. Reference lines for |
ref.lab |
A logical, indicating whether the reference lines should be labeled. |
... |
arguments to pass to the |
The id.method="noteworthy"
setting
also requires setting id.n>0
to have any effect.
Using id.method="noteworthy"
, and id.n>0
, the number of points labeled
is the union of the largest id.n
values on each of L, R, and CookD.
If points are identified, returns a data frame with the hat values, Studentized residuals and Cook's distance of the identified points. If no points are identified, nothing is returned. This function is primarily used for its side-effect of drawing a plot.
Michael Friendly
A. J. Lawrence (1995). Deletion Influence and Masking in Regression Journal of the Royal Statistical Society. Series B (Methodological) , Vol. 57, No. 1, pp. 181-189.
McCulloch, C. E. & Meeter, D. (1983). Discussion of "Outliers..." by R. J. Beckman and R. D. Cook. Technometrics, 25, 152-155.
influencePlot
in the car
package for other methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # artificial example from Lawrence (1995)
x <- c( 0, 0, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 18, 18 )
y <- c( 0, 6, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 7, 18 )
DF <- data.frame(x,y, row.names=LETTERS[1:length(x)])
DF
with(DF, {
plot(x,y, pch=16, cex=1.3)
abline(lm(y~x), col="red", lwd=2)
NB <- c(1,2,13,14)
text(x[NB],y[NB], LETTERS[NB], pos=c(4,4,2,2))
}
)
mod <- lm(y~x, data=DF)
# standard influence plot from car
influencePlot(mod, id.n=4)
# lrPlot version
lrPlot(mod, id.n=4)
library(car)
dmod <- lm(prestige ~ income + education, data = Duncan)
influencePlot(dmod, id.n=3)
lrPlot(dmod, id.n=3)
|
Loading required package: car
Loading required package: carData
Loading required package: heplots
x y
A 0 0
B 0 6
C 7 6
D 7 7
E 8 6
F 8 7
G 9 6
H 9 7
I 10 6
J 10 7
K 11 6
L 11 7
M 18 7
N 18 18
StudRes Hat CookD
M -2.162660 0.3068937 0.7925928
N 5.156882 0.3068937 1.8793244
Warning messages:
1: In plot.window(...) : "id.n" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "id.n" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
"id.n" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
"id.n" is not a graphical parameter
5: In box(...) : "id.n" is not a graphical parameter
6: In title(...) : "id.n" is not a graphical parameter
7: In plot.xy(xy.coords(x, y), type = type, ...) :
"id.n" is not a graphical parameter
Note: 7 points less than R= -2 have been clipped to preserve resolution
Rstudent Hat CookD L R
A -1.045217 0.3068937 0.2400144 -1.507829 0.0884497
B 1.699917 0.3068937 0.5527151 -1.507829 1.0611588
M -2.162660 0.3068937 0.7925928 -1.507829 1.5426777
N 5.156882 0.3068937 1.8793244 -1.507829 3.2806642
StudRes Hat CookD
minister 3.1345186 0.17305816 0.56637974
reporter -2.3970224 0.05439356 0.09898456
conductor -1.7040324 0.19454165 0.22364122
RR.engineer 0.8089221 0.26908963 0.08096807
Warning messages:
1: In plot.window(...) : "id.n" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "id.n" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
"id.n" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
"id.n" is not a graphical parameter
5: In box(...) : "id.n" is not a graphical parameter
6: In title(...) : "id.n" is not a graphical parameter
7: In plot.xy(xy.coords(x, y), type = type, ...) :
"id.n" is not a graphical parameter
Note: 11 points less than R= -3 have been clipped to preserve resolution
Rstudent Hat CookD L R
minister 3.1345186 0.17305816 0.56637974 -2.662719 2.2849512
reporter -2.3970224 0.05439356 0.09898456 -3.954193 1.7484546
conductor -1.7040324 0.19454165 0.22364122 -2.519378 1.0659949
contractor 2.0438046 0.04325517 0.05852346 -4.195032 1.4296262
RR.engineer 0.8089221 0.26908963 0.08096807 -2.097859 -0.4241054
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.