## Stata 15 help for qreg

```
[R] qreg -- Quantile regression

Syntax

Quantile regression

qreg depvar [indepvars] [if] [in] [weight] [, qreg_options]

Interquantile range regression

iqreg depvar [indepvars] [if] [in] [, iqreg_options]

Simultaneous-quantile regression

sqreg depvar [indepvars] [if] [in] [, sqreg_options]

Bootstrapped quantile regression

bsqreg depvar [indepvars] [if] [in] [, bsqreg_options]

qreg_options                Description
-------------------------------------------------------------------------
Model
quantile(#)               estimate # quantile; default is quantile(.5)

SE/Robust
vce([vcetype], [vceopts]) technique used to estimate standard errors

Reporting
level(#)                  set confidence level; default is level(95)
display_options           control columns and column formats, row
spacing, line width, display of omitted
variables and base and empty cells, and
factor-variable labeling

Optimization
optimization_options      control the optimization process; seldom used
wlsiter(#)                attempt # weighted least-squares iterations
before doing linear programming iterations
-------------------------------------------------------------------------

vcetype                     Description
-------------------------------------------------------------------------
iid                         compute the VCE assuming the residuals are
i.i.d.
robust                      compute the robust VCE
-------------------------------------------------------------------------

vceopts                     Description
-------------------------------------------------------------------------
denmethod                   nonparametric density estimation technique
bwidth                      bandwidth method used by the density
estimator
-------------------------------------------------------------------------

denmethod                   Description
-------------------------------------------------------------------------
fitted                      use the empirical quantile function using
fitted values; the default
residual                    use the empirical residual quantile function
kernel[(kernel)]            use a nonparametric kernel density estimator;
default is epanechnikov
-------------------------------------------------------------------------

bwidth                      Description
-------------------------------------------------------------------------
hsheather                   Hall-Sheather's bandwidth; the default
bofinger                    Bofinger's bandwidth
chamberlain                 Chamberlain's bandwidth
-------------------------------------------------------------------------

kernel                      Description
-------------------------------------------------------------------------
epanechnikov                Epanechnikov kernel function; the default
epan2                       alternative Epanechnikov kernel function
biweight                    biweight kernel function
cosine                      cosine trace kernel function
gaussian                    Gaussian kernel function
parzen                      Parzen kernel function
rectangle                   rectangle kernel function
triangle                    triangle kernel function
-------------------------------------------------------------------------

iqreg_options               Description
-------------------------------------------------------------------------
Model
quantiles(# #)            interquantile range; default is
quantiles(.25 .75)
reps(#)                   perform # bootstrap replications; default is
reps(20)

Reporting
level(#)                  set confidence level; default is level(95)
nodots                    suppress display of the replication dots
display_options           control columns and column formats, row
spacing, line width, display of omitted
variables and base and empty cells, and
factor-variable labeling
-------------------------------------------------------------------------

sqreg_options               Description
-------------------------------------------------------------------------
Model
quantiles(#[#[# ...]])    estimate # quantiles; default is
quantiles(.5)
reps(#)                   perform # bootstrap replications; default is
reps(20)

Reporting
level(#)                  set confidence level; default is level(95)
nodots                    suppress display of the replication dots
display_options           control columns and column formats, row
spacing, line width, display of omitted
variables and base and empty cells, and
factor-variable labeling
-------------------------------------------------------------------------

bsqreg_options              Description
-------------------------------------------------------------------------
Model
quantile(#)               estimate # quantile; default is quantile(.5)
reps(#)                   perform # bootstrap replications; default is
reps(20)

Reporting
level(#)                  set confidence level; default is level(95)
display_options           control columns and column formats, row
spacing, line width, display of omitted
variables and base and empty cells, and
factor-variable labeling
-------------------------------------------------------------------------

indepvars may contain factor variables; see fvvarlist.
by, mi estimate, rolling, and statsby are allowed with qreg, iqreg,
sqreg, and bsqreg; mfp, nestreg, and stepwise are allowed with qreg;
see prefix.
qreg allows fweights, iweights, and pweights; see weight.
See [R] qreg postestimation for features available after estimation.

qreg

Statistics > Nonparametric analysis > Quantile regression

iqreg

Statistics > Nonparametric analysis > Interquantile regression

sqreg

Statistics > Nonparametric analysis > Simultaneous-quantile
regression

bsqreg

Statistics > Nonparametric analysis > Bootstrapped quantile
regression

Description

qreg fits quantile (including median) regression models, also known as
least-absolute-value models (LAV or MAD) and minimum L1-norm models.  The
quantile regression models fit by qreg express the quantiles of the
conditional distribution as linear functions of the independent
variables.

iqreg estimates interquantile range regressions, regressions of the
difference in quantiles.  The estimated variance-covariance matrix of the
estimators (VCE) is obtained via bootstrapping.

sqreg estimates simultaneous-quantile regression.  It produces the same
coefficients as qreg for each quantile.  Reported standard errors will be
similar, but sqreg obtains an estimate of the VCE via bootstrapping, and
the VCE includes between-quantile blocks.  Thus you can test and
construct confidence intervals comparing coefficients describing
different quantiles.

bsqreg is equivalent to sqreg with one quantile.

Options for qreg

+-------+
----+ Model +------------------------------------------------------------

quantile(#) specifies the quantile to be estimated and should be a number
between 0 and 1, exclusive.  Numbers larger than 1 are interpreted as
percentages.  The default value of 0.5 corresponds to the median.

+-----------+
----+ SE/Robust +--------------------------------------------------------

vce([vcetype], [vceopts]) specifies the type of VCE to compute and the
density estimation method to use in computing the VCE.

vcetype specifies the type of VCE to compute.  Available types are
iid and robust.

vce(iid), the default, computes the VCE under the assumption that
the residuals are independent and identically distributed
(i.i.d.).

vce(robust) computes the robust VCE under the assumption that the
residual density is continuous and bounded away from 0 and
infinity at the specified quantile(); see Koenker (2005, sec.
4.2).

vceopts consists of available denmethod and bwidth options.

denmethod specifies the method to use for the nonparametric
density estimator.  Available methods are fitted, residual,
or kernel[(kernel)], where the optional kernel must be one of
the kernel choices listed below.

fitted and residual specify that the nonparametric density
estimator use some of the structure imposed by quantile
regression.  The default fitted uses a function of the
fitted values and residual uses a function of the
residuals.  vce(robust, residual) is not allowed.

kernel() specifies that the nonparametric density estimator
use a kernel method.  The available kernel functions are
epanechnikov, epan2, biweight, cosine, gaussian, parzen,
rectangle, and triangle.  The default is epanechnikov.
See [R] kdensity for the kernel function forms.

bwidth specifies the bandwidth method to use by the nonparametric
density estimator.  Available methods are hsheather for the
Hall-Sheather bandwidth, bofinger for the Bofinger bandwidth,
and chamberlain for the Chamberlain bandwidth.

See Koenker (2005, sec. 3.4 and 4.10) for a description of the
sparsity estimation techniques and the Hall-Sheather and Bofinger
bandwidth formulas.  See Chamberlain (1994, eq. 2.2) for the
Chamberlain bandwidth.

+-----------+
----+ Reporting +--------------------------------------------------------

level(#); see [R] estimation options.

display_options:  noci, nopvalues, noomitted, vsquish, noemptycells,
baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style),
cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R]
estimation options.

+--------------+
----+ Optimization +-----------------------------------------------------

optimization_options: iterate(#), [no]log, trace.  iterate() specifies
the maximum number of iterations; log/nolog specifies whether to show
the iteration log; and trace specifies that the iteration log should
include the current parameter vector.  These options are seldom used.

wlsiter(#) specifies the number of weighted least-squares iterations that
will be attempted before the linear programming iterations are
started.  The default value is 1.  If there are convergence problems,
increasing this number should help.

Options for iqreg

+-------+
----+ Model +------------------------------------------------------------

quantiles(# #) specifies the quantiles to be compared.  The first number
must be less than the second, and both should be between 0 and 1,
exclusive.  Numbers larger than 1 are interpreted as percentages.
Not specifying this option is equivalent to specifying
quantiles(.25 .75), meaning the interquantile range.

reps(#) specifies the number of bootstrap replications to be used to
obtain an estimate of the variance-covariance matrix of the
estimators (standard errors).  reps(20) is the default and is
arguably too small.  reps(100) would perform 100 bootstrap
replications.  reps(1000) would perform 1,000 replications.

+-----------+
----+ Reporting +--------------------------------------------------------

level(#); see [R] estimation options.

nodots suppresses display of the replication dots.

display_options:  noci, nopvalues, noomitted, vsquish, noemptycells,
baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style),
cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R]
estimation options.

Options for sqreg

+-------+
----+ Model +------------------------------------------------------------

quantiles(# [# [# ...]]) specifies the quantiles to be estimated and
should contain numbers between 0 and 1, exclusive.  Numbers larger
than 1 are interpreted as percentages.  The default value of 0.5
corresponds to the median.

reps(#) specifies the number of bootstrap replications to be used to
obtain an estimate of the variance-covariance matrix of the
estimators (standard errors).  reps(20) is the default and is
arguably too small.  reps(100) would perform 100 bootstrap
replications.  reps(1000) would perform 1,000 replications.

+-----------+
----+ Reporting +--------------------------------------------------------

level(#); see [R] estimation options.

nodots suppresses display of the replication dots.

display_options:  noci, nopvalues, noomitted, vsquish, noemptycells,
baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style),
cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R]
estimation options.

Options for bsqreg

+-------+
----+ Model +------------------------------------------------------------

quantile(#) specifies the quantile to be estimated and should be a number
between 0 and 1, exclusive.  Numbers larger than 1 are interpreted as
percentages.  The default value of 0.5 corresponds to the median.

reps(#) specifies the number of bootstrap replications to be used to
obtain an estimate of the variance-covariance matrix of the
estimators (standard errors).  reps(20) is the default and is
arguably too small.  reps(100) would perform 100 bootstrap
replications.  reps(1000) would perform 1,000 replications.

+-----------+
----+ Reporting +--------------------------------------------------------

level(#); [R] estimation options.

display_options:  noci, nopvalues, noomitted, vsquish, noemptycells,
baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style),
cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R]
estimation options.

Examples

---------------------------------------------------------------------------
Setup
. sysuse auto

Median regression
. qreg price weight length foreign

Replay results
. qreg

Estimate .25 quantile using the Bofinger bandwidth method
. qreg price weight length foreign, quantile(.25) vce(iid, bofinger)

Estimate .75 quantile using the Parzen kernel density estimator and the
Chamberlain bandwidth method
. qreg price weight length foreign, quantile(.75) vce(iid,
kernel(parzen) chamberlain)

Estimate [.25, .75] interquantile range, performing 100 bootstrap
replications
. iqreg price weight length foreign, quantile(.25 .75) reps(100)

Same as above
. iqreg price weight length foreign, reps(100)

Estimate .25, .5, and .75 quantiles simultaneously, performing 100
bootstrap replications
. sqreg price weight length foreign, quantile(.25 .5 .75) reps(100)

Median regression with bootstrap standard errors
. bsqreg price weight length foreign

Estimate .75 quantile with bootstrap standard errors
. bsqreg price weight length foreign, quantile(.75)
---------------------------------------------------------------------------

Stored results

qreg stores the following in e():

Scalars
e(N)                number of observations
e(df_m)             model degrees of freedom
e(df_r)             residual degrees of freedom
e(q)                quantile requested
e(q_v)              value of the quantile
e(sum_adev)         sum of absolute deviations
e(sum_rdev)         sum of raw deviations
e(sum_w)            sum of weights
e(f_r)              density estimate
e(sparsity)         sparsity estimate
e(bwidth)           bandwidth
e(kbwidth)          kernel bandwidth
e(rank)             rank of e(V)
e(convcode)         0 if converged; otherwise, return code for why
nonconvergence

Macros
e(cmd)              qreg
e(cmdline)          command as typed
e(depvar)           name of dependent variable
e(bwmethod)         bandwidth method; hsheather, bofinger, or
chamberlain
e(denmethod)        density estimation method; fitted, residual, or
kernel
e(kernel)           kernel function
e(wtype)            weight type
e(wexp)             weight expression
e(vce)              vcetype specified in vce()
e(vcetype)          title used to label Std. Err.
e(properties)       b V
e(predict)          program used to implement predict
e(marginsnotok)     predictions disallowed by margins
e(asbalanced)       factor variables fvset as asbalanced
e(asobserved)       factor variables fvset as asobserved

Matrices
e(b)                coefficient vector
e(V)                variance-covariance matrix of the estimators

Functions
e(sample)           marks estimation sample

iqreg stores the following in e():

Scalars
e(N)                number of observations
e(df_r)             residual degrees of freedom
e(q0)               lower quantile requested
e(q1)               upper quantile requested
e(reps)             number of replications
e(sumrdev0)         lower quantile sum of raw deviations
e(sumrdev1)         upper quantile sum of raw deviations
e(sumadev0)         lower quantile sum of absolute deviations
e(sumadev1)         upper quantile sum of absolute deviations
e(rank)             rank of e(V)
e(convcode)         0 if converged; otherwise, return code for why
nonconvergence

Macros
e(cmd)              iqreg
e(cmdline)          command as typed
e(depvar)           name of dependent variable
e(vcetype)          title used to label Std. Err.
e(properties)       b V
e(predict)          program used to implement predict
e(marginsnotok)     predictions disallowed by margins
e(asbalanced)       factor variables fvset as asbalanced
e(asobserved)       factor variables fvset as asobserved

Matrices
e(b)                coefficient vector
e(V)                variance-covariance matrix of the estimators

Functions
e(sample)           marks estimation sample

sqreg stores the following in e():

Scalars
e(N)                number of observations
e(df_r)             residual degrees of freedom
e(n_q)              number of quantiles requested
e(q#)               the quantiles requested
e(reps)             number of replications
e(sumrdv#)          sum of raw deviations for q#
e(sumadv#)          sum of absolute deviations for q#
e(rank)             rank of e(V)
e(convcode)         0 if converged; otherwise, return code for why
nonconvergence

Macros
e(cmd)              sqreg
e(cmdline)          command as typed
e(depvar)           name of dependent variable
e(eqnames)          names of equations
e(vcetype)          title used to label Std. Err.
e(properties)       b V
e(predict)          program used to implement predict
e(marginsnotok)     predictions disallowed by margins
e(asbalanced)       factor variables fvset as asbalanced
e(asobserved)       factor variables fvset as asobserved

Matrices
e(b)                coefficient vector
e(V)                variance-covariance matrix of the estimators

Functions
e(sample)           marks estimation sample

bsqreg stores the following in e():

Scalars
e(N)                number of observations
e(df_r)             residual degrees of freedom
e(q)                quantile requested
e(q_v)              value of the quantile
e(reps)             number of replications
e(sum_adev)         sum of absolute deviations
e(sum_rdev)         sum of raw deviations
e(rank)             rank of e(V)
e(convcode)         0 if converged; otherwise, return code for why
nonconvergence

Macros
e(cmd)              bsqreg
e(cmdline)          command as typed
e(depvar)           name of dependent variable
e(properties)       b V
e(predict)          program used to implement predict
e(marginsnotok)     predictions disallowed by margins
e(asbalanced)       factor variables fvset as asbalanced
e(asobserved)       factor variables fvset as asobserved

Matrices
e(b)                coefficient vector
e(V)                variance-covariance matrix of the estimators

Functions
e(sample)           marks estimation sample

References

Chamberlain, G. 1994. Quantile regression, censoring, and the structure
of wages. In Advances in Economics Sixth World Congress, ed.
Christopher A. Sims, 171-209. Cambridge University Press: Cambridge.

Koenker, R. 2005. Quantile Regression. Cambridge University Press:  New
York.

```