Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: 'twoway' syntax subtlety


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: 'twoway' syntax subtlety
Date   Wed, 15 Oct 2008 13:26:31 +0100 (BST)

--- George Hoffman <ghoffman@mcw.edu> wrote:
> I'm trying to overlay two (or more) kdensity plots.
> 
> kdensity accepts the 'norm' option
> twoway kdensity does not - see log below
> 
> I thought twoway calls kdensity - but I must have a misunderstanding
> of stata 10 graphics....

The -twoway- graphs allow for much more flexibility at the price of
haveing to specify more. In your case, if you want a normal cuve fitted
trouhg it, you will have to add it with the -twoway function- command,
like it in the example below:

*----------- begin example ---------------------------
sum mpg
twoway kdensity mpg || ///
       function y=normalden(x,`r(mean)',`r(sd)'), ///
       range(`r(min)' `r(max)')
*----------------- end example -----------------------

There are better methods if your aim is to assess deviations from a
normal/Gaussian distribution, like -pnorm- and -qnorm- in official
Stata, Nick Cox's -dpp- discussed in (Cox 2005) see -findit dpp-, and
my own -hangroot- see -findit hangroot-.

-- Maarten

Cox, Nicholas J. (2005) Speaking Stata: Density probability plots, The
Stata Journal 5(2): 259--273.
http://www.stata-journal.com/article.html?article=gr0012


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index