Hi,
I have a normal distribution with one additional mass-point. I would expect the fraction of the observations at the masspoint to be 0.33 (or 0.37). However, when I combine the normal distribution and the masspoint in one graph, it seems like the fraction at the masspoint is 1.0. How can I program it such that the reported fraction on the y-axis reports correctly, i.e. is based on the whole sample, not based on the two sub-samples separately?
Best,
Oivind A. Nilsen
drawnorm y, n(10000) means(1.25) sds(2.0 ) seed (123455) clear
***
* expand the dataset with 5000 observations,
* and make a masspoint at y = 1.25
***
expand 2
drop if _n >= 15001
replace y = 1.25 if _n > 10000
gen byte y_exact_1point25 = (y>=1.24999 & y<=1.25001)
gen y_rnd_025 = round(y, 0.25)
tabu y_rnd y_exact_1point25
twoway ///
(hist y_rnd_025 if y_exact==0, frac width(0.5) xlabel(-10(2)10.0) color(gs10)) ///
(hist y_rnd_025 if y_exact==1, frac width(0.5) color(black%50) start(1.0) ), ///
legend(order(1 "Non-masspoint" 2 "Masspoint" ))
***
* for comparision
***
hist y_rnd_025 , frac width(0.5) xlabel(-10(2)10.0)
tabu y_rnd y_exact_1point25 if y_rnd_025 == 1.25
dis 5545/15000
0 Response to Combined histograms; fraction based on the whole sample, not two sub-samples
Post a Comment