Announcement

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

  • Graph line or point of mean of different variables

    Hi guys,

    I have several variables, i.e. int_0_10, int_10_20, int_20_30, and so on.

    I want a chart in which one dot represents the mean of int_0_10, the next dot the mean of int_10_20, etc.

    I know how to do it for bars (graph bar (mean) int_*) but actually instead of the whole bar I would prefer just a dot, for which I can also show the i.c. In the x-axis, I should have the name of each of the variables.

    Any idea? Thanks

  • #2
    Code:
    help graph dot

    Comment


    • #3
      Thanks Nick, I checked that already but I'm unable to produce the type of chart that I want. Actually I'm attaching an example made in Excel to make the idea clearer. Clearly here the marker is a triangle, but it can be something different.

      Thanks a lot
      Attached Files

      Comment


      • #4
        There is an undocumented vertical option to graph dot.

        Comment


        • #5
          Here is a demonstration script you can run:

          Code:
          . webuse nlswork , clear
          (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
          
          . gen age_bin = 10 * ceil(age/10)
          (24 missing values generated)
          
          . label var age_bin "Age group, upper limits" 
          
          . graph dot (mean) ln_wage, over(age_bin) vertical

          Comment


          • #6
            indeed, that seems to produce a graph similar to the one I attached. However the difference (and the reason why I'm being unable to reproduce it with my data) is that in my data each dot (or bar if it were a bar graph) is one variable.

            So for example when I do
            Code:
            graph dot (mean) interruptions_*, vertical
            I have one single vertical line, with many dots on it. Thanks!

            Comment


            • #7
              Use the ascategory option. This is documented.

              Comment


              • #8
                That said, why show just three means, when any such graph allows more detail to be shown about the data?

                Here is one of many possibilities. The example shows one outcome and five groups, but there is syntax for three related outcomes to be shown side by side.

                stripplot is from SSC.

                Code:
                sysuse auto, clear
                stripplot mpg , over(rep78) centre vertical cumul cumprob refline
                Click image for larger version

Name:	mpg.png
Views:	1
Size:	34.7 KB
ID:	1716747

                Here the means are shown by horizontal lines. The quantile display is informative about group size, variability, skewness, ties, gaps and outliers to the extent that they are notable or present. (It's germane that the mean is the integral of the quantile function x = Q(p) over its support.)

                Comment

                Working...
                X