Announcement

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

  • Changing the scale histogram

    Hello all
    I created a histogram

    histogram propensity_score, freq by($treatment, col(1))) name(hist1, replace)

    I obtained the following histogram.

    How do I change the scale for the bottom graph to make the bar charts more apparent? I have a dataset of 600,000



    Click image for larger version

Name:	image.PNG
Views:	1
Size:	18.8 KB
ID:	1710720

  • #2
    Please show us the results of

    Code:
    bysort $treatment: su propensity_score, detail

    Comment


    • #3
      Click image for larger version

Name:	hip.PNG
Views:	1
Size:	257.3 KB
ID:	1710735


      This is the best I can do as the remove platform does not have internet Click image for larger version

Name:	knee.PNG
Views:	2
Size:	263.5 KB
ID:	1710737
      Attached Files

      Comment


      • #4
        You've confirmed that all values are positive, so why not use logarithmic scale? An alternative is to use a square root scale for frequency, a so-called rootogram. .

        This script shows an example.


        Code:
        clear
        set obs 1000
        set seed 314159265
        gen problem = exp(rnormal(0, 1.5))
        su problem, detail
        twoway__histogram_gen problem, start(0) width(2) gen(h x) freq 
        twoway bar h x, barw(2) name(G1, replace)
        su h  
        gen rt_h = sqrt(h)
        forval j = 0(5)25 { 
            local show = `j'^2 
            local call `call' `j' "`show'"
        }
        twoway bar rt_h x, barw(2) yla(`call') ytitle(Frequency (root scale)) name(G2, replace)

        Comment


        • #5

          I know you're busy but, would kindly explain what is happening in the red text please? clear set obs 1000 set seed 314159265 gen problem = exp(rnormal(0, 1.5)) su problem, detail twoway__histogram_gen problem, start(0) width(2) gen(h x) freq twoway bar h x, barw(2) name(G1, replace) su h gen rt_h = sqrt(h) //can you explain what is happening here , here you are square rooting forval j = 0(5)25 { //I don't follow what's happening here local show = `j'^2 local call `call' `j' "`show'" } twoway bar rt_h x, barw(2) yla(`call') ytitle(Frequency (root scale)) name(G2, replace)

          Comment


          • #6
            Square root scale for frequencies. See


            Code:
            help spikeplot
            https://journals.sagepub.com/doi/pdf...867X1201200210

            https://journals.sagepub.com/doi/ful...6867X211045583

            Comment

            Working...
            X