Announcement

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

  • How to Add Brackets to the Bar Chart to Show Statistical Significance in Stata?

    Hi,
    I wrote a code snippet below to create a vertical bar chart by severity of disciplinary action. Now, I want to add brackets to indicate there is a statistical difference in the mean value between the blue bar (mean=0.5184)and red bar (mean=0.4876) for students who received minor disciplinary actions. Although there is a thread that provided some hints at https://www.statalist.org/forums/for...l-significance, I still don't know how to do this in Stata.
    clear
    input byte race outcome infraction1 infraction2 infraction3
    1 1 .7048 .5184 .3047
    2 1 .7004 .4876 .1779
    3 1 .7232 .5578 .3354
    4 1 .7284 .5508 .2053
    1 2 .2429 .3565 .4077
    2 2 .2461 .3705 .3543
    3 2 .2297 .3363 .4086
    4 2 .2258 .3401 .3744
    1 3 .0522 .1251 .2875
    2 3 .0535 .1419 .4687
    3 3 .0471 .1059 .2561
    4 3 .0457 .1091 .4204
    end

    grstyle init

    label define race_label 1 "Black" 2 "Hispanic" 3 "White" 4 "Other"
    label values race race_label
    label define outcome_label 1 "Low" 2 "Medium" 3 "High"
    label values outcome outcome_label

    graph bar (mean) infraction2, over(race, label(angle(45) format(%9.0g))) over(outcome) asyvars blabel(total) ytitle("Predicted Probability of Disciplinary Action") title ("Medium Infractions")
    graph export "Medium Infractions.gph", replace

    Thank you for your help!
    Click image for larger version

Name:	123.JPG
Views:	2
Size:	144.0 KB
ID:	1714560

    Last edited by smith Jason; 23 May 2023, 05:45.

  • #2
    The cited thread is explicit that you can't do this (at any rate easily) with graph bar. You are much better off starting with twoway bar.

    Brackets such as I am guessing you want here need to be drawn with a specification for each line segment. It's very much coding ad hoc.

    I don't see any basis for declaring those means significantly different (at some level) -- or understand why yet bigger differences are not significant if that one is.

    If you think some of your bars are red and some green, you should be worrying that some of your readers can't distinguish those colours;

    Comment


    • #3
      Thank you for your help. I have performed a statistical test and confirmed there is a significant difference between 0.5184 and 0.4876, so I want to annotate it with brackets.
      Also, I made a typo earlier, the color I mentioned as green should be blue. Do you understand now?

      Comment


      • #4
        Naturally a statement about significance comes out of a statistical test. That doesn't give anyone here extra information, nor does it answer my query about larger differences.

        I see white people represented in a kind of green and black people in blue, and Hispanic in a kind of red, so I still guess you can do better on colours, although that is at worst a secondary problem.

        On your main question I don''t think we can improve on Andrew Musau's strategy in the linked thread.

        Comment


        • #5
          I don't care colors at all. What I want is to how to present significant differences between groups. I don't necessarily to use brackets to achieve this goal.
          Thank you for your assistance just now.

          Comment


          • #6
            The thread is closed because the solution is found at https://www.statalist.org/forums/for...roups-in-stata




            Comment


            • #7
              There is no formal closure of threads.

              What you mean, and what is a very good idea, is that you suggest that people interested in this thread follow the linked thread. So thanks for doing that.

              But nothing stops anybody posting further posts if they prefer. And starting a thread doesn't convey ownership of that thread.

              Comment

              Working...
              X