Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • back to back histogram

    Hi,

    Here is a sample of my data
    Code:
    input int x int  y
    x y
    3 1
    1 1
    2 0
    3 1
    2 1
    3 0
    3 1
    1 1
    2 0
    4 0
    4 1
    3 1
    2 1
    4 1
    3 0
    1 0
    4 0
    4 0
    4 1
    2 0
    3 1
    4 1
    3 0
    4 0
    end
    x is a 4 point likert scale and y is a dummy variable. I want to show the frequency of x in each of likert points for each category of y in a way that I have a vertical line that has 4 categories on each side, on its left it shows the frequency distribution of x for y=0 and on its right side distribution of x when y=1.

    attached is a picture I found online similar to what I am trying to do, if that helps at all.
    I really appreciate your help.
    Click image for larger version

Name:	backtobackhist.jpg
Views:	3
Size:	49.1 KB
ID:	1318535

    Attached Files
    Last edited by Monica Muller; 30 Nov 2015, 23:41.

  • #2
    See the detailed example for a population pyramid in the manual entry [G] graph twoway bar.

    Naturally there are many other ways to do it. I tend to prefer a hybrid graph-table such as is given by tabplot (SSC).

    Code:
    set scheme s1color
    tabplot x y, horizontal aspect(1) showval bfcolor(none) yasis
    Click image for larger version

Name:	tabplot4.png
Views:	1
Size:	9.7 KB
ID:	1318546


    For yet other possibilities, see e.g. http://www.stata-journal.com/sjpdf.h...iclenum=gr0004
    Last edited by Nick Cox; 01 Dec 2015, 01:59.

    Comment


    • #3
      Population pyramids are a traditional kind of plot in many fields. I guess I encountered them about age 13 in geography texts. For the usual application of comparing males and females, ratios of numbers are often (naturally not always) near 1 and small differences e.g. 98 males versus 100 females compared with 102, are often of great interest. It seems elementary that the pyramid can make it difficult to see small contrasts because the mental act required is heaving up one bar and laying it against another, or a lot of busy work comparing bar lengths using the axis labels. But I've not seen that comment often in the literature. Superimposing the bars, or moving to superimposed line plots, would seem more efficient.

      Comment


      • #4
        Thank you so very much Nick both for the plot command and the information. It's particularly helpful to me because English is not my first language and I usually don't know the correct names of the graphs like population pyramids. I really appreciate the helpful information. Have a wonderful day.

        Comment

        Working...
        X