Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)


From   Travis Smith <travisa.smith7@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)
Date   Tue, 5 Mar 2013 10:29:05 -0600

Hi Max,

Here is an example of what I use.  The key is to use -scatter- with
the "stairstep" option -c(J)- and there is no need to plot the markers
so I use the additional option -ms(none)-.

I added a bonus for you: the KS test.

********************* Start *********************
* Plotting two CDFs:
sysuse nlsw88, clear
* sortting may be unnecessary
sort wage union
* store F(wage) values for union
cumul wage if union == 1, generate(Fx) equal
* ... and non-union workers
cumul wage if union == 0, generate(Gx) equal

twoway (scatter Fx wage, sort c(J) ms(none)) ///
(scatter Gx wage, sort c(J) ms(none)), ///
ytitle("Density") xtitle("Hourly Wage") ///
legend( pos(5) ring(0) col(1) ///
label(1 "Union") label(2 "Non-union") )

* BONUS!!  Are the CDFs significantly different?
ksmirnov wage, by(union)
* Yes, reject the null of equality.

********************* End *********************

Hope that helps you out,
Travis
*
*   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/


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