Announcement

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

  • Calculating the overlap of two histograms as percentage

    Is it possible to calculate the overlap of two histogram as a percentage? I am using a user-written package called "hist_overlay". However, any solution will be appreciated. It not specially looking to calculate the percentage using "hist_overlay".

    Example code:
    Code:
     
    sysuse auto
    ssc install hist_overlay
    hist_overlay mpg, over(foreign) fraction width(5) verbose name(hist1,replace
    Click image for larger version

Name:	hist1.jpg
Views:	1
Size:	12.4 KB
ID:	1748799



  • #2
    Sorry, but what is the percentage overlap? Does it depend on the histogram shown -- and so is dependent on bin width and origin -- or is it a characteristic of the raw data?

    Code:
    ranksum
    has an option to calculate a useful probability (If I recall correctly Rich Goldstein and I lobbied for its inclusion perhaps 25 years ago.)

    Code:
    . sysuse auto, clear 
    
    
    . ranksum mpg, by(foreign) porder
    
    Two-sample Wilcoxon rank-sum (Mann–Whitney) test
    
         foreign |      Obs    Rank sum    Expected
    -------------+---------------------------------
        Domestic |       52      1688.5        1950
         Foreign |       22      1086.5         825
    -------------+---------------------------------
        Combined |       74        2775        2775
    
    Unadjusted variance     7150.00
    Adjustment for ties      -36.95
                         ----------
    Adjusted variance       7113.05
    
    H0: mpg(foreign==Domestic) = mpg(foreign==Foreign)
             z = -3.101
    Prob > |z| = 0.0019
    Exact prob = 0.0016
    
    P{mpg(foreign==Domestic) > mpg(foreign==Foreign)} = 0.271

    Comment


    • #3
      I agree with Nick Cox 's recollection (and also point out that I had previously written such a routine published in STB 22 (1994)

      Comment

      Working...
      X