Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Folding a density to check for symmetry or examine skewness


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: Folding a density to check for symmetry or examine skewness
Date   Fri, 9 Mar 2007 12:18:42 -0000

Here is something simple that may amuse -- or even be 
useful in teaching or data exploration. 

A symmetric distribution has identical left and right 
parts, either side of its middle. In the case of a unimodal 
distribution that middle will also be its mode, median and
mean. 

A skewed distribution will have different left and right parts, 
no matter what "middle" you select. This is a matter of definition, 
but checking that this is so or examining asymmetry in detail
can be worthwhile. 
 
We can fold to superimpose the two parts: 

. u auto, clear
(1978 Automobile Data)

. kdensity mpg, gen(density) at(mpg)

Pick a "middle", in this case a mode at 19: 

. gen distance = abs(mpg - 19)

. label var distance "distance from mode (mpg)"

. gen label = cond(mpg > 19, "R", cond(mpg < 19, "L", "M"))

. scatter density distance, mla(label) ms(i)

In a right-skewed distribution, the "R" points are higher, 
and so forth. 

I tried labels of "+" and "-" as well, but that is
not so good. The minus sign is too small. (The underscore "_"
would be placed too low.) 

Nick 
[email protected] 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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