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: histogram of tabular data


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: histogram of tabular data
Date   Tue, 30 Nov 2010 11:34:59 +0000

-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 
[email protected] 

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/


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