Announcement

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

  • How to add an overall box plot to an "over" box plot?

    Hi Statalisters

    I am running the following type of command:
    graph box outcome, over(group)

    I have 12 different values within group, and so 12 boxplots appear on the graph.

    I would like to add a 13th boxplot, labelled "all", which contains a boxplot of all observations of outcome.

    How would l do this?

    Thankyou

    Karin

  • #2
    This kind of problem is discussed at length in in the current Stata Journal. See http://www.stata-journal.com/article...article=gr0058 If you don't have access to a subscribed copy, or are too poor or mean to spend USD 8.75 on an excellent little article, the gist of the idea is accessible at http://www.stata.com/statalist/archi.../msg01102.html

    (This paper is also relevant and accessible to all. http://www.stata-journal.com/sjpdf.h...iclenum=gr0045)

    Here is some code any way. It's kind of kick yourself; it was obvious all along.

    Code:
     
    sysuse auto, clear
    set scheme s1color 
    preserve
    local N = _N
    expand 2
    gen byte new = _n > `N'
    replace rep78 = 6 if new
    label def rep78 6 "all"
    label val rep78 rep78
    
    graph hbox mpg, over(rep78) nofill ytitle("MPG, by Repair Record")



    Attached Files

    Comment


    • #3
      As you say "Do'h!" - it's obvious now, though I would never have thought of it myself. Many thanks!

      Comment


      • #4
        Otherwise known as Simpsons' paradox [sic].

        Comment

        Working...
        X