Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Rare bug/feature in -graph,ylog-


From   Roger Newson <[email protected]>
To   [email protected]
Subject   st: Rare bug/feature in -graph,ylog-
Date   Mon, 04 Nov 2002 12:46:29 +0000

Hello all (especially StataCorp)

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.

Best wishes

Roger

--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]

Opinions expressed are those of the author, not the institution.

*
* 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/




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