Announcement

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

  • Manual box plot

    I have a dataset with stored point estimates and values for the upper and lower bounds of a 95% confidence interval across different US states. I want to generate a boxplot-type graph that plots the point estimate and confidence interval for each state on one graph, with states varying along the horizontal axis.

    My dataset looks like this:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str13 state float(att lci uci)
    "state1"       -.5132595  -.9173008 -.10921822
    "state2"      -.2470038  -.6503548   .1563472
    "state3"     -.4327654  -.8360896 -.02944127
    "state4"       -.919714 -1.3244256  -.5150024
    "state5"      .1781192 -.22636406  .58260244
    "state6"         -.5974504 -1.0022075 -.19269334
    "state7"  -.736816 -1.1416054  -.3320266
    "state8"      .0774485  -.3270281   .4819251
    end
    How do I generate such a plot?

    I tried the code below and it gets the information on the graph, but not in a very nice looking way.

    Code:
    graph box lci att uci, over(state)

  • #2
    Not quite sure what you actually want. It doesn't sound to me like boxplots are the solution. Try this:

    Code:
    encode state, gen(nstate)
    summ nstate,meanonly
    graph twoway (scatter att nstate, xlabel(`r(min)'(1)`r(max)', valuelabel)) (rcap lci uci nstate)

    Comment


    • #3
      That works great, thanks!

      Comment

      Working...
      X