Statalist


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

RE: st: Bar graph ordered by values of yvar


From   David Radwin <radwin@berkeley.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Bar graph ordered by values of yvar
Date   Fri, 14 Mar 2008 09:26:32 -0700

Nick,

Thank you for the explanation. I was afraid that might be the case.

David

At 11:53 PM +0000 3/13/08, Nick Cox wrote:
I've devoted some time to trying to automate the kind of
manipulations needed here without being clear whether the emphasis
should
on changing the data structure or doing the graphics. (Short answer: You

need some of both.)

Absent a simple solution that I know of:

I'd -collapse- the data -- just as -graph bar- does, temporarily --
and then fool around in the editor to produce a dataset that was
amenable to
-textbarplot- fron SSC.

That may not be practical for your real example, especially if you want
to do this repeatedly or for a rather larger dataset.

Nick

David Radwin

Friedrich,

Thank you for the suggestion. This graph is adequate, but I would
like greater control over the spacing between bars as is typically
done using the bargap or gap options. The reason would be to
emphasize the comparison between college grads and non-college grads.

Is there a way to make the gaps between bars 2 and 3 and between bars
4 and 5 larger than the gaps between bars 1 and 2, bars 3 and 4, and
bars 5 and 6?

At 7:09 PM -0400 3/13/08, Friedrich Huebler wrote:

Here is one solution.

. sysuse nlsw88, clear
. foreach var of varlist hours wage tenure {
     sum `var' if collgrad == 0
     gen ncg`var' = r(mean)
     sum `var' if collgrad == 1
     gen cg`var' = r(mean)
   }
. keep in 1
. graph hbar ncghours - cgtenure, ascategory

On Thu, Mar 13, 2008 at 6:34 PM, David Radwin <radwin@berkeley.edu>
wrote:

   I have a question analogous to one I asked last year that was
   graciously answered by Nick Cox
   (http://www.stata.com/statalist/archive/2007-08/msg00934.html).

   Rather than pose the question outright, I will illustrate with a
   example comparing college graduates with non-college graduates:

   . sysuse nlsw88, clear
   . graph hbar (mean) hours wage tenure, over(collgrad) showyvars

   give you a graph with the bars in the order, from top to bottom,
of:
   1. mean hours for non-college grads
   2. mean wage for non-college grads
   3. mean tenure for non-college grads
   4. mean hours for college grads
   5. mean wage for college grads
   6. mean tenure for college grads

   But what I actually want is

   1. mean hours for non-college grads
   2. mean hours for college grads
   3. mean wage for non-college grads
   4. mean wage for college grads
   5. mean tenure for non-college grads
   6. mean tenure for college grads

   Is there a option, user-written program, or set of commands that
   would produce this graph?

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

--
David Radwin, Principal Analyst // radwin@berkeley.edu
Office of Student Research, University of California, Berkeley
2223 Fulton St # 2032, Berkeley, CA 94720-2032
Tel. 510.642.2097; Fax 510.642.2894
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index