Help for ratio_plot

Description

ratio_plot is designed to plot ratios and confidence intervals of specified variables with an option for disaggregation. Essentially, ratio_plot mirrors the output of Stata's in-built ratio command in a graphical format. It also offers the flexibility to adapt to a wide range of graphical preferences.

Syntax

ratio_plot varlist [IF] [IN], Base(varname) [Over(varname)] [Title(string)] [Sort] [SCale] [Graphopts(string)]

Options

Base(varname) Specifies the denominator variable in the ratio calculation. Essential for determining the ratio.

Over(varname) Defines the grouping variable for disaggregating the ratio calculation over different categories.

Title(string) Allows users to provide a custom title for the graph. Defaults to "Ratio graph" if not specified.

Sort Enables sorting of the ratio values in the plotted graph. Useful for ordered comparisons and relevant only if used in conjunction with the 'over' option. If not selected, ratios will default to an alphabetic order.

Scale Adjusts the scale of the graph to be between 0 and 1. By default, ratios are presented without scaling.

Graphopts(string) Facilitates the inclusion of additional Stata graph options. Must be specified as a string in quotation marks. This option offers extensive customization of the graphical output.

Examples

Setting up an example dataset.

. webuse census2, clear

Example 1

Plotting a basic ratio of one variable over another without grouping.

. ratio_plot divorce, base(marriage)

Example #2

Plotting ratios over categories defined by a third variable, including custom title.

. ratio_plot divorce, base(marriage) over(region) title("Ratio of divorce to marriage")

Example #3

Customizing the graph's scale, sorting the ratios and adding additional graph options.

. ratio_plot divorce, base(marriage) over(region) scale sort graphopts(msymbol(S) xtitle("My X-Axis"))

Example #4

Additional example of using the graph options.

. ratio_plot divorce, base(marriage) over(region) sort scale graphopts(msymbol(S) xtitle("My X-Axis") recast(bar) barwidth(0.5) citop fcolor(*.7) mlabpos(2))

Notes

1. This program is a wrapper for the coefplot package. If coefplot is not already installed, it must be installed from SSC with the command "ssc install coefplot, replace".

2. The sort and scale options do not require arguments.

3. Standard errors and confidence intervals are drawn directly from Stata's in-built ratio program. It is important to note that these standard errors are estimated simultaneously and as such, for each subgroup ratio the Degrees of Freedom used for estimating the 95% Confidence Interval are based on the overall (pooled) sample size (N) as opposed to the sub-group specific Ns.

Acknowledgments

Special thanks to Ben Jann, the creator of coefplot, which serves as the foundational tool for ratio_plot.

Authors

Kabira Namit, World Bank

knamit@worldbank.org

Zaeen de Souza, Frontline Impact

zaeen.desouza19_mec@apu.edu.in