Announcement

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

  • Scatterplot - Issues Limiting Y Axis and Labeling Data Points

    Hello all,

    I am attempting to plot a scatter plot (twoway in v18) which identifies the OR with associated 95% CI over 5 time points. I am running into two issues which I am struggling to resolve.

    Data is as follows:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str9 StudyID double(OR lCI uCI) long TimePoint
    "72 hours"  8.21 1.77 38.18 5
    "30 days"   5.07 2.32  7.82 3
    "2 months " 5.76 3.25  8.26 1
    "3 months " 5.42 2.75 10.69 2
    "6 months " 1.14  .68   1.9 4
    end
    label values TimePoint TimePoint
    label def TimePoint 1 "2 months", modify
    label def TimePoint 2 "3 months", modify
    label def TimePoint 3 "30 days", modify
    label def TimePoint 4 "6 months", modify
    label def TimePoint 5 "72 hours", modify
    Issue 1:
    As can be seen in the data, the 72 hours 95%CI is very large compared with 6 months (for example), making the output quite difficult to read.

    I have attempted to limit the Y axis using the following codes but the graph produced does not limit the axis. I have attempted to insert the force command at various points around the yscale and ylabel command without success either.

    Code:
    twoway (scatter OR TimePoint, ms(Oh) mc (gs5)) (rcap lCI uCI TimePoint, lc(gs5)), yscale (range(0, 15))
    Code:
    twoway (scatter OR TimePoint, ms(Oh) mc (gs5)) (rcap lCI uCI TimePoint, lc(gs5)), ylabel(0 1 5 10)
    Is there way to modify the y axis to either
    a) limit the y axis and have the 95%CI as an arrow at the uCI of 72 hours or
    b) modify the y axis so the 95%CI of the lower values is more easily viewed?

    Issue 2:
    When attempting to add labels to the point estimates of the OR using the mlabel command, I receive the following error:

    command mlabel is unrecognized
    r(199);

    I am not sure what to do about this.

    Thank you for your assistance,

    Richard Armour



  • #2
    I have attempted to limit the Y axis using the following codes but the graph produced does not limit the axis.
    Stata does not allow you to truncate the axis. If arbitrary truncation were allowed, I suspect it would be misused, leading to misleading graphics. However, you can expand the axis using -yscale(range())-. This thread may be helpful on how to proceed.


    When attempting to add labels to the point estimates of the OR using the mlabel command, I receive the following error:

    command mlabel is unrecognized
    r(199);
    -mlabel()- is an option of scatter, not a command. See

    Code:
    help scatter##marker_label_options

    Comment


    • #3
      As a further detail the time points in #1 are out of order as a result of a misguided encode.

      Comment


      • #4
        As often, using logarithmic scale is a good reaction to the occurrence of extremes. Also, why treat time point just as ordinal?

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str9 StudyID double(OR lCI uCI) long TimePoint Days
        "72 hours"  8.21 1.77 38.18 1  3
        "30 days"   5.07 2.32  7.82 2  30
        "2 months " 5.76 3.25  8.26 3  66
        "3 months " 5.42 2.75 10.69 4  91
        "6 months " 1.14  .68   1.9 5  183
        end
        label values TimePoint TimePoint
        label def TimePoint 3 "2 months", modify
        label def TimePoint 4 "3 months", modify
        label def TimePoint 2 "30 days", modify
        label def TimePoint 5 "6 months", modify
        label def TimePoint 1 "72 hours", modify
        
        scatter OR TimePoint || rcap lCI uCI TimePoint, ytitle(Odds ratio) yla(1 2 5 10 20 50) xla(1/5, valuelabel) ysc(log)

        Comment

        Working...
        X