 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: draw overlapping normal densities

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: draw overlapping normal densities Date Tue, 13 Jul 2010 13:34:36 -0700 (PDT)

```--- On Tue, 13/7/10, Cohen, Elan wrote:
> I'd like to draw two overlapping Normal densities based on
> 2 sets of population means and sds.  For example:
>
> sysuse auto
> su price if !foreign , meanonly
> local mean0 = r(mean)
> local sd0 = r(sd)
> su price if foreign , meanonly
> local mean1 = r(mean)
> local sd1 = r(sd)
>
> This is where I'd like to draw a normal curve based on
> (mean0, sd0) and another based on (mean1, sd1).

If you add the -meanonly- option you will not compute the
standard deviation, so the locals sd0 and sd1 will contain
nothing in your example. Otherwise you were looking in the
right direction. To comple the example:

*------------------ begin example -------------------
sysuse auto
su price if !foreign
local mean0 = r(mean)
local sd0 = r(sd)
su price if foreign
local mean1 = r(mean)
local sd1 = r(sd)
twoway function y = normalden(x, `mean0',`sd0'), ///
range(3000 15000) ||             ///
function y = normalden(x, `mean1',`sd1'), ///
range(3000 15000)
*----------------- end example -----------------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```