On Mon, Mar 4, 2013 at 11:26 PM, David Radwin wrote:
> You can create your own CDFs using -cumul- and then plot them using
> -twoway line-. The following example is based on this message by Nick Cox:
> http://www.stata.com/statalist/archive/2005-04/msg00800.html
>
> sysuse nlsw88, clear
> gen wageodd=wage if mod(_n,2)==1 // odd-numbered observations
> gen wageeven=wage if mod(_n,2)==0 // even-numbered observations
>
> kdensity wageodd, gen(a b)
> cumul b, gen(cb)
>
> kdensity wageeven, g(c d)
> cumul d, gen(cd)
>
> twoway (line cb b, sort ) (line cd d, sort lpattern(dash))
One of the big advantages of plotting CDFs over PDFs is that you
hardly ever need to smooth the distribution for plotting CDFs, while
smooting is often necesary for PDFs. The simplest example of smooting
a PDF would be a histogram, which "smooths" by binning. So in the
example above I would leave out the two calls to -kdensity- and
directly look at the real data instead:
*------------------ begin example ------------------
sysuse nlsw88, clear
gen wageodd=wage if mod(_n,2)==1 // odd-numbered observations
gen wageeven=wage if mod(_n,2)==0 // even-numbered observations
cumul wageodd, gen(codd)
cumul wageeven, gen(ceven)
twoway line codd wageodd , sort lpattern(solid) || ///
line ceven wageeven, sort lpattern(dash)
*------------------- end example -------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
Hope this helps,
Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/