Announcement

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

  • Bimodal distribution in Histogram using STATA

    Dear Stata users,

    I have a public spending data of a sample size of 483 counties. Among these counties, 211 counties did not receive any public funding i.e. 211 zero observations. The rest 272 counties received some form of funding and the max is 968.5986. I want to look using a histogram to what extent this 0 spending occurs and whether spending is distributed uniformly after zero or there exists a substantial bimodality in spending. Can anyone tell me the exact command to draw a histogram in this case? I want the bin showing the frequency of 0s and then bin ranged from 1-50, 51-100,101-150,151-200 and >200.

    Thanks and regards,
    Azreen Karim.

  • #2
    You should create your own binning variable and use graph bar or twoway bar

    Comment


    • #3
      Thanks Nick. Can you suggest how to write down the command in STATA? I am quite new in drawing histogram in specific cases.

      Cheers,
      Azreen.

      Comment


      • #4
        I can't advise on STATA, a name not used for 30 years or more by the company (http://www.statalist.org/forums/help#spelling)

        In Stata you could do something like this

        Code:
         
        gen binned = myvar 
        replace binned = 1 if myvar > 0 & myvar <= 50
        replace binned = 2 if myvar > 50 & myvar <= 100
        replace binned = 3 if myvar > 100 & myvar <= 150 
        replace binned = 4 if myvar > 150 & myvar <= 200 
        replace binned = 5 if myvar > 200 & myvar < . 
        
        label def binned 0 "0" 1 "<=50" 2 "<=100" 3 "<=150" 4 "<=200" 5 ">200"
        label val binned binned 
        
        bysort binned: gen freq = _N 
        twoway bar freq binned, xla(0/5, valuelabel)
        Note that as your variable takes non-integer values, your bin limits might miss some values.

        But I wouldn't use such a graph myself. You can't tell whether it misses important fine structure. I would start with

        Code:
        spikeplot myvar, round(1)

        Comment


        • #5
          Thanks a lot, Nick. I think it worked really well.

          Cheers,
          Azreen.

          Comment

          Working...
          X