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]

From |
Maarten Buis <maartenlbuis@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:02:36 +0100 |

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/

**References**:**st: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)***From:*Max.Livingston@ny.frb.org

**st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)***From:*"David Radwin" <dradwin@mprinc.com>

- Prev by Date:
**st: fitted values in Poisson and NB** - Next by Date:
**Re: st: test difference in marginal effects for the same dummy variable, computed first as difference and then as derivative** - Previous by thread:
**st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)** - Next by thread:
**Re: st: RE: Graphing multiple cdf's in the same graph (using either -distplot- or -cdfplot-)** - Index(es):