Bookmark and Share

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


[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 <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index