*! version 2.4 Fernando Rios-Avila May 2021
help rifhdreg

Title

rifhdreg -- Recentered influence function regression with high-dimensional fixed effects

Syntax

rifhdreg depvar [indepvars] [if] [in] [weight], rif(RIF_options)
[retain(newvar) replace abs(varlist) iseed(str)
over(varname)
rwlogit(varlist) rwprobit(varlist) rwmlogit(varlist)
rwmprobit(varlist) [ate|att|atu]
scale(real)
svy
regress_options reghdfe_options]

bsrifhdreg depvar [indepvars] [if] [in] , rif(RIF_options)
[retain(newvar) replace abs(varlist) iseed(str)
over(varname)
rwlogit(varlist) rwprobit(varlist) rwmlogit(varlist)
rwmprobit(varlist) [ate|att|atu]
scale(real)
bootstrap_options
regress_options reghdfe_options]

options

* rif(RIF_options) specify the recentered influence function (RIF) statistic used as outcome; see
rifvar() for details on the distributional statistics currently allowed

retain(newvar) specify a new variable where the generated RIF will be stored based on the sample used in the regression

replace when retain() is specified,
overwrite the variable retain(newvar) if it already exists

abs(varlist) identify the fixed effects to be absorbed; each variable listed here represents one set of fixed effects

iseed(str) indicate a particular seed for
replication of rank-dependent indices

over(varname) indicate a variable over which the RIF will be estimated; this can be understood as a partial conditional RIF; when the variable
used is binomial, the regression can be seen as the ordinary least-squares
(OLS) alternative to Oaxaca-Blinder decomposition

rwlogit(varlist) specify the logit regression for the
estimation of the reweighting factors; the variable used in over() is
used as the dependent variable;
this can be used to obtain estimates akin to treatment effects under the assumption of exogeneity

rwprobit(varlist) specify the probit regression for the
estimation of the reweighting factors; the variable used in over() is
used as the dependent variable;
this can be used to obtain estimates akin to treatment effects under the assumption of exogeneity

trim(numlist) specifies the min and max values to trim the propensity score, when rwlogit/rwprobit
are used. This is done to reduce the sensitivy of the IPW strategy when the predicted score is close to 0 or 1.

rwmlogit(varlist) specify the mlogit regression for the
estimation of the reweighting factors; the variable used in over() is
used as the dependent variable;
this can be used to obtain estimates akin to multivalued treatment effects under
the assumption of exogeneity; only average treatment effects (ate) are allowed

rwmprobit(varlist) specify the mprobit regression for the
estimation of the reweighting factors; the variable used in over() is
used as the dependent variable;
this can be used to obtain estimates akin to multivalued treatment effects under
the assumption of exogeneity; only average treatment effects (ate) are allowed

[ate|att|atu] indicate which estimator will be
obtained using the reweighted factors; the default is to estimate the average
treatment effect (ate);
one can also specify to obtain treatment effect on the treated (att) or on the untreated (atu)

scale(real) provide a value for rescaling the dependent
variable

svy obtain estimates using survey design; does not
work when fixed effects are included (option abs())

regress_options when abs() is not used, all options in
regress can be used

reghdfe_options when abs() is used, all options in
reghdfe can be used; requires reghdfe be installed

bootstrap_options The command bsrifhdreg is a wrapper around rifhdreg that allows to more easily implement bootstrap standard errors. Specifically, it's use is recommended for plotting unconditional quantile regressions with qregplot.

If using this command, one can use the following options: reps(int 50), strata(), seed(), bca, TIEs, cluster(varname), idcluster(newvarname), nodots, level() and force. see bootstrap for details.

old This option request using the older rifvar function (for replication purposes).

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

* rif() is required.

RIF options

The option rif(RIF_options) allows one to specify a large set of RIF
statistics that can be used to define the dependent variable for modeling.
The RIF statistic is first obtained using the egen function
rifvar(), which is then used as the dependent variable in an
OLS model that is fit using regress or reghdfe when fixed effects
are specified. For more details on the available options, see
rifvar() and Rios-Avila (2019).

RIF_options

mean sample mean

var variance

