-------------------------------------------------------------------------------
help for mrgraph
-------------------------------------------------------------------------------

Graphs of multiple responses

mrgraph { bar | hbar | dot | tab } varlist [weight] [if exp] [in range] [, { response(numlist) | condition(exp) } poly countall include includemissing casewise sort[(#)] descending by(varname[, by_subopts]) stat(statname) rtotal ctotal nopercent nolabel addval[(string)] width(#) height(#) oversubopts(over_subopts) graph_options ]

where by_subopts is

{ inboard | outboard [ over_subopts ] | separate [ suboptions ] }

and statname is

{ freq | column | row | cell | rcolumn | rcell }

fweights and aweights are allowed with mrgaph; see help weights.

Description

mrgraph may be used to produce graphs of multiple response distributions. Please read help mrtab before using mrgraph. The syntaxes mrgraph bar, mrgraph hbar and mrgraph dot are specified to indicate use of graph bar, graph hbar and graph dot respectively. The size (height or length) of the bars or position of the dots in the graph corresponds to the frequencies (or, optionally, proportions) of the response categories. mrgraph tab produces table plots in the manner of Nick Cox's tabplot (Cox 2004). mrgraph is implemented as a wrapper for mrtab followed by _mrsvmat and graph.

Options

addval[(string)] specifies that labels and values (or variable names in the case of the indicator mode) are used to mark the responses in the graph. The values and labels will be separated by string if specified or by a blank otherwise (use quotes, if the desired delimiter has leading and/or trailing blanks, i.e. addval(": ")). If the addval option is not specified, then labels are used exclusively. However, if no labels are available, values are used and addval will have no effect. Furthermore, addval will have no effect if the response variables are string.

by(varname[, by_subopts])} draws the conditional distributions of responses for the categories of varname. The by-variable may be string or numeric. The by_subopts control the grouping of the results in the graph if the graph type is mrgraph bar, mrgraph hbar, or mrgraph dot. Possible specifications are:

inboard

The categories of the by-variable are grouped within the categories of the multiple response variables. This is the default.

outboard [ over_subopts ]

The categories of the multiple response variables are grouped within the categories of the by-variable. The separation of the by-groups is implemented as an additional over statement in the internal graph call. Thus, over_subopts may be specified. See help graph bar and help graph dot.

separate [ suboptions ]

For each category of the by-variable a separate plot is drawn within a single graph. This conforms to the default behavior of the by option in Stata's graph commands (which, however, is not the default in mrgraph). See help by_option for details on the suboptions.

casewise specifies that cases with missing values for at least one of the response variables should be excluded listwise.

condition(exp) is an alternative to the response() option. See help mrtab for details on this option.

countall requests that repeated identical responses be added up.

ctotal specifies that column totals be reported.

descending specifies that the sort order be descending. The default is to sort in ascending order. This is only relevant if sort is specified.

height(#) controls the amount of available graph space taken up by bars in the table plot. This option is only relevant if the graph type is mrgraph tab. The default is 0.8.

include specifies that observations composed of zero responses be treated as valid. See help mrtab for details on this option.

includemissing is an enhancement to include and specifies that cases be treated as valid even if all response variables are missing. See help mrtab for details on this option.

nolabel specifies that labels be ignored.

nopercent specifies that relative frequencies be formatted as proportions (.271) instead of percentages (27.1).

oversubopts(over_subopts) may be used to pass suboptions through to the over option which is applied by mrgraph in the internal call of the graph command. This is only relevant for the graph types mrgraph bar, mrgraph hbar, and mrgraph dot. For further explanations on the over option and its suboptions see help graph bar and graph dot. Do not use the sort suboption; use mrgraph's own sort option instead (see below).

poly specifies that the responses are stored in polytomous mode. See help mrtab for details on this option.

response(numlist) specifies the (range of) response values. See help mrtab for details on this option.

rtotal specifies that row totals be reported.

sort draws the categories in ascending order of frequency. If by is specified, the sorting will correspond to the totals over all groups unless a reference group is specified in parentheses. That is, sort(1) will sort in order of the frequencies in the first by-group, sort(2) in order of the frequencies in the second by-group, and so on. Specify descending to sort in descending order.

stat(statname) determines the statistic which the graph be based on. statname is either freq, if raw frequencies be used, or column (base: column total of observations), row (base: row total), cell (base: grand total of valid observations), rcolumn (base: column total of responses), or rcell (base: grand total of responses), if relative frequencies be used. stat(freq) is the default.

width(#) specifies the maximum width (number of chars) used to display the labels of the responses. Labels that are too wide are wrapped. Note that the single words in the labels will not be broken. If no width is specified, labels are not wrapped.

Examples

One-way bar chart:

. use http://fmwww.bc.edu/RePEc/bocode/d/drugs.dta (1997 Survey Data on Swiss Drug Addicts)

. mrgraph bar crime1-crime5, include response(2 3) sort width(15) title(Criminal experiences (as a victim)) ylabel(,angle(0))

Two-way bar chart (inboard):

. mrgraph bar crime1-crime5, include response(2 3) sort width(15) by(sex) stat(column) title(Criminal experiences (as a victim)) ylabel(,angle(0)) legend(bmargin(t+1))

Two-way bar chart (outboard):

. mrgraph hbar crime1-crime5, include response(2 3) sort by(sex, outboard) stat(column) title(Criminal experiences (as a victim)) ylabel(,angle(0))

Two-way bar chart (separate):

. mrgraph hbar crime1-crime5, include response(2 3) sort(1) width(16) stat(column) by(sex, separate title(Criminal experiences (as a victim)))

Table plot:

. mrgraph tab crime1-crime5, include response(2 3) sort width(16) stat(column) by(sex) rtotal title(Criminal experiences (as a victim))

References

Cox, N. J. 2004. Speaking Stata: Graphing categorical and compositional data. The Stata Journal 4(2): 190–215.

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see

Manual: [G] graph bar, [G] graph dot, [G] by_option

Online: help for mrtab, _mrsvmat, graph bar, graph hbar, graph dot,