Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

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

From   "William M. Doerner" <>
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:

use, 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.

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:

use, 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

Thanks in advance for any input!

Will Doerner

*   For searches and help try:

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