help for qregplotFernando Rios Avila

Module for plotting coefficients of a Quantile Regressions

qregplot
[varlist]
[,
quantiles(numlist)
cons
ols
olsopt(regress options)
seed(seed number)
raopt(rarea options)
lnopt(line options)
twopt(twoway options)
estore(name )
from(name)
label
labelopt(label options)
mtitles(titles)
grcopt(graph combine options)
graph_combine_options
]

Description

qregplot graphs the coefficients of a quantile regression produces by various
programs that produce quantile coefficients including, qreg, bsqreg, sqreg,
mmqreg, smqreg, sivqr, and rifhdreg (for unconditional quantiles).

qregplot Works in a similar way as grqreg, but provides added options
to give the user more control on the creation of the requested figures, also allowing
for the use of factor notation.

The command works as follows.

Step 1. It gathers all the information of a previously
estimated model (for example via qreg). This information is used as template
for the estimation of quantile regression models across the distribution.

Step 2. Using the information from Step 1, qregplot estimates N
quantile regressions following the same specification as the original model.
One can select which quantiles will be used for the estimation of this models.

Step 3. Once all coefficients, and CI are stored, qregplot plots all requested coefficients
using a twoway rarea for ploting CI, combined with twoway line for plotting the point estimates.
Each figure is stored temporary as a graph in memory.

Step 3b. If requested, OLS coefficients and CI are added to each figure in step 3.

Step 4. If more than 1 variable is requested for plotting,
all plots from Step 3 are combined using graph combine.

The only exception to this process is sqreg. When used after this
command, coefficients are collected from sqreg output, rather than reestimated.

Standard errors are estimated based on the original command specifications. For example. If
qreg was first estimated using vce(robust), qregplot will use
the same type of standard errors for plotting

Since the most time consumming part of quantile regressions is the estimation
of the qregressions themselves, specially if using boostrap standard errors,
one can request qregplot to store all coefficients and CI in memory using the option
estore(name). The advantage of doing this is that plots can be created using the stored coefficients
directly.

In all cases, CI are plotted automatically using the same level of confidence as the original
estimation specification (typically 95%)

Options

varlist Select variables that will be graphed. If none is provided,
all coefficients except the intercept, will be plotted. This accepts factor notation.

quantiles(numlist) Indicates which quantiles to use for plotting. One can use
any numlist to do so. The default is quantile(10(5)90). This is ignored after sqreg.

cons Requests the intercept to be plotted.

ols Requests to include in the graph the coefficients and CI for the standard
ols model (via regress).

olsopt(regress options) Used to provide additional information to estimate the model
via regress. For example, olsopt(robust) request OLS regression to
estimate the model using robust standard errors.

seed(seed number) If one used bsqreg, seed can be used to set the same seed
number for each quantile replication.

raopt(rarea options)
Provides options to be used in the "twoway rarea" part of the graph. This controls
the aspects of the Confidence intervals.
The default options are pstyle(p1) fintensity(30) lwidth(none)