q(#p) [kernel(kernel) bw(#)] pth quantile, where
0<#p<100;
default is to use a gaussian kernel;
all kernel functions available for the
command kdensity are also allowed; default is
the Silverman's plugin optimal bandwidth;
full kernel name should be used instead of abbreviations (for example, use
biweight instead of bi); the only exception is that when requesting the
Epanechnikov kernel, one should use epan

iqr(#p1 #p2) [kernel(kernel) bw(#)] interquantile
range: q(#p2) - q(#p1), where 0<p1<=p2<100; bw()
and kernel() are the same as for the quantile case

gini Gini inequality index

cvar coefficient of variation

std standard deviation

iqratio(#p1 #p2) [kernel(kernel) bw(#)] interquantile ratio:
q(#p2)/q(#p1), where 0<p1<=p2<100;
bw() and kernel() are the same as for the quantile case

entropy(#a) entropy inequality index with sensitivity index
#a

atkin(#e) Atkinson inequality index with inequality aversion
#e>0

logvar logarithmic variance (different from variance of logarithms)

glor(#p) generalized Lorenz ordinate at #p, where 0<#p<100

lor(#p) Lorenz ordinate at #p, where 0<#p<100

ucs(#p) share of income held by richest 1-p%; 1-lor(#p)

iqsr(#p1 #p2) interquantile share ratio:
(1-lor(#p2))/lor(#p1),
where 0<p1<=p2<100

mcs(#p1 #p2) share of income held by people between #p1 and
#p2: lor(#p2)-lor(#p1), where 0<#p1<#p2<100; also known as P_shares

pov(#a) pline(#|var) Foster-Greer-Thorbecke poverty
measure with sensitivity parameter #a>=0 and poverty line defined by
pline(); pline() can be a single number or a variable

watts(#povline) Watts poverty index; requires a number or variable to define the poverty line

sen(#povline) Sen poverty index; requires a number to define the poverty line

tip(#p) pline(#) three I's of poverty (TIP) curve ordinate at
#p for poverty line defined by pline(#), where 0<#p<100

agini absolute Gini

acindex(varname) absolute concentration index using varname as the rank variable

cindex(varname) concentration index using varname as the rank variable

eindex(varname) lb(#) ub(#) Erreygers's index using
varname as
the rank variable, with lower bound lb() and upper bound ub()
and where
lb()<ub()

arcindex(varname) lb(#) attainment relative concentration index
using varname as the rank variable, with lower bound lb()

srindex(varname) ub(#) shortfall relative concentration index
using varname as the rank variable, with upper bound ub()

windex(varname) lb(#) ub(#) Wagstaff concentration index using
varname as the rank variable, with lower bound lb() and upper
bound ub()
and where lb()<ub()

rifown(str) rifopt(str) these options are added to enable
rifvar() to use other community-contributed programs to estimate RIF for
statistics not available in this list

Description

rifhdreg is a wrapper command that uses the capabilities of regress
and reghdfe to estimate recentered influence function (RIF)
regressions. When requested, it fits models with multiple fixed effects
similarly to the community-contributed command xtrifreg but based on
reghdfe, which permits one to include a larger set of fixed effects.

The best-known use of RIF regressions is the estimation of unconditional
quantile regressions (Firpo, Fortin, and Lemieux 2009), but they have also
been proposed for the analysis of other distributional statistics, including
the Gini and the variance (Firpo, Fortin, and Lemieux 2018), entropy index,
Atkinson index (Cowell and Flachaire 2007), poverty indices, Lorenz and
general Lorenz ordinates (Essama-Nssah and Lambert 2012), and bivariate
inequality indices (Heckley, Gerdtham, and Kjellson 2016).

The command fits the RIF-regression model in two steps. First, it
estimates the RIF for the distributional statistic of interest using
rifvar(). Second, it uses the estimated RIF as dependent
variable and fits the RIF model using regress if no fixed effects are
declared or reghdfe if the fixed effects are declared via
abs(varlist). For an intuitive description of RIFs and this command, see
Rios-Avila (2019).

Because rifhdreg is a wrapper for both regress and reghdfe,
all the options for both commands are allowed. Thus, by default, OLS standard
errors are reported, but both robust and clustered standard errors can be
requested following regress or reghdfe syntax. Note, however,
that Firpo, Fortin, and Lemieux (2009, 2018) suggest to estimate standard
errors using bootstrap methods because of the intermediate steps used for the
estimation of the RIF functions.

For the correct estimation of bootstrap standard errors, one should
use the bootstrap prefix rather than vce(bootstrap) to apply the
bootstrap through the whole estimation process. See
Examples for further
details.

On the other hand, Cowell and Flachaire (2007) and Deville (1999) indicate
that RIFs can be used to easily estimate asymptotic standard errors of complex
distributional functions, in which case reporting robust standard errors
should suffice. In Rios-Avila (2019), Monte Carlo simulations are run,
showing that robust standard errors seem to be appropriate for statistical
inference for most statistics used here except for the Atkinson inequality
index with an inequality aversion index greater than 2 and for statistics that
are constructed based on unconditional quantiles.

The options acindex(), cindex(), and eindex() estimate the
concentration index based on an additional ranking variable. If the sorting
variable has ties, the results may not be reproducible because they will
depend on the order of the main variable of interest.

The option iseed() can be used for the replication of results when using
rank-dependent indices. Otherwise, RIFs for these indices may vary because of
the presence of ties in the distribution of the dependent variable.

The option over() can be used to estimate RIFs over a single categorical
variable. This can be thought of as a shortcut to estimate the difference in
distribution across a finite number of groups while controlling for other
characteristics. Using this option can also be thought of as the equivalent
to doing a regression adjustment treatment-effect analysis.

The options rwlogit() and rwprobit() can be used in combination
with over() for the estimation of treatment effects using inverse
probability weighting. This procedure is based on the parametric strategy
described in Firpo and Pinto (2016). This can be thought of as the equivalent
to teffects, ipwra. This makes the estimator a double robust estimator
for treatment effects on distributional statistics under the assumption of
exogeneity of the treatment.

If rwlogit() or rwprobit() is specified, one can also include the
treatment effect to be estimated, which can be average treatment effect
(ate), average treatment effect on the treated (att), or average
treatment effect on the untreated (atu). When using these options, it
is recommended to use the bootstrap prefix to obtain correct standard
errors.

It is also possible to use rwmlogit() or rwmprobit() to request
the estimation of multivalued treatment effects akin to Cattaneo (2010) and
Cattaneo, Drukker, and Holland (2013). When one of these options is used,
only average treatment effects (ate) can be estimated. When using these
options, it is recommended to use the bootstrap prefix to obtain correct
standard errors. Different from Cattaneo, Drukker, and Holland (2013), the
treatment effects are estimated individually rather than jointly; see
rifsureg and rifsureg2 for joint estimations.

The option svy allows one to use survey design information for the
estimation of the RIF regressions. However, this does not correct for the
uncertainty implicit in the estimation of distributional statistics that are
functions of quantiles (or more specifically, density functions).

It is also possible to use the Prefix svy for the estimation of Bootstrap Standard
errors using survey design. This requires having access to Bootstrap weights.

rifhdreg typed without arguments replays the last results.

bsrifhdreg is a wrapper around rifhdreg. See examples for a syntaxis comparison. You should use this if you want to plot coefficient with bootstrapped standard errors using the command qregplot.

Examples

. use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta

Verify that reghdfe is installed and compiled in your computer. If
already installed, this step can be skipped.

. ssc install reghdfe, replace

. reghdfe, compile

. generate wage=exp(lnwage)

RIF regression for the mean.

. rifhdreg lnwage educ exper tenure, rif(mean)

RIF regression for the 10th quantile, using robust standard errors.

. rifhdreg lnwage educ exper tenure, rif(q(10)) robust

RIF regression for the 90-10 interquantile difference, using clustered
standard errors at age.

. rifhdreg lnwage educ exper tenure, rif(iqr(90 10)) cluster(age)

RIF regression for the Gini coefficient, using robust standard errors.

. rifhdreg wage educ exper tenure, rif(gini) robust

RIF regression for the 90-50 interquantile difference, using clustered
standard errors at age. Retaining RIF statistic.

. rifhdreg lnwage educ exper tenure, rif(iqr(90 50)) retain(rif_q9050) cluster(age)

. summarize rif_q9050

RIF regression for the 50 quantile difference, using clustered standard errors
at age. Retaining RIF statistic.

. rifhdreg lnwage educ exper tenure, rif(q(50)) retain(rif_q50) cluster(age)

. summarize rif_q50

RIF regression for the Gini coefficient, using robust standard errors and one
fixed effect (age). Note that because we are using abs(age),
reghdfe
does not allow us to use robust. Instead, we need to use vce(robust).

. rifhdreg wage educ exper tenure, rif(gini) vce(robust) abs(age)

RIF regression for the Atkinson inequality index with coefficient = 1, using
robust standard errors and two fixed effects (age and isco).

. rifhdreg wage educ exper tenure, rif(atkin(1)) vce(robust) abs(age isco)

Estimation with bootstrap standard errors, and with the wrapper

. bootstrap: rifhdreg lnwage educ exper tenure, rif(q(10))

. bsrifhdreg lnwage educ exper tenure, rif(q(10))

Estimation with bootstrap standard errors with clusters.

. bootstrap, cluster(age): rifhdreg lnwage educ exper tenure, rif(q(10))

. bsrifhdreg lnwage educ exper tenure, rif(q(10)) cluster(age)

Estimation with bootstrap standard errors with clusters and fixed effects, but
fixed effects differ from cluster.

. bootstrap, cluster(age): rifhdreg lnwage educ exper tenure, rif(q(10)) abs(isco)

. bsrifhdreg lnwage educ exper tenure, rif(q(10)) abs(isco) cluster(age)

Estimation with bootstrap standard errors with clusters and fixed effects, with
fixed effects the same as cluster.

. bootstrap, cluster(age) idcluster(idage): rifhdreg lnwage educ exper tenure, rif(q(10)) abs(idage)

. bsrifhdreg lnwage educ exper tenure, rif(q(10)) abs(idage) cluster(age) idcluster(idage)

Replication of results using rifreg (requires installing the command
from the author's website).

. rifreg lnwage educ exper tenure, q(10)

. kdensity lnwage, nograph

. local bw=r(bwidth)

. rifhdreg lnwage educ exper tenure, rif(q(10) bw(`bw')) robust

Using community-contributed RIF function. Be sure to have the program
_ghvar in the right folder. This estimates the half-variance. See the
structure of _ghvar.ado as the template.

. rifhdreg lnwage educ exper tenure female age, rif(rifown(hvar) rifopt(hvn))

. rifhdreg lnwage educ exper tenure female age, rif(rifown(hvar) rifopt(hvp))

Estimation of treatment effects under exogeneity.

. webuse cattaneo2, clear

Treatment effect of smoking on the median.

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(50)) over(mbsmoke)

This would be different if over() is not included.

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(50))

Estimation of average treatment effect on the median using inverse-probability
weighting.

. rifhdreg bweight mbsmoke, rif(q(50)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

Comparing results with the teffects command.

. teffects ipwra (bweight) (mbsmoke prenatal1 mmarried mage fbaby, logit), ate

. rifhdreg bweight mbsmoke, rif(mean) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

Adjusted for covariates as well.

. teffects ipwra (bweight prenatal1 mmarried mage fbaby) (mbsmoke prenatal1 mmarried mage fbaby, logit), ate

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(mean) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

Treatment effects with inverse-probability weighting and adjusting for
covariates.

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(10)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(25)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(50)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(75)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

. rifhdreg bweight mbsmoke prenatal1 mmarried mage fbaby, rif(q(90)) over(mbsmoke) rwlogit(prenatal1 mmarried mage fbaby) ate

Estimation of multivalued treatment effects under exogeneity.

. use http://www.stata-press.com/data/r13/bdsianesi5, clear

Using teffects ipw.

. teffects ipw (wage) (ed math7 read7 maed paed)

Using rifhdreg.

. rifhdreg wage i.ed, rif(mean) over(ed) rwmlogit(math7 read7 maed paed)

Comparing results with poparms.

. ssc install poparms

. generate c=1

. poparms (ed math7 read7 maed paed) (wage c), q(.25 .5 .75) vce(bootstrap, reps(50))

Using rifhdreg.

. rifhdreg wage ibn.ed, rwmlogit(math7 read7 maed paed) over(ed) rif(q(25)) nocons

. rifhdreg wage ibn.ed, rwmlogit(math7 read7 maed paed) over(ed) rif(q(50)) nocons

. rifhdreg wage ibn.ed, rwmlogit(math7 read7 maed paed) over(ed) rif(q(75)) nocons

Simultaneous RIF regressions. The command suest does not work with
rifhdreg. For simultaneous unconditional quantile regressions, one
can use rifsureg. However, simultaneous RIF regressions with
suest are possible using a multiple-step approach.

Step 1: Estimation of the models of interest, saving the RIF functions.

. use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta, clear

. gen wage=exp(lnwage)

. rifhdreg lnwage educ exper tenure, rif(q(10)) retain(rifq10)

. rifhdreg lnwage educ exper tenure, rif(q(50)) retain(rifq50)

. rifhdreg lnwage educ exper tenure, rif(q(90)) retain(rifq90)

. rifhdreg lnwage educ exper tenure, rif(iqr(90 10)) retain(rifiqr9010)

. rifhdreg wage educ exper tenure, rif(gini) retain(rifgini)

Step 2: Estimation of RIF regressions using standard OLS using the retained
variables.

. regress rifq10 educ exper tenure

. estimates store m1

. regress rifq50 educ exper tenure

. estimates store m2

. regress rifq90 educ exper tenure

. estimates store m3

. regress rifiqr9010 educ exper tenure

. estimates store m4

. regress rifgini educ exper tenure

. estimates store m5

Step 3: Simultaneous estimation with suest.

. suest m1 m2 m3 m4 m5

Acknowledgments

This command is based on the community-contributed commands rifreg and
reghdfe.

This command requires the community-contributed command reghdfe by
Sergio
Correira to fit the models with multiple fixed effects.

RIF variables are estimated using the egen add-on rifvar().
An intuitive description of RIF regressions is provided in Rios-Avila (2019).

All errors are my own.

References

Cattaneo, M. D. 2010. Efficient semiparametric estimation of multi-valued
treatment effects under ignorability. Journal of Econometrics 155:
138-154. https://doi.org/10.1016/j.jeconom.2009.09.023.

Cattaneo, M. D., D. M. Drukker, and A. D. Holland. 2013.
Estimation of multivalued treatment effects under conditional independence.
Stata Journal 13: 407-450.

Cowell, F. A., and E. Flachaire. 2007. Income distribution and inequality
measurement: The problem of extreme values. Journal of Econometrics 141:
1044-1072. https://doi.org/10.1016/j.jeconom.2007.01.001.

Deville, J.-C. 1999. Variance estimation for complex statistics and
estimators: Linearization and residual techniques. Survey Methodology 25:
193-203.

Essama-Nssah, B., and P. J. Lambert. 2012. Influence functions for policy impact analysis. In Inequality, Mobility and Segregation: Essays in Honor of Jacques Silber, ed. J. A. Bishop and R. Salas, 135-159.
Bingley, UK: Emerald.

Firpo, S. P., N. M. Fortin, and T. Lemieux. 2009. Unconditional quantile
regressions. Econometrica 77: 953-973.
https://doi.org/10.3982/ECTA6822.

------. 2018. Decomposing wage distributions using recentered influence
function regressions. Econometrics 6: 28.
https://doi.org/10.3390/econometrics6020028.

Firpo, S. P., and C. Pinto. 2016. Identification and estimation of distributional impacts of interventions using changes in inequality measures. Journal of Applied Econometrics 31: 457-486.
https://doi.org/10.1002/jae.2448.

Heckley, G., U.-G. Gerdtham, and G. Kjellsson. 2016. A general method for decomposing the causes of socioeconomic inequality in health. Journal of Health Economics 48: 89-106.
https://doi.org/10.1016/j.jhealeco.2016.03.006.

Rios-Avila, F. 2020. Recentered influence functions (RIFs) in Stata: RIF regression and RIF decomposition.
Stata Journal, 20(1), 51-94. https://doi.org/10.1177/1536867X20909690.

Author

Fernando Rios-Avila

Levy Economics Institute of Bard College

Annandale-on-Hudson, NY

friosavi@levy.org

Also see

Help: rifvar(), rifhdreg, rifreg,
rifsureg, uqreg, hvar(), oaxaca_rif
(if installed), [R] regress