Announcement

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

  • Dotplot or similar to draw dots and confidence interval whiskers of specified length: surely this can't be difficult!

    Dear all,

    There have been a few threads about problems with confidence intervals on graphs – I’m afraid I am in the midst of one.

    I am trying to make a dotplot, with the dots indicating regression coefficients; and whiskers above and below, confidence intervals. These data originate from a series of logistic regressions, individually exported into a table of the format:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str9 country float(coef ci_low ci_high)
    "country_a" .205 .158 .267
    "country_a" .081 .055  .12
    "country_b" .094 .083 .105
    "country_c" .105 .089 .124
    "country_c" .056 .036 .086
    end
    The graph I would like to plot is therefore something like:
    Code:
    dotplot coef, over(country)
    combined with:
    Code:
    twoway (rcap ci_low ci_high), over (country)
    But of course the syntax for the second is incorrect because string variables [country] can’t be used with -twoway- graphs.

    I feel this should be simple with a scatterplot or dotplot, but cannot find a way to simply specify the values of my dots and whiskers on a graph with a discrete x-axis variable [note - this is only a problem because I'm specifying CI values rather than calculating from a dataset - otherwise, -ciplot- would do this].

    I want to generate a graph which looks something like the version below (generated by changing the string values of my countries to numbers) but there is surely a simpler solution than re-labeling the axis?

    Thank you very much for any advice – I am using Stata v. 15.

    Josh.

    Code:
    twoway (rcap ci_low ci_high count) (scatter coef country)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	22.6 KB
ID:	1460607




  • #2
    Rather than -dotplot-, -twoway scatter- is more helpful. See this post: https://www.statalist.org/forums/for...ng-only-values
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Thank you very much for advice, Carole, and sorry for asking an answered question. I did this in the end by manually adjusting the x axis (anyway, I needed to "jitter" a lot and found the easiest way was to manipulate the axis.
      Have a good day.
      Josh.

      Comment

      Working...
      X