Stata help for grby
-------------------------------------------------------------------------------------------------------------------------------------------
help for grby
-------------------------------------------------------------------------------------------------------------------------------------------
Bar charts
grby yvar xvar1 [xvar2] [if exp] [in range] [, format(%fmt) shading(#) yscale(# #) means ci(##) connect numbers vlabel
v1label v2label title(text) saving(filename[,replace])]
yvar continuous or categorical variable on y-axis.
xvar1 first categorical variable on x-axis.
xvar2 second categorical variable on x-axis.
Description
grby displays a bar chart for each covariate pattern. Sums or means of yvar determine the height of the bars. In the latter case you
can specify the level of a confidence interval. This program works under Stata 7 and Stata 8 and it is based on gph.
Options
format(%fmt) specifies the display format for sums or means over the bars.
shading(#) specifies the amount of shading on a scale 0 up to 4, with 0 being the lightest and 4 the darkest.
yscale(# #) specifies the minimum and maximum value of y-axis.
means specifies that means of yvar determine the height of the bars (the default are the sums).
ci(##) specifies the level to figure out a confidence intervals for the means. This option is available only with the option means. The
mean value for a covariate pattern with only one observation is signed by X.
connect with a line the means on the graph. This option is available only with ci(##).
numbers specifies the number (sum or mean) over the bar (or point if ci is specified).
vlabel specifies the variable label.
v1label specifies the value label for xvar1.
v2label specifies the value label for xvar2.
title(text) specifies a title on the top of the graph.
saving(filename[,replace]) saves the graph in the current directory
Examples
. webuse lbw, clear
. xtile aged = age, nq(10)
. label var aged "decile age"
. label define smoke 0 "No" 1 "Yes"
. label values smoke smoke
. label var smoke "smoking"
. grby lwt race, nu format(%9.0g)
. grby lwt race smoke, nu format(%9.0g)
. grby lwt race smoke, nu format(%3.1f) mean v v1 v2
. grby lwt race smoke, nu format(%3.1f) mean ci(95)
. grby lwt race smoke, nu format(%3.1f) mean ci(95) v v1 v2
. grby lwt race smoke, nu format(%3.1f) mean ci(95) v v1 v2 connect
. grby lwt aged, nu
. grby lwt aged smoke, mea ci(95)
. grby lwt aged race, mea ci(95) co v v2
. grby lwt aged race, mea ci(99) co v v2 yscale(100 200)
Authors
Nicola Orsini, Institute of Environmental Medicine, Karolinska Institutet, Stockholm, Sweden and Institute of Information Science and
Technology, National Research Council of Italy, Pisa, Italy.
Matteo Bottai, Arnold School of Public Health, University of South Carolina, Columbia, USA and Institute of Information Science and
Technology, National Research Council of Italy, Pisa, Italy.
Also see
[R] gph
[R] graph
On-line: help for help for gph, graph
Worked examples for grby
Click here to run or save the do-file
for the following worked examples and be sure to have an update version. Type