Plotting Means of a Variable, by Category
catgraph yvar xvar [if exp] [in range] , by(varname) stat(collapse_statistic) graph_options
Description
catgraph plots a summary statistic (means by default) of yvar against xvar, separately for categories of varname.
Options
by(varname) specifies the variable that specifies the categories for plotting. catgraph plots one series for each value of varname. by() may be numeric or string. If by is not specified, one category encompassing all the data is plotted.
stat() specifies the statistic to be plotted. The default is to plot the mean of yvar for each value of xvar. Any valid statistic for the collapse command may be specified.
Examples
. catgraph mpg rep78, by(foreign) c(ll) ylab(0,35)
Graphs mean mileage against repair record, separately for foreign and domestic autos.
. catgraph mpg rep78, by(foreign) c(ll) ylab(0,35) stat(median)
Graphs median mileage against repair record, separately for foreign and domestic autos.
Author
Nick Winter Cornell University nw53@cornell.edu