help for twoway dstathttp://github.com/benjann/dstat/

Title

twoway dstat -- Plot distribution estimates from dstat in
graph twoway

Syntax

Syntax 1 (computing results on the fly)

[graph] twoway dstat [ci] subcmd
varlist [if] [in] [weight]
[, options ]

where subcmd is one of

density density function

pdf same as density

histogram histogram

proportion probability distribution

frequency same as proportion with option frequency

cdf cumulative distribution function

ccdf complementary CDF/survival function

quantile quantile function

lorenz lorenz curve

share percentile shares

tip TIP curve

fweights, pweights, iweight, and aweights are allowed; see weight.

Syntax 2 (using stored results)

[graph] twoway dstat [ci] name
[, options ]

where name is a set of results from dstat subcmd
that has been stored by estimates store. name
may also be . for the current (active) estimates.

In case of conflict, subcmd takes precedence over name. That is,
Syntax 1 takes precedence over Syntax 2.

options Description

Syntax 1 only
dstat_options any options allowed by dstat,
depending on subcmd, except generate() and rif()

Main
labels(textlist) label(s) to be used in legend

select(eqlist) select results to be plotted

[no]step do/do not use step function; only allowed with
cdf and ccdf

line use line plot rather than bar plot; only allowed with
histogram and pshare

horizontal flip plot orientation

rescale(#) rescale plotted values by factor #

area(#) synonym for rescale()

Rendering
marker_options change look of markers

cline_options change look of lines

barlook_options change look of bars

area_options change look of shaded areas

axis_choice_options associate plot with alternate axis

twoway_options general options for two-way graphs

Description

graph twoway dstat plots distribution estimates computed by dstat
using graph twoway line or graph twoway bar.

graph twoway dstat ci plots corresponding confidence intervals using
graph twoway rarea or graph twoway rcap.

graph twoway dstat requires Stata 16 or newer.

Options

dstat_options are any options allowed by
dstat, except generate() and rif(). The set of available
options depends on subcmd. dstat_options are only allowed in
Syntax 1.

labels(textlist) specifies custom legend labels for the plotted variables or
subpopulations, where textlist is

"text" ["text" ...]

This may also affect the label that is printed on the y-axis.

select(eqlist) selects the equations (variables or subpopulations)
to be included in the plotted results, where eqlist is a list of
equation names. The * and ? wildcards are allowed in
eqlist. The default is to plot all available results.

[no]step, if specified with subcommand cdf or ccdf,
enforces or prevents using a step function to display the CDF. The default
is to use a step function if option discrete (but not
ipolate) is specified, and else use straight lines. Specify
nostep or step, respectively, to override this default behavior.

line, if specified with subcommand histogram or pshare,
prints a line tracing the top of the bars, rather than printing
bars. CIs will be printed as areas rather than capped spikes.

horizontal flips the axes.

rescale(#) multiplies all estimates by #.

area(#) is a synonym for rescale().

marker_options are options affecting the look of the plotted
markers.

cline_options are options affecting the look of the plotted lines.

barlook_options are options affecting the look of the plotted bars

area_options are options affecting the look of the plotted areas.

axis_choice_options are options for specifying the axes on which
the plot appears.

twoway_options are general options for two-way graphs.

Examples

Distribution of a single variable:

. sysuse nlsw88, clear
. twoway dstat pdf tenure, ll(0)

Distributions of multiple variables:

. twoway dstat pdf tenure ttl_exp wage, ll(0)

Distribution of a single variable in multiple subpopulations:

. twoway dstat pdf tenure, ll(0) over(union)

Distributions of multiple variables in multiple subpopulations:

. twoway dstat pdf tenure ttl_exp wage, ll(0) over(union)

Use stylelists to affect the rendering in case of multiple variables
or subpopulations:

. twoway dstat pdf tenure ttl_exp wage, ll(0) lpattern(l dash dash_dot) lwidth(medthick ..)

. twoway dstat pdf tenure, ll(0) over(union) recast(area) fcolor(%50 ..) lcolor(%0 ..)

Add confidence intervals in the back or on top, depending on context:

. twoway dstat ci pdf tenure, ll(0) || dstat pdf tenure, ll(0)

. twoway dstat histogram tenure, lalign(center) || dstat ci histogram tenure

Combine different types of plots:

. twoway dstat histogram tenure, lalign(center) || dstat pdf tenure, ll(0)

Alternatively, use ()-binding rather than ||-separator notation;
see Syntax in graph twoway:

. twoway (dstat histogram tenure, lalign(center)) (dstat pdf tenure, ll(0))

Combine different types of plots on separate axes:

. twoway (dstat pdf tenure, ll(0)) (dstat cdf tenure, yaxis(2))

Use with by():

. twoway (dstat histogram tenure, color(*.5)) (dstat pdf tenure, ll(0)), by(union, legend(off))

Plot distributional differences between subpopulations using over(, contrast):

. twoway (dstat ci quantile wage, over(union, contrast)) (dstat quantile wage, over(union, contrast)), legend(off) yline(0) ytitle(Difference in quantiles)

. twoway (dstat hist wage, over(union, contrast)) (dstat pdf wage, ll(0) over(union, contrast)), legend(off) yline(0) ytitle(Density difference)

. twoway (dstat pshare wage, over(union, contrast)) (dstat ci pshare wage, ll(0) over(union, contrast)), legend(off) yline(0) ytitle(Difference in percentile shares)

Using twoway dstat with stored results:

. sysuse nlsw88, clear
. dstat hist tenure ttl_exp wage

. twoway dstat ., fcolor(%50 ..) lcolor(%0 ..) label(tenure experience wage)

. dstat pdf tenure, ll(0)
. estimates store PDF
. dstat cdf tenure
. estimates store CDF
. twoway (dstat ci PDF) (dstat PDF) (dstat CDF, yaxis(2))

Author

Ben Jann, University of Bern, ben.jann@unibe.ch

Thanks for citing this software as follows:

Jann, B. (2020). dstat: Stata module to compute summary statistics and
distribution functions including standard errors
and optional covariate balancing. Available from
http://ideas.repec.org/c/boc/bocode/s458874.html.

Also see

Online: help for
graph twoway,
dstat