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]
st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)
From
"David Radwin" <[email protected]>
To
<[email protected]>
Subject
st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)
Date
Mon, 4 Mar 2013 14:26:57 -0800 (PST)
Max,
Please remember to cite sources for user-written programs. -distplot- is
by Nick Cox and -cdfplot- is by Adrian Mander. Both are available from
SSC.
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))
David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of [email protected]
> Sent: Monday, March 04, 2013 1:13 PM
> To: [email protected]
> Subject: st: Graphing multiple cdf's in the same graph (using either -
> distplot- or -cdfplot-)
>
> Hi all,
>
> I'm trying to plot two cdf's on the same axis. -distplot- allows me to
do
> this (simple example: distplot line var1 var2, lc(red blue) ) , but
> there's a wrinkle in my data that makes this more complicated. The data
is
> arranged such that var1 and var2 are never both non-missing. That is,
for
> every observation where var1 exists, var2 is missing, and vice versa. I
am
> able to graph this using kernel density:
> twoway (kdensity var1, lp(solid) lc(blue))
> || (kdensity var2, lp(solid) lc(red))
>
> But I can't seem to find a similar implementation for -distplot- (or
> -cdfplot- for that matter). If anyone has any ideas, I would greatly
> appreciate it.
>
> Thanks,
> Max
>
>
> Max Livingston
> Sr. Research Analyst
> Microeconomic Studies
> Research and Statistics Group
> Federal Reserve Bank of New York
> (212) 720-7894
*
* 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/