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

st: RE: Re: st histogram with multiple variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: st histogram with multiple variables
Date   Sun, 8 Dec 2002 18:41:19 -0000

Eric Uslaner
>
> This may be a very simple problem, but I have spent a considerable
> amount of time with the manuals and using findit trying to solve the
> problem, without success.  I have downloaded several
> programs from SSC and still don't have what I want.
>
> I have a set of ratio variables (probabilities derived from Nick
> Winter's oprobit) and a three-category ordinal variable.  I
> want to plot
> these probabilities (P1, P2, P3, and P4) against the
> ordinal variable
> (call it X) in the following manner:
>
> Graph 1 would have a bar chart of the values for P1, P2,
> P3, and P4 for
> the first category of X; Graph 2 would do the same for the second
> category of X3, and Graph 3 would do the same for the third
> category of
> X and then I'd like to line them up side by side.  Any help would be
> appreciated.

The task here is in essence a bar chart for 3 X 4 numbers.
I assert that for display a horizontal format is
usually easier to read than a vertical one. -hbar-
from SSC is then pertinent.

The following structure can be elaborated,
given X, Y and P:

. gen str1 legend = string(Y)

. replace legend = string(X) + "   " + legend if X != X[_n-1]

. l X Y legend

            X         Y              legend
  1.        1         1               1   1
  2.        1         2                   2
  3.        1         3                   3
  4.        1         4                   4
  5.        2         1               2   1
  6.        2         2                   2
  7.        2         3                   3
  8.        2         4                   4
  9.        3         1               3   1
 10.        3         2                   2
 11.        3         3                   3
 12.        3         4                   4

. hbar P , legend(legend) gap(4 8)  border

Nick
[email protected]

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