*! version 3.9 29 Feb 2020
help qreg2 also see: qreg postestimation

Title

qreg2 -- Quantile regression with robust and clustered standard errors

Syntax

qreg2 depvar [indepvars] [if] [in] [weight]
[, options]

options

quantile(#) estimate # quantile; default is quantile(.5)

cluster(clustvar) specifies that the standard errors are computed allowing for intra-cluster correlation;
the variable identifying the clusters is defined by clustvar

mss(varlist) use varlist in the MSS heteroskedasticity test

notest suppresses the computation of the MSS and PSS tests

silverman uses Silverman's rule-of-thumb as a scaling factor for the bandwidth

wlsiter(#) attempt # weighted least-squares iterations before doing linear programming iterations; default is wlsiter(1)

epsilon(#) controls the number of residuals set to zero (seldom used); default is epsilon(1e-7)

indepvars may contain factor variables; see fvvarlist.

qreg2 allows fweights except when the option cluster is used; see weight.

See [R] qreg postestimation for features available after estimation.

Description

qreg2 is a wrapper for [R] qreg which estimates quantile regression and reports robust standard
errors and t-statistics. By default the standard errors are asymptotically valid under heteroskedasticity
and misspecification. The robust covariance matrix is computed following Chamberlain (1994), Angrist et al. (2006),
and Powell (1984). Standard errors that are also robust to intra-cluster correlation can be obtained with the option
cluster; see Parente and Santos Silva (2016). Additionally, qreg2 reports the value of the objective
function, defined as the average of the check function; the R-squared, defined as the square of the correlation between
the fitted values and the dependent variable (note however that in quantile regressions the R-squared is even less meaningful
than usual); and the result of a specification test. By default, the Machado-Santos Silva (2000) test for
heteroskedasticity is reported. This test is valid after quantile regression estimation and by default the test
variables are the fitted values of the dependent variable and its squares as in the "Special case of the White test";
see Wooldridge (2009, p. 276). Alternative sets of test variables can be specified with mss(varlist). When the
option cluster is used the Parente-Santos Silva (2016) test for intra-cluster correlation is reported. The
computation of the test statistics can be suppressed with the option notest.

Citations

We would be grateful if you could cite our work when you use qreg2. The correct citations are as follows:

a) If you use clustered standard errors or the Parente-Santos Silva (2016) test, please cite:

Parente, P.M.D.C. and Santos Silva, J.M.C. (2016),
Quantile Regression with Clustered Data,
Journal of Econometric Methods, 5, 1-15.

b) If you use the Machado-Santos Silva (2000) test, please cite:

Machado, J.A.F. and Santos Silva, J.M.C. (2000),
Glejser's Test Revisited,
Journal of Econometrics, 97, 189-202.

c) If you just use heteroskedasticity-robust standard errors, please cite:

Machado, J.A.F., Parente, P.M.D.C., and Santos Silva, J.M.C. (2011), QREG2: Stata module to perform
quantile regression with robust and clustered standard errors, Statistical Software Components S457369,
Boston College Department of Economics.

Options

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.

cluster(clustvar) specifies that the standard errors are computed
allowing for intra-cluster correlation as in Parente and Santos Silva (2016); the
variable identifying the clusters is defined by clustvar.

mss(varlist) specifies the list of variables to be used in the Machado-Santos
Silva (2000) heteroskedasticity test. By default, the test is performed using the fitted
values of the dependent variable and its squares.

notest suppresses the computation of the Machado-Santos Silva (2000) and
Parente-Santos Silva (2016) tests.

silverman by default the scaling factor for the bandwidth is the median absolute
deviation of the quantile regression residuals, as in Parente and Santos Silva (2016). When
the option silverman is used, the scaling factor is given by Silverman's (1986) rule-of-thumb.

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 may help.

epsilon(#) controls the number of residuals set to zero (seldom used),
the default value is 1e-7. In quantile regression, there should be at least as many
residuals equal to zero as parameters estimated. However, when residuals are generated,
some of those that should be zero are not set exactly equal to zero. This is important
because the covariance matrix and the tests depend on how many residuals are negative,
zero, or positive. qreg2 uses a rule to set to zero the residuals whose absolute
value is small enough. This rule works generally well, but in rare cases it may generate
too few or too many zero residuals, and the option epsilon(#) can be used to correct
this. The number of residuals equal to zero can be found in e(zeros).

Remarks

qreg2 was written by J.A.F. Machado, P.M.D.C. Parente, and J.M.C. Santos Silva and it is not an
official Stata command. For further help and support, please contact jmcss@surrey.ac.uk. Please notice
that this software is provided as is, without warranty of any kind, express or implied, including but
not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.
In no event shall the authors be liable for any claim, damages or other liability, whether in an action
of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other
dealings in the software.

Examples

Setup

. sysuse auto

Median regression with heteroskedasticity-robust standard errors

. qreg2 price weight length foreign

Estimate .25 quantile with heteroskedasticity-robust standard errors

. qreg2 price weight length foreign, quantile(.25)

Median regression computing the MSS test using the regressors as test variables

. qreg2 price weight length foreign, mss(weight length foreign)

Median regression suppressing the MSS test

. qreg2 price weight length foreign, not

Estimate .25 quantile and cluster standard errors by headroom

. qreg2 price weight length foreign, q(.25) c(headroom)

Saved results

qreg2 saves the following in e():

Scalars

e(N) number of observations

e(df_m) model degrees of freedom

e(df_r) residual degrees of freedom - always set to missing

e(zeros) number of residuals equal to zero

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(obj_func) mean of the check function

e(f_r) residual density estimate

e(convcode) 0 if converged; otherwise, return code for why nonconvergence

e(r2) R-squared defined as the square of the correlation between the fitted values and the dependent variable

e(mss_chi2) MSS test statistic (if computed)

e(mss_df) degrees of freedom of the MSS test (if computed)

e(mss_p) p-value of the MSS test (if computed)

e(pss_t) PSS test statistic (if computed)

e(pss_p) p-value of the PSS test (if computed)

Macros

e(cmd) qreg

e(cmdline) command as used in the estimation

e(depvar) name of dependent variable

e(properties) b V

e(predict) program used to implement predict

e(wtype) weight type

e(wexp) weight expression

e(marginsnotok) predictions disallowed by margins

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix

Functions

e(sample) marks estimation sample

References

Angrist, J.; Chernozhukov, V. and Fernández-Val, I. (2006), Quantile Regression under Misspecification,
with an Application to the U.S. Wage Structure,
Econometrica, 74, 539-563.

Chamberlain, G. (1994), Quantile Regression, Censoring and the Structure of Wages, in
Advances in Econometrics, ed. C.A. Sims, Cambridge University Press, 171-209.

Machado, J.A.F. and Santos Silva, J.M.C. (2000), Glejser's Test Revisited, Journal of Econometrics,
97, 189-202.

Parente, P.M.D.C. and Santos Silva, J.M.C. (2016), Quantile Regression with Clustered Data,
Journal of Econometric Methods, 5, 1-15.

Powell, J.L. (1984), Least Absolute Deviation Estimation for the Censored Regression Model,
Journal of Econometrics, 25, 303-325.

Silverman, B. W. (1986), Density estimation for statistics and data analysis, New York(NY): Chapman and Hall.

Wooldridge, J.M. (2009), Introductory Econometrics, 4th edition, Mason (OH): South Western.

Also see

Manual: [R] qreg

Help: [R] qreg postestimation;