Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: option problems with byhist (interlaced histogram)

From   Nick Cox <>
To   "''" <>
Subject   RE: st: option problems with byhist (interlaced histogram)
Date   Wed, 30 Nov 2011 11:45:05 +0000

I am easier than Maarten about histograms for categorical variables, not least because much depends on the exact definition of histogram, which broadly might include bar charts of absolute or relative frequencies too. 

But if alternatives may be mentioned 

1. Please note also 

SJ-8-1  gr0031  . . . . . . . . . . . Speaking Stata: Spineplots and their kin
        (help spineplot if installed) . . . . . . . . . . . . . . .  N. J. Cox
        Q1/08   SJ 8(1):105--121
        discusses spineplots (mosaic plots), a type of bar chart for
        showing frequencies, proportions, or percentages of cross-
        classified categorical variables

2. I would add my -tabplot- (SSC). 

Spineplots, perhaps more widely called mosaic plots, have many passionate proponents and can be extremely effective. But with many categories and/or some categories with small frequencies they can just become complicated and confusing. -tabplot- can be used to draw two-way bar charts (_not_ to be confused with -twoway bar- charts!) and will work reasonably at showing small frequencies too. 


Maarten Buis

On Tue, Nov 29, 2011 at 7:38 PM, Patricia Biedermann wrote:
> I want to produce an interlaced histogram with two variables:
> 1. Variable: 1= Case; 2=Control (binary)
> 2. Varialbe: 1=Agriculture, 2=Employment; 3=Business, and so on... (categorical)
> I tried this command:
> byhist occup, by(casecontrol) percent tw1(color(blue) lwidth(3)) tw2(color(red) lwidth(3))
> (the important thing is that it has to be ONE GRAPH!)

A histogram is the wrong graph for such variables as your second
variable is not even an ordinal variable. For two categorical
variables I would look at Nick Cox's -spineplot-, which you can get by
typing in Stata -ssc install spineplot-.

*   For searches and help try:

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