lnopt(line options)
Provides options to be used in the "twoway line" part of the graph. This controls
aspects of the point estimates.
The default options are pstyle(p1) lwidth(0.3)(

twopt(twoway options)
Provides options to be used on the "twoway" graph. This controls
aspects of the twoway graph, after combining rarea and line.
The default options is to set graph and plot region margins to vsmall (

grcopt(graph combine options)
Provides options to be used along with "graph combine". This controls
aspects for the combined graph of all coefficients.

graph combine options It is no longer needed to provide Graph combine options with grcopt(). One can simply add any of those options directly in the command line. This controls
aspects for the combined graph of all coefficients. However, if you are plotting a single coefficient, it will affect the twoway options

estore(name) Request to save all estimated coefficients
and CI in e(). This will be stored in memory under name . This could be used later on
for plotting coefficients only, without re-estimating the quantile regressions. One could also Save this results in a file as a ster file. See estimates save

from(name) Request to plot quantile coefficients using
the information previously stored in e().
When this option is used, one graph aspects options can be used.

label Request the use variable (or value) labels to be used as titles
for each individual quantile plot. The default option is to use the variable name.

labelopt(options) Provides additional information to handle "long"
variable labels. The two options are:

- lines(#L) Request to break a label into #L lines.

- maxlength(#k) Request to break a label into lines of maxlength #k.
This be superseeded by lines if #k is too small to break a label into #L lines.

mtitles(titles) One also has the option of providing titles for each sub-graph. They should be written within double quotes. For exaple mtitles("first" "second") will use 'first' and 'second' as title graphs. See examples for details.

Examples

Setup.

webuse womenwk

Simple Conditional quantile regression using qreg.

qreg wage age education i.married children i.county

Ploting all coefficients of interest, for quantiles 5 95 in 2.5 increments. Storing coefficients in qp

qregplot age education i.married children, q(5(2.5)95) estore(qp)

Same as above but adding OLS coefficients and CI

qregplot age education i.married children, q(5(2.5)95) ols

Changing the look for the CI across quantiles

qregplot age education i.married children, q(5(2.5)95) ols raopt( color(black%5))

Same as above, but ploting in only 1 column for the combined graph

qregplot age education i.married children, q(5(2.5)95) ols raopt( color(black%5)) col(1)

Same as above, but changing the aspect of the graph for better readability

qregplot age education i.married children, q(5(2.5)95) ols col(1) ysize(20) xsize(8)

Using only 3 variables and use results from qp (see above)

qregplot age education children, from(qp)

Same as above but using labels as titles

qregplot age education children, from(qp) label

Same as above but using own titles for figures 1 and 2

qregplot age education children, from(qp) label mtitles("Age in years since 1980" "Years of education")

Same as above but using own titles for figures 1 and 2, written in two lines

qregplot age education children, from(qp) label mtitles("Age in years since 1980 I want this to be long" "Years of education, including Highschool and college") labelopt(lines(2))

Using alternative estimator, bsqreg

bsqreg wage age education i.married children i.county

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, qrprocess (if installed)

qrprocess wage age education i.married children i.county

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, qreg2 (if installed)

qreg2 wage age education i.married children i.county

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, ivqreg2 (if installed)

ivqreg2 wage age education married , inst(age education married children)

qregplot age education married , q(5(5)95)

Using alternative estimator, xtqreg (if installed)

xtqreg wage age education i.married children , i(county)

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, mmqreg (if installed)

mmqreg wage age education i.married children

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, sqreg

sqreg wage age education i.married children i.county, q(10 25 50 75 90)

qregplot age education i.married children,

Using alternative estimator, rifhdreg

rifhdreg wage age education i.married children i.county, rif(q(50))

qregplot age education i.married children, q(5(5)95)

Using alternative estimator, sivqr

sivqr wage age education married children , q(50)

qregplot age education married children, q(5(5)95)

Storing regressions information in memory

qreg wage age education i.married children i.county, q(50)

qregplot age education i.married children, q(5(5)95) estore(qreg_1)

Ploting coefficients from stored estimations

qregplot age education i.married children, from(qreg_1)

Same as above but using labels for titles

qregplot age education i.married children, from(qreg_1) label

Aknowledgements

This program was created as a companion for rifhdreg, for making it easier
to plot coefficients across different quantiles, but also as an answer to a regular question
regarding plotting dummies with grqreg when using factor notation.

This program requires ftools, for expanding varlists with factor notation.

The usual disclaimer applies.

And if interested or curious about smqreg, shoot me an email.

Author

Fernando Rios-Avila

Levy Economics Institute of Bard College

Blithewood-Bard College

Annandale-on-Hudson, NY

friosavi@levy.org

Also see

help for qreg, qreg2, ivqreg2, qrprocess,
bsqreg, sqreg, rifhdreg, xtqreg, mmqreg, sivqr