Title
Bar and dot graphs for use with overlapping over() categories
Syntax
multibar varlist [if] [in] [, options]
options Description ------------------------------------------------------------------------- Main percent display results on a percent scale gnumber(#) number of categories. Required option catlabels(string) category labels. Required option statistic(string) statistic represented in bar or dot graph type(string) bar, hbar or dot. Required option list displays numeric results -------------------------------------------------------------------------
Description
multibar creates bar and dot graphs for overlapping over() categories. multibar is a wrapper for Stata's graph bar and graph dot. When entered correctly, multibar treats overlapping catgories as if they are not overlapping and, therefore, allows use of over().
Options
+------+ ----+ Main +-------------------------------------------------------------
percent displays results as percents.
gnumber (#) is the number of categories. This option is required.
catlabels (string) are the labels given to the categories. See example.
statistic (string) is the statistic to be represented in the bar or dot graph. Default is mean. See collapse for allowed statistics. Weights are not supported.
type (bar, hbar, dot) selects the type of graph. This option is required.
list displays numeric results.
Remarks
Each yvar is a group of variables that is treated as a category level. All of the levels together form the over() category. Suppose we have panel or longitudinal data in which subjects take drugs (treatments) at two (or more) times. For example, Drug A can be used at baseline entry into the cohort and at the final observation in the cohort. We are interested in displaying the proportion (or percent) usage of drugs A, B, C at the baseline and final obervation. The group of these three drugs is an overlapping group because persons can receive one or more of the drugs at any time. Stata's graph bar, hbar and dot cannot handle this type of category. multibar, using collapse, preserve, and restore creates a result set to enable this type of categorization.
In the example above, we have drugAfirst, drugAlast, drugBfirst, drugBlast, drugCfirst, drugClast. Drugs have to be arranged this way: (drugAfirst drugBfirst drugCfirst) (drugAlast drugBlast drugClast). drugAfirst and drugAlast will form the the first of the three categories in this example. The drugs will need a label because they are newly created composite variables. Use catlabels() to do this. The data have to be entered with the ordering noted above. The parentheses are not necessary, but can help in making the lists easier to read. There are three categories in this example, and this information must be entered into the gnumber() option as gnumber(3).
"first" and "last" in the above example are treated as "variables," but are newly created by the program. To be meaningful they need to be added with legend descriptions, as shown in the example below.
Examples
To install test dataset, type ssc describe multibar and follow instructions.
. use multibar, clear
. multibar (fprednisn fmtxa ftnf fplaquinl fazulfidn) (bpred bmtxa btnf bplaq bazulf), gnumber(5) catlab(1 Prednisone 2 MTX 3 TNF 4 HCQ 5 SSZ) p legend(label(1 Baseline) label(2 "At index observation")) yline(37) type(dot)
Author
F. Wolfe fwolfe@arthritis-research.org.
Acknowledgements
Nick Cox made very helpful suggestions.
Also see