*! version 1.0.1 27JUN2013

Title

qvgraph -- Graph command for quasi variances

Syntax

qvgraph
varlist
[,options]

options description

ref(string) name of reference category; ref_grp if not specified

level(#) sets the confidence interval between 0-100; default is 95

horizontal horizontal orientation

grplabel(# "label" [# "label" ...]) group labels

mklabel place labels at markers

scatteroption(scatter_options) scatter options

rspikeoption(rspike_options) rspike options

twoway_options other twoway options

saving(prefix[, replace]) save variables used in the graph

Description

qvgraph uses quasi variances (Firth 2003) to plot the point and confidence interval estimates
for effects of a multi-category variable. A fit model must exists before qvgraph.

The varlist accepts either the (n-1) dummy variables of a multi-category variable,
or its equivalent factor variable in the form of i.group. In both cases,
varlist has to be included in the previous estimation command.

qvgraph works by first running the varlist through qv, and then extracting the results
to draw the graph. The graph combines a twoway scatter graph that plots the point estimates
as the markers, and a twoway rspike graph that plots the quasi standard errors as the spikes.

Options

Estimating quasi variances

ref(string) names the reference category. If not specified, ref_grp is used.

level(#) specifies the level of confidence interval. It accepts numeric values between 0 and 100. The
default is 95.

Labeling groups

grplabel() assigns group labels by following these rules:

a) If this option is specified, the user-supplied labels are used. The syntax to specify labels is the same
as in value define lblname, which is # "label" [# "label" ...].

b) If the option is not specified and the varlist contains (n-1) dummy variables, the variable
names become the value labels. In this case, specifying option ref() is recommended, or
the program will use ref_grp to indicate the reference category.

c) If grplabel() is not specified and the varlist contains a factor variable, qvgraph
first tries to apply the value labels of the factor variable. If the factor variable has no value
labels, its numeric values are used.

mklabel places the group labels at the markers. If mklabel is not specified, qvgraph
places the labels along the x or y axis.

Graph options

horizontal sets the orientation horizontally. The default orientation is vertical.

scatteroption() takes twoway scatter options intended for the scatter plot. Use it to control
the markers.

rspikeoption() takes twoway rspike options intended for the rspike graph. Use it to control
the spikes.

twoway options intended for the combined graph should be specified seperately from scatteroption()
and rspikeoption(). This may include controls for the axises, additional lines, and the graph region.

saving(prefix[, replace]) saves the variables used to plot the graph. This is designed for users who
prefer to build their graphs "from stratch". This option saves four variables with names starting with the
user-specified prefix:

a)prefix_g: an indicator for the groups/categories
b)prefix_b: the point estimates
c)prefix_l: the qv-based lower bound
d)prefix_u: the qv-based upper bound

prefix takes the first six specified characters.

replace is optional. Specifying replace directs the program to overwrite existing variables.

Examples

A) Effects of region on a state's death rate

. sysuse census, clear
. gen dpop=death/pop*1000
. gen NC=region==2
. gen SO=region==3
. gen WS=region==4
. reg dpop NC SO WS medage

Example 1: dummy variables; horizontal; specified labels placed along the y axis

. qvgraph NC SO WS, hori grplabel(1 Northeast 2 Northcentral 3 South 4 West) ///
rsp(lw(medium) lc(gs2)) ///
xlab(-2(.5)1, labs(small)) xmtick(-2(.1)1) ///
xtitle("Effect on death per 1,000 people", size(medsmall)) ///
ylab(,val labs(small) nogrid angle(horizontal)) ///
ytitle("Region", size(medsmall)) scheme(s2mono)
(click to run)

Example 2: dummy variables; horizontal orientation; specified labels placed at markers

. qvgraph NC SO WS, hori grplabel(1 "Northeast" 2 "North central" 3 "South" 4 "West") ///
mklab ///
scat(msym(D D D D) mlabgap(2) mlabposition(12) mcolor(gs2)) ///
rsp(lw(medium) lc(gs2)) ///
xtitle("Effect on death per 1,000 people", size(medsmall)) ///
scheme(s2gcolor) ylab(,nolab notick nogrid) yscale(r(.5(1)4.5))
(click to run)

Example 3: dummy variables; vertical; unspecified labels placed along the x axis

. qvgraph NC SO WS, ref(NE) scheme(s2mono) ///
rsp(lw(thick) lc(gs8)) ///
ylab(-2(.5)1, labs(small) glp(dash) glc(gs8) glw(thin)) ///
ymtick(-2(.1)1) ///
ytitle("Effect on death per 1,000 people", size(medsmall)) ///
xlab(,val labs(small)) xtitle("Region", size(medsmall)) ///
xscale(r(.5(1)4.5))
(click to run)

Example 4: factor variable; vertical; original value labels placed along the x axis

. reg dpop i.region medage
. qvgraph i.region, ytitle("Effect on death per 1,000 people", size(medsmall)) ///
xscale(r(.5(1)4.5))
(click to run)

Example 5: factor variable; vertical; no value labels placed along the x axis; saves variables

. label value region // strip value labels
. qvgraph i.region, ytitle("Effect on death per 1,000 people", size(medsmall)) ///
xscale(r(.5(1)4.5)) sav(A,replace)
(click to run)

B)Effects of region on a country's population growth rate

. sysuse lifeexp,clear
. gen lnlexp=ln(lexp)
. reg popgrowth gnppc safewater ib2.region

Example 6: factor variable; vertical; specified labels with non-letter characters

. qvgraph ib2.region, grplabel(1 "Europe/Cen. Asia" 2 "North America" 3 "South America") ///
scat(mlabposition(5) mlabgap(2)) ///
ytitle(Effects on annual % of population growth) ///
xscale(range(.5 3.5)) xlab(, notick) scheme(sj)
(click to run)

References

Firth, David. 2003. ¡§Overcoming the Reference Category Problem in the Presentation of Statistical Models.¡¨Sociological Methodology 33(1): pp 1¡V18.