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
Related Posts with Combined histograms; fraction based on the whole sample, not two sub-samples
xtabond2Hello everyone, I am currently working with dynamic panel data. The model I want to estimate using …
Stata technique for CPPMLHello, does anyone have practical experience in Stata with Constrained Poisson Pseudo Maximum Likel…
Question about stsplitHi all, I would like to write a command to stsplit a dataset thus: Code: stsplit newvar, at(date…
How to sum variable by year for specific group idThe original dataset has the following structure: group_id | year | varx 1 1998 5 1 1998 5 1 1999 2…
Multilevel model (binary outcome) with spatial weight matrix (not panel data)Hi Stata forum users, Does stata have any option to incorporate a spatial weight matrix with melogi…
Subscribe to:
Post Comments (Atom)
0 Response to Combined histograms; fraction based on the whole sample, not two sub-samples
Post a Comment