I have a question regarding the twoway histogram gen, which is a subroutine for histogram in Stata. My dataset looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double X .3174416686101092 .751236919860475 .9301581439614081 .9820105769895106 .05727364951864301 .8445030492980504 .6804149308376887 .49954514377019377 .29520458027947755 .29811460380267646 .9275025219694819 .9724850263841481 .9791286583776323 .6510749770783657 .1544199045494288 .1932478934156534 .9379135269435722 .25260398443521526 .2222642682396161 .8124093280647008 .4401466116856465 .7638075062117162 .15021975908220003 .0937371505709939 .17454901704707335 .2103111345184566 .49958168883851733 .2564613859692991 .9772037154981096 .0398732567225077 .7846374970730708 .7151596743181867 .739565706022628 .4152583301532447 .4988744869281709 .4320066558978679 .17702199740780342 .4987809721003545 .29142269873865323 .25626641845606346 .6021471915763306 .6916335521065502 .47613840036785515 .11688861092340357 .6401968244992694 .4711574665061757 .9999560785889613 .34359191510064296 .23060671159102006 .07129011164674397 .030658100708024022 .16435660875766872 .22118887204911686 .374742576916307 .8880812208669601 .15741030998464273 .4998514554127955 .6143946312021679 .3989133106410578 .14326924938133404 .863692902725487 .7324743741082095 .7132996777874436 .25256755815771365 .9506983775669362 .6863749389688217 .20915823802416403 .19167090955192637 .6498482411173856 .12624360062478165 .10837015624931981 .9022921278552039 .2658067777154678 .07934113731531843 .30423409149573194 .6678730601800089 .630846307280887 .08057434608286282 .3681894078019108 .9211227616075107 .8149965326776698 .25662792431800874 .39539171159721415 .6781711504668789 .004588136930979945 .4415167267300685 .09621249458583389 .49895380633653985 .3928292169449788 .9863350797863923 .6575152978773136 .5004026390278045 .7630594953495181 .8000504114242307 .9085240103531792 .30928709432157325 .16739888912955703 .8547703595432454 .27755997414302636 .19589573622430317 end
Array
there is 0 frequency for X with values between 0.5 and 0.6 (approximately). When I run the following code.
Code:
twoway__histogram_gen X, bin(100) frequency gen(h x) display
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double X float(x h) .3174416686101092 .0033731484 96 .751236919860475 .013391868 111 .9301581439614081 .023410587 95 .9820105769895106 .033429306 88 .05727364951864301 .04344803 105 .8445030492980504 .05346674 125 .6804149308376887 .063485466 107 .49954514377019377 .07350419 95 .29520458027947755 .0835229 99 .29811460380267646 .09354162 114 .9275025219694819 .10356034 86 .9724850263841481 .11357906 110 .9791286583776323 .12359778 89 .6510749770783657 .1336165 110 .1544199045494288 .14363521 107 .1932478934156534 .15365393 96 .9379135269435722 .16367266 96 .25260398443521526 .17369138 91 .2222642682396161 .1837101 99 .8124093280647008 .1937288 98 .4401466116856465 .20374754 106 .7638075062117162 .21376626 104 .15021975908220003 .22378497 106 .0937371505709939 .2338037 105 .17454901704707335 .2438224 114 .2103111345184566 .25384113 117 .49958168883851733 .26385987 100 .2564613859692991 .27387857 93 .9772037154981096 .28389728 93 .0398732567225077 .29391602 97 .7846374970730708 .3039347 101 .7151596743181867 .3139535 110 .739565706022628 .3239722 100 .4152583301532447 .3339909 86 .4988744869281709 .3440096 97 .4320066558978679 .3540283 103 .17702199740780342 .36404705 91 .4987809721003545 .3740658 90 .29142269873865323 .3840845 98 .25626641845606346 .3941032 105 .6021471915763306 .4041219 95 .6916335521065502 .4141406 96 .47613840036785515 .4241594 96 .11688861092340357 .4341781 97 .6401968244992694 .4441968 100 .4711574665061757 .4542155 102 .9999560785889613 .4642342 97 .34359191510064296 .474253 106 .23060671159102006 .4842717 101 .07129011164674397 .4942904 345 .030658100708024022 .5043091 798 .16435660875766872 .5944776 5 .22118887204911686 .6044963 100 .374742576916307 .614515 97 .8880812208669601 .6245338 95 .15741030998464273 .6345525 92 .4998514554127955 .6445712 107 .6143946312021679 .6545899 110 .3989133106410578 .6646087 100 .14326924938133404 .6746274 88 .863692902725487 .6846461 112 .7324743741082095 .6946648 109 .7132996777874436 .7046835 96 .25256755815771365 .7147022 102 .9506983775669362 .724721 84 .6863749389688217 .7347397 96 .20915823802416403 .7447584 88 .19167090955192637 .7547771 94 .6498482411173856 .7647958 101 .12624360062478165 .7748145 91 .10837015624931981 .7848333 102 .9022921278552039 .794852 99 .2658067777154678 .8048707 98 .07934113731531843 .8148894 110 .30423409149573194 .8249081 90 .6678730601800089 .8349268 86 .630846307280887 .8449455 95 .08057434608286282 .8549643 91 .3681894078019108 .864983 87 .9211227616075107 .8750017 111 .8149965326776698 .8850204 93 .25662792431800874 .8950392 92 .39539171159721415 .9050579 104 .6781711504668789 .9150766 92 .004588136930979945 .9250953 103 .4415167267300685 .935114 91 .09621249458583389 .9451328 80 .49895380633653985 .9551515 105 .3928292169449788 .9651702 100 .9863350797863923 .9751889 102 .6575152978773136 .9852077 130 .5004026390278045 .9952264 106 .7630594953495181 . . .8000504114242307 . . .9085240103531792 . . .30928709432157325 . . .16739888912955703 . . .8547703595432454 . . .27755997414302636 . . .19589573622430317 . . end
Notice that the bin values (variable x) jump from .5043091 to .5944776, since there are no X values that fall into those bins.
I would like to fill this void by entering the bin values (0.5043091+width after 0.5043091, and so on) and enter 0 for frequency (variable h), instead of leaving it like this. I am not sure how to proceed in a good way. Any help would be much appreciated. Also, let me know if anything is not clear, as I am still pretty inexperienced at posting questions on Statalists. Thank you!
0 Response to twoway histogram gen with 0 frequency
Post a Comment