[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: converting densities into values
I have a probably very simple question:
I want to demonstrate a book example with two variables:
the n range is 0 to 3000;
the first variable has mean 1200 and sd 180;
the second variable has mean 1600 and sd 450.
I used the below commands to generate the densities of variables. The
question is: how can I translate the densities into values? Or, better, can
I generate the values variables directly?
range x 0 3000 3000
la var x "nutrient distribution"
local var1 = 180^2 /* variance of requirement m=1200;sd=180 */
local m1 = 1200
local var2 = 450^2 /* variance of usual intake m=1600;sd=450 */
local m2 = 1600
gen r = (1/sqrt(2*_pi*`var1'))*exp(-1*(x-`m1')^2/(2*`var1'))
la var r "DRA m=1200;dp=180"
gen u = (1/sqrt(2*_pi*`var2'))*exp(-1*(x-`m2')^2/(2*`var2'))
la var u "usual intake m=1600;dp=450"
>>> It's not very clear to me what you want to do here.
But evidently you have as reference distributions
two normals (Gaussians) with mean 1200 and sd 180
and mean 1600 and sd 450. You can -generate- the
densities of such variables as above or you
can make it easier for yourself by using the
built-in function -normden(x, mean, sd)-. See -help-
If you wanted to compare some real data with these
Gaussians, you could do something like this
. histogram y, plot(function normden(x,1200,180), range(y) ||
function normden(x, 1600, 450), range(y))
* For searches and help try: