*! version 2.6 Fernando Rios-Avila May 2021
help rifvar()

Title

rifvar() -- Extension to generate recentered influence
functions

Syntax

egen [type] newvar =
rifvar(varname)
[if] [in]
[, options]

egen [type] newvar =
rifvar_old(varname)
[if] [in]
[, options]

options

Main
by(varname) indicate the variables over which the recentered
influence
functions (RIFs) will be estimated

weight(varname) indicate the weight to be used for the estimation of RIFs

seed(str) indicate a particular seed for replication
of rank-dependent indices. no longer needed with newer algorithm

RIF_options
mean sample mean

var variance

q(#p) [kernel(kernel) bw(#)] pth quantile, where
0<#p<100;
the kernel functions available are gaussian (default), epan,
epan2, biweight, cosine, parzen, rectan,
triangle, and triweight;
all kernel functions available for the
command kdensity are also allowed; bandwidth default is the Silverman's plugin optimal bandwidth

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) generalized 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(#|varname) Foster-Greer-Thorbecke
poverty index given sensitivity parameter #a; pov(0) obtains the
poverty head count, pov(1) obtains the poverty gap, and pov(2)
obtains the poverty
severity; Foster-Greer-Thorbecke indices
are defined based on the poverty line pline(), which can be a scalar
(fixed poverty line) or a variable (variable poverty line)

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; one can potentially use
analytical methods or numerical methods (like jackknife) to estimate the RIF
functions; community-contributed programs should be compatible to be used
with egen and should allow for two options: by() and
weight; other options are allowed;
to use it, the name of the program should be indicated in rifown(),
whereas options other than weight or by() would go in
rifopt();
see the file _ghvar.ado for a template of a program;
this program estimates the RIF for half-variance using jackknife methods;
the option hvp estimates the RIF positive half-variance, and hvn
estimates the RIF negative half-variance;
an example of how it can be used with oaxaca_rif and rifhdreg
is available in their respective help files

Description

egen rifvar() creates a new variable, newvar, of the
optionally specified storage type equal to the RIF of the specified statistic,
over a set of groups specified with by() and considering weights
specified by weight(). The newest version uses Mata for all RIF calculations
improving the precision and stability of some concentration and rank dependence indices.
For replication purposes, one can use the older program now named rifvar_old()

Remarks

The function rifvar() creates a corresponding RIF for the specified
distributional statistic (see RIF_options), over a
set of groups defined in by() and allowing for the use of weights
weight().

Because of their nature, rank-dependent indices like the concentration ratio
may be slightly different every time if there are ties within
observations. In the newest algorithm, this has been fixed, and seed is no longer needed.

A similar problem is observed with indices like the Lorenz and generalized
Lorenz coordinates. To obtain indices that can be fully replicated, one can
use the option seed(). This option creates an auxiliary random variable
that is used to break the ties when ranking observations.

To allow for greater flexibility with the commands oaxaca_rif and
rifhdreg, one can use the options rifown(str) and
rifopt(str) to apply other community-contributed commands.

Acknowledgments

Some of the RIF derivations were taken based on the community-contributed
command rifreg and the do-file for rifireg.

The derivations of the RIFs for all the other statistics were taken from
various sources, all cited in the reference section.

An intuitive description of RIFs, RIF regressions, and RIF decompositions is
provided in Rios-Avila (2020). The appendix of that article also provides the
exact formulas used for defining the RIFs, as well as the sources that were
used to obtain them.

All errors are my own.

Reference

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: rifhdreg, rifreg, rifsureg, rifsureg2,
uqreg, hvar() (if installed), [D] egen