help qreg2                                       also see:  qreg postestimation



qreg2 -- Quantile regression with robust standard errors


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

options Description -------------------------------------------------------------------------

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

norobust displays results based on the non-robust covariance matrix estimator

mss(varlist) use varlist in the MSS heteroskedasticity test

nomss suppresses the computation of the MSS test

wlsiter(#) attempt # weighted least-squares iterations before doing linear programming iterations


qreg2 allows fweights; see weight. See [R] qreg postestimation for features available after estimation.


qreg2 is a wrapper for [R] qreg which estimates quantile regression and reports standard errors and t-statistics that are asymptotically valid under heteroskedasticity and misspecification. The robust covariance matrix is computed following Chamberlain (1994), Angrist et al. (2006), and Powell (1984). The non-robust results can also displayed with the option norobust. 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 the Machado-Santos Silva (2000) test for heteroskedasticity. 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) and the computation of the statistic can be suppressed with the option nomss.


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.

norobust display results based on the non-robust covariance matrix estimator.

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.

nomss suppresses the computation of the MSS test.

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.


qreg2 was written by J.A.F. Machado and J.M.C. Santos Silva and it is not an official Stata command. For further help and support, please contact 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.


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

Median regression . qreg2 price weight length foreign

Median regression with non-robust output . qreg2 price weight length foreign,nor

Estimate .25 quantile . 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, nomss


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 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(rank) rank of the non-robust covariance matrix 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)

Macros e(cmd) qreg2 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(marginsnotok) predictions disallowed by margins

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

Functions e(sample) marks estimation sample


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(1), 189-202. Powell, J. L. (1984), Least Absolute Deviation Estimation for the Censored Regression Model, Journal of Econometrics, 25, 303-325. Wooldridge, J.M. (2009), Introductory Econometrics, 4th edition, Mason (OH): South Western.

Also see

Manual: [R] qreg

Help: [R] qreg postestimation;