[R] Graphical presentation of logistic regression

David Scott d.scott at auckland.ac.nz
Thu Sep 15 00:06:53 CEST 2005


On Wed, 14 Sep 2005, Beale, Colin wrote:

> Hi,
>
> I wonder if anyone has written any code to implement the suggestions of
> Smart et al (2004) in the Bulletin of the Ecological Society of America
> for a new way of graphically presenting the results of logistic
> regression (see
> www.esapubs.org/bulletin/backissues/085-3/bulletinjuly2004_2column.htm#t
> ools1 for the full text)? I couldn't find anything relating to this sort
> of graphical representation of logistic models in the archives, but
> maybe someone has solved it already? In short, Smart et al suggest that
> a logistic regression be presented as a combination of the two
> histograms for successes and failures (with one presented upside down at
> the top of the figure, the other the right way up at the bottom)
> overlaid by the probability function (ie logistic curve). It's somewhat
> hard to describe, but is nicely illustrated in the full text version
> above. I think it is a sensible way of presenting these results and am
> keen to do so - at the moment I can only do this by generating the two
> histograms and the logistic curve separately (using hist() and lines()),
> then copying and pasting the graphs out of R and inverting one in a
> graphics package, before overlying the others. I'm sure this could be
> done within R and would be a handy plotting function to develop. Has
> anyone done so, or can anyone give me any pointers to doing this? I
> really nead to know how to invert a histogram and how to overlay this
> with another histogram "the right way up".
>
I think if you take a peek at hist.default you will find it is pretty 
straightforward. All that happens in hist.default is there is a lot of 
stuff about choosing the breaks for the bins, then some C code is called 
to get the counts, then the information is assembled and plot is called 
where the object plotted is of class histogram.

If you then look at plot.histogram (getAnywhere(plot.histogram)) you find 
all it really does is plot some rectangles. Just change the plotting bit.

If you want an example of how it might be done, you can look at log.hist 
in my package HyperbDist (or a more recent version logHist.R on my 
homepage at http://www.stat.auckland.ac.nz/~dscott/)

David Scott


_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
 		The University of Auckland, PB 92019
 		Auckland	NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz


Graduate Officer, Department of Statistics




More information about the R-help mailing list