From maechler at stat.math.ethz.ch  Tue Apr 26 12:13:38 2005
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue Apr 26 12:16:48 2005
Subject: [Rd] Enhanced version of plot.lm()
In-Reply-To: <b21d1d1a13e8f82d4e1d44c233e9f76e@anu.edu.au>
References: <200504251000.j3PA01lD009332@hypatia.math.ethz.ch>
	<40567787fcb17bee0bf9ecf403fb8e21@anu.edu.au>
	<320af97cfe90da4c59b7e9c8cd9956d4@anu.edu.au>
	<9717926f912f9fb045c57dd9be4e743c@warwick.ac.uk>
	<b21d1d1a13e8f82d4e1d44c233e9f76e@anu.edu.au>
Message-ID: <17006.5202.986122.321760@stat.math.ethz.ch>

>>>>> "JMd" == John Maindonald <john.maindonald@anu.edu.au>
>>>>>     on Tue, 26 Apr 2005 15:44:26 +1000 writes:

    JMd> The web page http://wwwmaths.anu.edu.au/~johnm/r/plot-lm/
    JMd> now includes files:
    JMd> plot.lm.RData: Image for file for plot6.lm, a version of plot.lm in 
    JMd> which
    JMd> David Firth's Cook's distance vs leverage/(1-leverage) plot is plot 6.
    JMd> The tick labels are in units of leverage, and the contour labels are
    JMd> in units of absolute values of the standardized residual.

    JMd> plot6.lm.Rd file: A matching help file

    JMd> Comments will be welcome.

Thank you John!

The *.Rd has the new references and a new example but
is not quite complete: the \usage{} has only 4 captions,
\arguments{ .. \item{which} ..}  only mentions '1:5' --- but
never mind.

One of the new examples is

    ## Replace Cook's distance plot by Residual-Leverage plot
    plot(lm.SR, which=c(1:3, 5))

and -- conceptually I'd really like to change the default from
'which = 1:4' to the above
'which=c(1:3, 5))' 

This would be non-compatible though for all those that have
always used the current default 1:4. 
OTOH, "MASS" or Peter Dalgaard's book don't mention  plot(<lm fit> )
or at least don't show it's result.

What do others think?
How problematic would a change be in the default plots that
plot.lm() produces?


    JMd> Another issue, discussed recently on r-help, is that when the model
    JMd> formula is long, the default sub.caption=deparse(x$call) is broken
    JMd> into multiple text elements and overwrites.  
good point!

    JMd>  The only clean and simple way that I can see to handle
    JMd> is to set a default that tests whether the formula is
    JMd> broken into multiple text elements, and if it is then
    JMd> omit it.  Users can then use their own imaginative
    JMd> skills, and such suggestions as have been made on
    JMd> r-help, to construct whatever form of labeling best
    JMd> suits their case, their imaginative skills and their
    JMd> coding skills.

Hmm, yes, but I think we (R programmers) could try a bit harder
to provide a reasonable default, e.g., something along
 
 cap <- deparse(x$call, width.cutoff = 500)[1]
 if((nc <- nchar(cap)) > 53)	    
     cap <- paste(substr(cap, 1, 50), "....", substr(cap, nc-2, nc))

{untested;  some of the details will differ;
 and the '53', '50' could depend on par("..") measures}


    JMd> John Maindonald.


    JMd> On 25 Apr 2005, at 8:00 PM, David Firth wrote:

    >> From: David Firth <d.firth@warwick.ac.uk>
    >> Date: 24 April 2005 10:23:51 PM
    >> To: John Maindonald <john.maindonald@anu.edu.au>
    >> Cc: r-devel@stat.math.ethz.ch
    >> Subject: Re: [Rd] Enhanced version of plot.lm()
    >> 
    >> 
    >> On 24 Apr 2005, at 05:37, John Maindonald wrote:
    >> 
    >>> I'd not like to lose the signs of the residuals. Also, as
    >>> plots 1-3 focus on residuals, there is less of a mental
    >>> leap in moving to residuals vs leverage; residuals vs
    >>> leverage/(1-leverage) would also be in the same spirit.
    >> 
    >> Yes, I know what you mean.  Mental leaps are a matter of 
    >> taste...pitfalls, etc, come to mind.
    >> 
    >>> 
    >>> Maybe, one way or another, both plots (residuals vs
    >>> a function of leverage, and the plot from Hinkley et al)
    >>> should go in.  The easiest way to do this is to add a
    >>> further which=6.  I will do this if the consensus is that
    >>> this is the right way to go.  In any case, I'll add the
    >>> Hinkley et al reference (author of the contribution that
    >>> includes p.74?) to the draft help page.
    >> 
    >> Sorry, I should have given the full reference, which (in BibTeX format 
    >> from CIS) is
    >> 
    >> @inproceedings{Firt:gene:1991,
    >> author = {Firth, D.},
    >> title = {Generalized Linear Models},
    >> year = {1991},
    >> booktitle = {Statistical Theory and Modelling. In Honour of Sir 
    >> David Cox, FRS},
    >> editor = {Hinkley, D. V. and Reid, N. and Snell, E. J.},
    >> publisher = {Chapman \& Hall Ltd},
    >> pages = {55--82},
    >> keywords = {Analysis of deviance; Likelihood}
    >> }
    >> 
    >> David
    >> 
    JMd> John Maindonald             email: john.maindonald@anu.edu.au
    JMd> phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
    JMd> Centre for Bioinformation Science, Room 1194,
    JMd> John Dedman Mathematical Sciences Building (Building 27)
    JMd> Australian National University, Canberra ACT 0200.

    JMd> ______________________________________________
    JMd> R-devel@stat.math.ethz.ch mailing list
    JMd> https://stat.ethz.ch/mailman/listinfo/r-devel

