[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Rare bug/feature in -graph,ylog- |

Date |
Mon, 4 Nov 2002 13:49:34 -0000 |

Roger Newson > > I think I have discovered a rarely-encountered bug/feature > in the Stata > -graph- command. (I use the very latest Stata 7 under > Windows 98 SE.) It > appears that, if there is only one observation in the > selected sample, and > -ylog- (or -xlog-) is specified, and the single y-value (or > x-value) is in > the open interval between one and zero, then -graph- complains of > non-positive values. For instance, in the -auto- data, I > might define a > variable -gpm- by typing: > . drop gpm > > . gene gpm=1/mpg > > . summ gpm > > Variable | Obs Mean Std. Dev. Min Max > -------------+----------------------------------------------------- > gpm | 74 .0501928 .0127986 .0243902 .0833333 > > > As you can see, -gpm- (gallons per mile) has values all in the open > interval from 0 to 1. If I then use this variable in a > -graph- command with > one observation and the option -xlog- or -ylog-, then the > result is as follows: > > > . grap weight gpm in 1,xlog > nonpositive values encountered > r(411); > > . grap gpm weight in 1,ylog > nonpositive values encountered > r(411); > > > I get similar results if I restrict the -graph- to any > other observation. > However, -graph- doesn't seem to mind if I type > > . grap gpm weight in 1,xlog > > . grap weight gpm in 1,ylog > > in which case graphs are drawn. Nor is there any problem if > more than one > observation is included, as follows: > > . grap weight gpm in 1/2,xlog > > . grap gpm weight in 1/2,ylog > > It therefore seems that the problem -graph- has is > specifically with the > non-positive logs in single-observation sample sets. > > The bug/feature I have found is, of course, rarely > encountered in day to > day statistical work, because very few people draw graphs with one > observation. (I discovered it today in the course of > writing a cert script > for my -smileplot- package, downloadable from SSC, which > plots P-values on > a reverse log scale against the corresponding estimates.) > However, in the > interests of completeness, it would be ideal if this > bug/feature was fixed, > before it confuses too many more unwary cert script writers. > This certainly looks like a bug, but Stata is only trying its best... How does it arise? Here is my surmise. When Stata is -- in effect -- asked to plot a constant on one graph axis, how it is supposed to choose upper and lower limits for the axis -- if given no information to determine that by -?la()- or -?sc()-? The adhockery used is that Stata tries to add 1 to and subtract 1 from the constant. However, whenever the lower limit would be < 0 this clashes with any prescription of a logarithmic scale. Hence my guess is that this arises whenever the constant is <= 1, not quite Roger's diagnosis. Nick n.j.cox@durham.ac.uk * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: RE: Rare bug/feature in -graph,ylog-***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: Rare bug/feature in -graph,ylog-***From:*Roger Newson <roger.newson@kcl.ac.uk>

- Prev by Date:
**st: How do I obtain SS ad df after anova** - Next by Date:
**st: RE: Rare bug/feature in -graph,ylog-** - Previous by thread:
**st: Rare bug/feature in -graph,ylog-** - Next by thread:
**st: RE: RE: Rare bug/feature in -graph,ylog-** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |