Announcement

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

  • Box Whisker Plot Help

    Hello:

    I would like to make a box whisker plot where the y axis is age and the boxes are 2 different variables (ICD==1 and CUI==1). However, there is some overlap in icd=1 and cui=1, so I can't just combine these two variables into one without losing the original n's in each group. Does anyone have advice on how I can create this box plot? This may be a very simple issue, but I am quite a stata novice and have found this forum to be very helpful before.

    Thank you!

  • #2
    Code:
    graph box age if icd == 1, name(G1) subtitle(something sensible)
    graph box age if cui == 1, name(G2) subtitle(appropriate annotation)
    graph combine G1 G2, ycommon
    Not what you ask for, but cleaner logically and a nicer graph.

    Code:
    gen group = 1 if icd == 1 & cui != 1
    replace group = 2 if icd == 1 & cui == 1
    replace group = 3 if cui == 1 & icd != 1
    label def group 1 "icd only" 2 "both" 3 "cui only"
    label val group group
    graph box age, by(group)
    A dotplot or strip plot is usually more informative than a box plot, and you have space to show detail.

    I can't use your example data because you didn't give any. Nor am I clear on your variable names, so you may need to rewrite this code.
    Last edited by Nick Cox; 06 Nov 2019, 01:39.

    Comment


    • #3
      Thank you very much Nick Cox ! I actually installed the stripplot package and will be experimenting with both. You have been very helpful!

      Comment

      Working...
      X