>>>>> "JMd" == John Maindonald <john.maindonald@anu.edu.au>
>>>>>     on Tue, 26 Apr 2005 15:44:26 +1000 writes:

    JMd> The web page
    JMd> http://wwwmaths.anu.edu.au/~johnm/r/plot-lm/ now
    JMd> includes files: plot.lm.RData: Image for file for
    JMd> plot6.lm, a version of plot.lm in which David Firth's
    JMd> Cook's distance vs leverage/(1-leverage) plot is plot
    JMd> 6.  The tick labels are in units of leverage, and the
    JMd> contour labels are in units of absolute values of the
    JMd> standardized residual.

    JMd> plot6.lm.Rd file: A matching help file

    JMd> Comments will be welcome.

    JMd> Another issue, discussed recently on r-help, is that
    JMd> when the model formula is long, the default
    JMd> sub.caption=deparse(x$call) is broken into multiple
    JMd> text elements and overwrites.  The only clean and
    JMd> simple way that I can see to handle is to set a default
    JMd> that tests whether the formula is broken into multiple
    JMd> text elements, and if it is then omit it.  Users can
    JMd> then use their own imaginative skills, and such
    JMd> suggestions as have been made on r-help, to construct
    JMd> whatever form of labeling best suits their case, their
    JMd> imaginative skills and their coding skills.

    JMd> John Maindonald.


    JMd> On 25 Apr 2005, at 8:00 PM, David Firth wrote:

    >> From: David Firth <d.firth@warwick.ac.uk> Date: 24 April
    >> 2005 10:23:51 PM To: John Maindonald
    >> <john.maindonald@anu.edu.au> Cc:
    >> r-devel@stat.math.ethz.ch Subject: Re: [Rd] Enhanced
    >> version of plot.lm()
    >> 
    >> 
    >> On 24 Apr 2005, at 05:37, John Maindonald wrote:
    >> 
    >>> I'd not like to lose the signs of the residuals. Also,
    >>> as plots 1-3 focus on residuals, there is less of a
    >>> mental leap in moving to residuals vs leverage;
    >>> residuals vs leverage/(1-leverage) would also be in the
    >>> same spirit.
    >>  Yes, I know what you mean.  Mental leaps are a matter of
    >> taste...pitfalls, etc, come to mind.
    >> 
    >>>  Maybe, one way or another, both plots (residuals vs a
    >>> function of leverage, and the plot from Hinkley et al)
    >>> should go in.  The easiest way to do this is to add a
    >>> further which=6.  I will do this if the consensus is
    >>> that this is the right way to go.  In any case, I'll add
    >>> the Hinkley et al reference (author of the contribution
    >>> that includes p.74?) to the draft help page.
    >>  Sorry, I should have given the full reference, which (in
    >> BibTeX format from CIS) is
    >> 
    >> @inproceedings{Firt:gene:1991, author = {Firth, D.},
    >> title = {Generalized Linear Models}, year = {1991},
    >> booktitle = {Statistical Theory and Modelling. In Honour
    >> of Sir David Cox, FRS}, editor = {Hinkley, D. V. and
    >> Reid, N. and Snell, E. J.}, publisher = {Chapman \& Hall
    >> Ltd}, pages = {55--82}, keywords = {Analysis of deviance;
    >> Likelihood} }
    >> 
    >> David
    >> 
    JMd> John Maindonald email: john.maindonald@anu.edu.au phone
    JMd> : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for
    JMd> Bioinformation Science, Room 1194, John Dedman
    JMd> Mathematical Sciences Building (Building 27) Australian
    JMd> National University, Canberra ACT 0200.

    JMd> ______________________________________________
    JMd> R-devel@stat.math.ethz.ch mailing list
    JMd> https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Enhanced version of plot.lm()
Martin Maechler