*! version 1.0.2 Nicolai T. Borgen 15june2022
help rqr

Title

rqr -- Residualized quantile regression (RQR)

Syntax

rqr depvar indepvars [if] [in] [weight],
[quantile(numlist) controls(varlist) absorb(varlist)
step1command(string) step2command(string)
options_step1(string) options_qreg(string)
options_qrprocess(string) options_predict(string)
generate_r(varname) smoothing(a,b) print1step
options]

options

quantile(numlist) specifies the quantile and can be either one
quantile or a range of quantiles. The default is quantile(.5).

controls(varlist) lists the control variables to be included in the
first-step regression. High-dimensional fixed effects should be included in the
absorb() option.

absorb(varlist) lists the fixed effects to be included in the
first-step regression. The default estimator is areg when one fixed
effects is listed and the user-written reghdfe when more than one
fixed effects are included.

step1command(string) decides the first-step estimator.
The default is regress when no fixed effects are included, areg
when one fixed effects is included, and the user-written reghdfe when
more than one fixed effects are included.

step2command(string) decides the second-step quantile regression
model. qreg is the default when one quantile is specified in the
quantile(numlist) and the user-written qrprocess is default when
more than one quantile is specified.

options_step1(string) passes options along to the first-step
regression model.

options_qreg(string) passes options along to the second-step
qreg command.

options_qrprocess(string) passes options along to the second-step
qrprocess command.

options_predict(string) passes options along to the predict
command that is carried out after the first-step regression. The default is
residuals.

generate_r(varname) saves a variable containing the residuals from
the first-step regression.

smoothing(a,b) adds uniformly distributed noise over the interval
[a,b] to the outcome variable.

print1step displays the first-step regression.

pweights, fweights, and iweights are allowed; see weight.

Description

rqr fits the residualized quantile regression (RQR) model developed by
Borgen, Haput, and Wiborg (2021a),
which estimates unconditional quantile treatment effects. This RQR model is a
flexible and fast approach that can easily handle all types of control variables,
including high-dimensional fixed effects. The treatment variable (or independent
variable of interest) should be placed in indepvars, control variables
(if any) in the controls(varlist) option, and fixed effects (if any)
in the absorb(varlist) option.

The rqrplot postestimation command can be used to plot the coefficients and
confidence interval effortless.

See Borgen, Haput, and Wiborg (2021b)
for descriptions and examples of the
rqr and rqrplot commands.

Options

quantile(numlist) specifies the quantile and can be either one quantile or a
range of quantiles. The specified quantile(s) should be number(s) between 0
and 1. All shorthands described in numlist are allowed, including
quantile(.03(.02).97). The default quantile is quantile(.5).

controls(varlist) lists the control variables to be included in the
first-step regression. Factor-variable operators are allowed (fvvarlist).
Including (high-dimensional) fixed effects in the controls(varlist)
option is inefficient and fixed effects should instead be included in the
absorb(varlist) option.

absorb(varlist) lists the fixed effects to be included in the
first-step regression. The default estimator is areg when one fixed
effects is listed and the user-written reghdfe when more than one
fixed effects are included.

step1command(string) decides the first-step estimator.
The default is regress when no fixed effects are included, areg
when one fixed effects is included, and the user-written reghdfe when
more than one fixed effects are included.

step2command(string) decides the second-step quantile regression
model. The default when one quantile is specified in the quantile(numlist)
option is qreg. When more than one quantile is specified, the
user-written qrprocess command is the default, and the user cannot
choose the qreg option. To get the qreg estimator with more than
one quantile, add option options_qrprocess(method(qreg)).

options_step1(string) passes options along to the first-step
regression model. See regress options,
areg options, and
reghdfe options for list of available options
in the different first-step regressions. First-step options are rarely needed.
One exception is if the user wants to include singleton groups in the reghdfe
command, which can be achieved by adding the option options_1step(keepsingletons).

options_qreg(string) passes options along to the second-step
qreg command. See qreg options for list of
available options.

options_qrprocess(string) passes options along to the second-step
qrprocess command. See qrprocess options
for list of available options.

options_predict(string) passes options along to the predict
command that is carried out after the first-step regression. The default is
residuals.

generate_r(varname) saves a variable containing the residuals from
the first-step regression.

smoothing(a,b) adds uniformly distributed noise over the interval
[a,b] to the outcome variable.

