Title
Plots the cumulative distribution function
Syntax
cdfplot varname [if] [in] [weight] [, options]
options Description ------------------------------------------------------------------------- Main by(varname) specifies a separate c.d.f. to be drawn for each value of varname. normal specifies that a Gaussian probability curve with the same mean and standard deviation to be superimposed over the c.d.f. samesd specifies that the normal c.d.f.s use the same same standard deviation. nocdf specifies that the empirical c.d.f. is not drawn. opt1(twoway_options) specifies the additional graph options for the c.d.f. plot. opt2(twoway_options) specifies the additional graph options for the Gaussian c.d.f. plots . twoway_options any twoway options are applied to the final graph. -------------------------------------------------------------------------
Description
cdfplot plots the sample cumulative distribution function. Distributions can be compared within subgroups defined by a second variable. The best fitting normal (Gaussian) model may be superimposed over the sample c.d.f.
Updating this command using SSC
To obtain the latest version click the following to uninstall the old version
ssc uninstall cdfplot
And click here to install the new version
ssc install cdfplot
Options
by(varname) specifies a separate c.d.f. to be drawn for each value of varname. These are plotted on the same graph for easier comparison.
normal specifies that a normal probability curve with the same mean and standard deviation to be superimposed over the c.d.f.
samesd is relevant only when by and normal options are used together. It specifies that the normal curves with different means have the same standard deviations. This demonstrates the fit of the conventional Gaussian location shift model.
nocdf specifies that the empirical c.d.f. is not drawn but this option will not work unless the normal option is specified, hence only the smoothed Gaussian c.d.f will be drawn.
opt1(twoway_options) specifies additional graph options for the c.d.f. plots.
opt2(twoway_options) specifies additional graph options for the Gaussian c.d.f. plots.
If the xlog option is used, the normal option causes log-normal distributions to be fitted.
Examples
Using the variable length from the auto data (click on the following commands in order):
NOTE DATA will be lost when loading new data
sysuse auto,replace cdfplot length, normal cdfplot length, by(foreign) cdfplot length, by(foreign) norm saving(mygraph) cdfplot length [fw=rep78], by(foreign) norm saving(mygraph,replace)
Using the variable bp from the bplong data
sysuse bplong,replace cdfplot bp, norm cdfplot bp, by(agegrp) cdfplot bp, by(agegrp) norm
Now to show the use of the options in the individual graphs, opt1 alters the line colours for the c.d.f. graphs and opt2 alters the line pattern for the Gaussian c.d.f.
cdfplot bp, by(agegrp) opt1( lc(red green olive) ) opt2( lp(dash dash dash) ) norm
Author
Adrian Mander, MRC Human Nutrition Research Unit, Cambridge, UK.
Email adrian.mander@mrc-hnr.cam.ac.uk
Acknowledgement
This command is nearly a direct port of the cdf command that was written by David Clayton and Michael Hills in STB-49.
Also see
cdf (if installed)