Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: boxplot whiskers with -lv- versus -adjacent-


From   "William M. Doerner" <[email protected]>
To   [email protected]
Subject   st: boxplot whiskers with -lv- versus -adjacent-
Date   Tue, 11 May 2010 10:43:35 -0400

Does anybody know what the -graph box- and -adjacent- commands are
computing for their whiskers?  They aren't using the typical +-1.5*IQR
formula as listed in the help files and used by -lv-.

The command -adjacent- adjusts the fence for min/max values, but the
adjacent values are not lower=Q1-1.5*IQR and upper=Q3+1.5*IQR.  The
command -lv- computes the adjacent values with that formula, but it
does not adjust the fence for min/max values.  I am puzzled.  I looked
at the code, but I couldn't figure it out why the commands have
different outputs.  Here is what I was running:

**BEGIN**
use http://www.stata-press.com/data/r11/bplong, clear
*graph box bp, over(when) over(sex)
keep if sex==1 & when==2
summarize bp, detail
local u=r(p75)+(3/2)*(r(p75)-r(p25))
local l=r(p25)-(3/2)*(r(p75)-r(p25))
local l=max(`l',r(min))
local u=min(`u',r(max))

di `u'
di `l'

adjacent bp
lv bp
graph box bp, ylabel(#50, angle(horizontal))
*Notice how the upper limit should be 173 instead of 169.
**END**

The difference between the commands is not as simple as "it's 5% and
95%."  That looks true for the bp dataset, but it doesn't happen with
the city temperature dataset.  Here is more code to compare:

**BEGIN**
use http://www.stata-press.com/data/r11/bplong, clear
local x "if sex==1 & when==2 & bp~=."
summarize bp `x', detail
adjacent bp `x'
lv bp `x'

sysuse citytemp.dta, clear
summarize tempjuly, detail
adjacent tempjuly
lv tempjuly
**END**

Thanks in advance for any input!

Will Doerner

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index