print1step displays the first-step regression.

Examples

Setup

. webuse nlswork

Union wage effects on single quantile with control variables.

. rqr ln_wage union, quantile(.90) controls(year c.grade##c.grade south i.ind_code)

Union wage effects on multiple quantiles with control variables.

. rqr ln_wage union, quantile(.03(.02).97) controls(year c.grade##c.grade south i.ind_code)

Union wage effects on multiple quantiles with one fixed effects variable.

. rqr ln_wage union, quantile(.03(.02).97) controls(year c.grade##c.grade south i.ind_code) absorb(idcode)

Union wage effects on multiple quantiles with multiple fixed effects variables.

. rqr ln_wage union, quantile(.03(.02).97) controls(year c.grade##c.grade south i.ind_code) absorb(idcode occ_code)

Bootstrapping standard errors.

. bootstrap, reps(200): rqr ln_wage union, quantile(.03(.02).97) controls(year c.grade##c.grade south i.ind_code) absorb(idcode occ_code)

Plotting coefficients after rqr; see rqrplot for more details.

. rqrplot

Stored results

rqr stores the following in e():

Scalars

e(N) number of observations

e(first_step_r2) first-step R-squared

e(first_step_re_a) first-step adjusted R-squared

e(df_r) residual degrees of freedom

e(f_r) density estimate

e(df_m) model degrees of freedom

e(sum_w) sum of weights

e(q_v) value of quantile

e(q) quantile requested

e(sum_rdev) sum of raw deviations

e(sum_adev) sum of absolute deviations

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

Macros

e(cmd) Second-step QR model

e(cmdname) rqr

e(cmdline) command as typed

e(treatment) treatment variable

e(controls) control variables

e(properties) b V

e(estat_cmd) program used to implement estat

e(predict) program used to implement predict

e(bwmethod) bandwidth method; hsheather, bofinger, or chamberlain

e(vce) vcetype specified in vce()

e(method) algorithmic method

e(depvar) name of dependent variable

e(title) Quantile regressions

e(marginsnotok) predictions disallowed by margins

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(coefmat) coefficient matrix

e(quantiles) estimated quantiles

e(sum_rdev) sum of absolute deviations

e(sum_mdev) sum of raw deviations

Functions

e(sample) marks estimation sample

In addition to the above, the following is stored in r():

Matrices

r(table) matrix containing the coefficients with their standard
errors, test statistics, p-values, and confidence intervals

Version requirements

The rqr command requires Stata 12.0 or later.

Package dependencies

To use all the functionalities of the rqr command, you should download
the qrprocess (Chernozhukov et al. 2020) and reghdfe
(Correia 2016) commands. To install these commands, type:

. ssc install qrprocess

. ssc install reghdfe

Reference

Borgen, Haupt, and Wiborg (2021a)
A New Framework for Estimation of Unconditional Quantile Treatment Effects:
The Residualized Quantile Regression (RQR) Model. SocArXiv.
doi:10.31235/osf.io/42gcb

Borgen, Haupt, and Wiborg (2021b)
Flexible and fast estimation of quantile treatment effects: The rqr and rqrplot
commands SocArXiv. doi:10.31235/osf.io/4vquh

Chernozhukov, V., I. Fernández-Val, and B. Melly (2020). Fast algorithms for the
quantile regression process. Empirical economics 1–27.

Correia, S. (2016). Linear Models with High-Dimensional Fixed Effects: An Efficient and
Feasible Estimator. Technical report. Working Paper.

Authors

Nicolai T. Borgen, University of Oslo

n.t.borgen@isp.uio.no

Andreas Haupt, Karlsruhe Institute of Technology

andreas.haupt@kit.edu

Øyvind Wiborg, University of Oslo

o.n.wiborg@sosge.uio.no

Thanks for citing this software in one of the following ways:

Borgen, NT., A. Haupt, and ØN. Wiborg (2021).
A New Framework for Estimation of Unconditional Quantile Treatment Effects:
The Residualized Quantile Regression (RQR) Model. SocArXiv.
doi:10.31235/osf.io/42gcb

Borgen, Haput, and Wiborg (2021b)
Flexible and fast estimation of quantile treatment effects: The rqr and rqrplot
commands SocArXiv. doi:10.31235/osf.io/4vquh