histogram of tabular data

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

histogram of tabular data

Hillel Alpert
Could anyone advise if Stata can be used to generate a histogram showing multiple bars per category of the variable being plotted? Each bar would be the frequency or percentage of the variable for a subcategory of a second variable.

For example, the histogram would show the numbers of boys and girls in each of ten classrooms, where the bars for boys and girls of each classroom are adjacent to one another.

Hillel

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: histogram of tabular data

Sergiy Radyakin
On Mon, Nov 29, 2010 at 5:36 PM, Hillel Alpert <[hidden email]> wrote:
> Could anyone advise if Stata can be used to generate a histogram showing multiple bars per category of the variable being plotted? Each bar would be the frequency or percentage of the variable for a subcategory of a second variable.
>
> For example, the histogram would show the numbers of boys and girls in each of ten classrooms, where the bars for boys and girls of each classroom are adjacent to one another.
>
> Hillel


Try the following example:
sysuse auto, clear
graph bar  turn gear_ratio, over(rep78)

in your data replace "turn" with boys, "gear_ratio" with girls and
"rep78" with classroom.

Refer to M.Mitchell's book for graphical questions:

http://books.google.com/books?id=D0aYj9TDjdEC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false

See section 5.2 in particular.

Best, Sergiy Radyakin




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

*
*   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/
Reply | Threaded
Open this post in threaded view
|

RE: histogram of tabular data

David Radwin-2
In reply to this post by Hillel Alpert
I'm not sure if this is what you mean, but you might try -bihist- for two
groups and -byhist- for more than two groups. Both programs are written by
Austin Nichols and available from SSC.

David
--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [hidden email] [mailto:owner-
> [hidden email]] On Behalf Of Hillel Alpert
> Sent: Monday, November 29, 2010 2:37 PM
> To: [hidden email]
> Subject: st: histogram of tabular data
>
> Could anyone advise if Stata can be used to generate a histogram showing
> multiple bars per category of the variable being plotted? Each bar would
> be the frequency or percentage of the variable for a subcategory of a
> second variable.
>
> For example, the histogram would show the numbers of boys and girls in
> each of ten classrooms, where the bars for boys and girls of each
> classroom are adjacent to one another.
>
> Hillel

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: histogram of tabular data

Phil Clayton
In reply to this post by Hillel Alpert
Sometimes I generate a "dummy" frequency variable equal to 1 in order to generate a frequency plot:

gen byte freq=1
graph bar (sum) freq, over(sex) over(classroom) asyvars

Phil

On 30/11/2010, at 9:36 AM, Hillel Alpert wrote:

> Could anyone advise if Stata can be used to generate a histogram showing multiple bars per category of the variable being plotted? Each bar would be the frequency or percentage of the variable for a subcategory of a second variable.
>
> For example, the histogram would show the numbers of boys and girls in each of ten classrooms, where the bars for boys and girls of each classroom are adjacent to one another.
>
> Hillel
>
> *
> *   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/


*
*   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/
Reply | Threaded
Open this post in threaded view
|

RE: histogram of tabular data

Nick Cox
-catplot- from SSC does this.

sysuse auto, clear
catplot foreign rep78

Hillel's analogue would be something like

catplot gender classroom

The main trick behind -catplot- is precisely that explained by Phil Clayton, although there are other tricks too, including handles for percent calculations. There was some discussion within

SJ-4-2  gr0004  .  Speaking Stata: Graphing categorical and compositional data
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q2/04   SJ 4(2):190--215                                 (no commands)
        discusses graphical possibilities for categorical and
        compositional data

(although please note that the syntax was changed in -catplot- 2.0.0 from SSC),
and there are examples at

http://www.ats.ucla.edu/stat/stata/faq/graph/njcplot.htm

Nick
[hidden email]

P.S. Sergiy's example is strictly not a histogram, but a bar chart showing means.

Phil Clayton
============

Sometimes I generate a "dummy" frequency variable equal to 1 in order to generate a frequency plot:

gen byte freq=1
graph bar (sum) freq, over(sex) over(classroom) asyvars

David Radwin
============

I'm not sure if this is what you mean, but you might try -bihist- for two groups and -byhist- for more than two groups. Both programs are written by Austin Nichols and available from SSC.

Sergiy Radyakin
===============

Try the following example:
sysuse auto, clear
graph bar  turn gear_ratio, over(rep78)

in your data replace "turn" with boys, "gear_ratio" with girls and "rep78" with classroom.

Refer to M.Mitchell's book for graphical questions:

http://books.google.com/books?id=D0aYj9TDjdEC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false

See section 5.2 in particular.

Hillel Alpert
==============

Could anyone advise if Stata can be used to generate a histogram showing multiple bars per category of the variable being plotted? Each bar would be the frequency or percentage of the variable for a subcategory of a second variable.
 
For example, the histogram would show the numbers of boys and girls in each of ten classrooms, where the bars for boys and girls of each classroom are adjacent to one another.

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