Announcement

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

  • Displaying mean values for groups on a line

    Hello Statalisters,

    I wish to display the means of a continuous variable for different values of a single group variable, so that the subgroups are ordered on the x axis on a descending/ascending order. I already used the command "grmeanby", which resulted in the following graph:

    Click image for larger version

Name:	Unbenannt.PNG
Views:	1
Size:	18.3 KB
ID:	1643831


    The command was: grmeanby subclass, summarize(dist)

    Basically, I want the means to be displayed on the x axis and the y axis to be gone, so that the names for the different values of "subclass" are aligned horizontally over a single line displaying the range for "dist". I would much appreciate it if somebody could help with this.
    Also, sorry for not posting my code in the right way, I am not using my own computer at the moment and do not want to install things because of this.

    Regards,

    Dominik


  • #2
    I can't follow all of your wording but for displaying group means I find it much easier to use graph dot -- where there is plenty of scope to display category text legibly and without risk of overlap.

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . graph dot mpg , over(rep78)
    
    . graph dot mpg , over(rep78) exclude0 scheme(s1color) linetype(line) lines(lc(gs12) lw(thin))
    You seem to have a twoway structure here with

    Ben Std Priv

    and

    Arb. Loh. Kap Kle

    which should indicate what comparisons are most interesting and should guide the design. further.

    Comment


    • #3
      Thank you, Nick.
      You are right, my group variable is a synthesis of two underlying dimensions and I also analyze them separately. With this descriptive graph, I want to show some underlying similarities and variations that come across when focusing on mixing those dimensions to generate "subclasses" as I built them with the accordingly named variable.
      Your solution works fine, but originally, I had something like this in mind:

      Click image for larger version

Name:	Unbenannt.PNG
Views:	1
Size:	15.2 KB
ID:	1643845

      For reference, this is from Wright 2000: Class Counts, page 227.

      Do you, by any chance, know how to plot a similar looking graph? I see it often in various books and always wondered how to do them in Stata.

      Comment


      • #4
        Please post a relevant data example. My bias is that the graph would be better rotated: it's giraffe graphics otherwise.

        Comment


        • #5
          So let´s take the automobile dataset you already used. Say, I want to have the mean trunk space (variable: trunk) for foreign and domestic cars (variable: foreign) depicted on a horizontal line like the one in the picture I have posted above. I hope this is sufficient as an example.
          You may be right that for many cases, it would be visually more appealing to not arrange the graph in this way, especially when dealing with long and specific labels like in my original case. But as I said, I am nevertheless interested in learning how to do such graphs in Stata, you may never know when it comes in handy.

          Thanks again for your quick help.

          Comment


          • #6
            I don't like the result, but these are some of the things you can do.

            Code:
            sysuse auto, clear
            decode foreign, gen(origin)
            egen mean = mean(trunk), by(foreign)
            gen where = 0
            scatter where mean, ms(none) mla(origin) mlabangle(90) mlabsize(*2.5) ytitle("") yscale(noline r(0 3)) yla(none) ysize(3) scheme(s1color) xtitle(Mean trunk space (ft{sup:3}), size(large)) xsc(titlegap(*3))

            Comment


            • #7
              Thank you very much, Nick!

              Comment

              Working...
              X