[Rd] Enhanced version of plot.lm()

David Firth d.firth at warwick.ac.uk
Sat Apr 23 17:09:02 CEST 2005


On 23 Apr 2005, at 12:30, John Maindonald wrote:

> I propose the following enhancements and changes to plot.lm(),
> the most important of which is the addition of a Residuals vs
> Leverage plot.
>
> (1) A residual versus leverage plot has been added, available
> by specifying which = 5, and not included as one of the default
> plots.  Contours of Cook's distance are included, by default at
> values of 0.5 and 1.0.  The labeled points, if any, are those with
> the largest Cook's distances.  The parameter cook.levels can be
> changed as required, to control what contours appear.
>
> (2) Remove the word "plot" from the captions for which=2, 3, 4.
> It is redundant.
>
> (3) Now that the pos argument to text() is vectorized, use that
> in preference to an offset.
>
> (4) For which!=4 or 5, by default use pos=4 on the left half
> of the panel, and pos=2 on the right half of the panel.
> This prevents labels from appearing outside the plot area,
> where they can overlap other graphical features.
> The parameter label.pos allows users to change this default.
>
> The modified code that I propose is below.   This, a modified .Rd
> file, and files from diff used with the April 20 development version,
> are in my directory
>
> http://wwwmaths.anu.edu.au/~johnm/r/plot-lm/
>
> I believe the Residual-Leverage plot is given in Krause & Olsen,
> whether with Cook's distance contours I do not recall.  I do not
> have access to a copy of this book.  Martin Maechler drew my
> attention to it in 2003, as superior to the Cook's distance plot.

Agreed.  Alternatively Cook's distance versus leverage/(1-leverage), as 
on p74 of this book:
Statistical Theory and Modelling, In honour of Sir David Cox, FRS.  Eds 
D V Hinkley, N Reid and E J Snell.  Chapman and Hall, 1991.
In that graph the contours of residual^2 are straight lines through the 
origin.  A small disadvantage is that the sign of the residual is lost.

David

> I have finally got around to coding it up!
>
> John Maindonald.
...



More information about the R-devel mailing list