Help for mean_ci_plot

Description

mean_ci_plot offers a user-friendly command for visualizing means and confidence intervals of specified variables, with an option for disaggregation. It also offers the flexibility to adapt to a wide range of graphical preferences.

Syntax

mean_ci_plot varlist [IF] [IN], [by(varname)] [scale] [title()] [graphopts()]

Options

by(varname) This specifies the grouping variable. The varname must be a labelled factor variable.

scale Allows the user to scale the Y-Axis to the percentage scale. Useful for visualizing percentages, proportions and rates.

title Allows users to specify a custom title for the graph. If not used, the default title is "Means and confidence intervals".

graphopts(string) Allows the user to pass any Stata graph options into the program. For example, a custom subtitle and/or note (or make changes to the axis labels, ticks and so on). Must be specified as a string enclosed in quotation marks. Users should refer to the official Stata documentation for a comprehensive list of graph options.

Examples

Setting up an example dataset.

. sysuse auto.dta, clear

. gen pct_score = runiform()*100

. lab var pct_score "Percentage Score"

Example 1

Mean + 95% confidence interval of three continuous variables with no group variable.

. mean_ci_plot mpg trunk turn

Example #2

Mean + 95% confidence interval of three continuous variables with a group variable.

. mean_ci_plot mpg trunk turn, by(foreign)

Example #3

Mean + 95% confidence interval of a percentage variable while using the "title" option.

. mean_ci_plot pct_score, title("My custom title")

Example #4

Mean + 95% confidence interval of a percentage variable while using the "scale" option.

. mean_ci_plot pct_score, scale

Example #5

Editing the look of the graph via "graphopts".

. mean_ci_plot mpg trunk turn, by(foreign) graphopts(msymbol(S) xtitle("My X-Axis"))

Example #6

Using an IF/IN condition.

. mean_ci_plot mpg trunk turn if price > 5000, by(foreign)

Notes

1. This program requires the coefplot package. If not already installed, it can be installed from SSC by running "ssc install coefplot, replace".

Acknowledgments

We would like to thank Ben Jann, who developed coefplot, which our command builds on.

Authors

Zaeen de Souza, Frontline Impact

zaeen.desouza19_mec@apu.edu.in

Kabira Namit, World Bank

knamit@worldbank.org