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]

Re: st: nested groups for over (or by) in box graph


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: nested groups for over (or by) in box graph
Date   Fri, 6 Dec 2013 15:46:35 +0000

-graph combine- on different graphs will do this in principle, but in
practice there will be more scaffolding than you might want.

Rather, a better approach is to fool Stata into seeing the data as you
want it to see them. That means in practice changing the data
temporarily.

sysuse auto, clear
gen order = _n
expand 3
bysort order : gen which = _n
drop if which == 1 & price > 5000
drop if which == 2 & price > 10000
label def which 1 "<= $5000" 2 "<= $10000" 3 "all"
label val which which
graph box mpg, over(which) over(foreign)

For a similar trick, see
http://stackoverflow.com/questions/14342210/in-stata-how-can-i-combine-box-plots-of-different-widths

Nick
[email protected]


On 6 December 2013 15:17, Ben Hoen <[email protected]> wrote:
> Hi all,
>
> I have been toying with this and have not been able to solve it.  Hopefully
> it will require a simple solution
>
> I would like to use nested groups in an over option with a box graph.
>
> Here is an example:
>
> sysuse auto, clear
> egen pricegroup=cut(price), at(0, 5000,10000, 16000) // this creates
> discrete groups.  Not what I want but I will use this for the example.
> graph box mpg, over(pricegroup) over(foreign)
>
> * ideally I could create nested groups, like the following, and use them
> somehow to produce a similar box graph.
> g pricegroup1=(price<5000)
> g pricegroup2=(price<10000)
> g pricegroup3=(price<16000) //i.e. all cases
>
> * I know this next command will not work but this is what I am imagining
> might be possible
> graph box mpg, over(pricegroup_*) over(foreign)
>
> Any ideas?
>
> As always, thanks in advance,
>
> Ben
>
> Ben Hoen
> Staff Research Associate
> Lawrence Berkeley National Laboratory
> Office: 845-758-1896
> Cell: 718-812-7589
> [email protected]
> http://emp.lbl.gov/staff/ben-hoen
>
> Visit our publications at:
> http://emp.lbl.gov/reports/re
>
> Sign up for our email list to receive publication notifications at:
> https://spreadsheets.google.com/a/lbl.gov/spreadsheet/viewform?formkey=dGlFS
> 1U1NFlUNzQ1TlBHSzY2VGZuN1E6MQ
>
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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