Announcement

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

  • Why is my box plot not showing median line?

    Hi,

    I just made a box plot with
    Code:
    graph box grade_15, over(shock_c) over(cohort) name(box_grade_shock_c,replace)nooutsides asy
    and it produced plots (attached below) where the median line is not present for all but one of the boxes.
    Click image for larger version

Name:	29_box_grade_childshock_5_8.png
Views:	2
Size:	11.0 KB
ID:	1683532


    I would have shared example data but I tried the plot with the example data and it's not covering enough of the variation to produce all 4 boxes.

    I would appreciate it if some of you can suggest the possible reasons behind this so that I may check for those issues in my data.

    Please let me know if you would need more details.

    Thanks,

    Below is the distribution of the variable:

    Code:
    sum grade_15 if cohort==1,detail
    
                      grade attained at age 15
    -------------------------------------------------------------
          Percentiles      Smallest
     1%            4              0
     5%            6              1
    10%            7              2       Obs               1,822
    25%            8              2       Sum of Wgt.       1,822
    
    50%            9                      Mean           8.345225
                            Largest       Std. Dev.      1.393846
    75%            9             11
    90%           10             11       Variance       1.942808
    95%           10             12       Skewness      -1.308763
    99%           11             12       Kurtosis       6.291034
    Code:
    sum grade_15 if cohort==0,detail
    
                      grade attained at age 15
    -------------------------------------------------------------
          Percentiles      Smallest
     1%            2              0
     5%            5              1
    10%            6              1       Obs                 961
    25%            7              1       Sum of Wgt.         961
    
    50%            9                      Mean           8.150884
                            Largest       Std. Dev.      1.726968
    75%            9             11
    90%           10             11       Variance       2.982418
    95%           10             11       Skewness      -1.465881
    99%           10             12       Kurtosis       5.617447
    Attached Files

  • #2
    because you only show us 2 pieces of data and we really need to see all 4 that are shown in the box plot, I can't be sure, but my guess is that the median aligns with with the top or the bottom of the boxes - this is certainly true of the 2 summaries you show where, in each, the median is equal to the 75th percentile (which is the top of the boxes)

    Comment


    • #3
      I agree with Rich Goldstein. Indeed, box plots are in my view a poor choice for this kind of data: use histograms or quantile plots instead.

      Comment

      Working...
      X