help xtrobreghttp://github.com/benjann/xtrobreg/

Title

xtrobreg -- Pairwise-differences and first-differences robust regression

Syntax

Estimation

xtrobreg subcmd depvar indepvars [if] [in] [weight]
[, options ]

where subcmd is any of the subcommands supported by robreg.

Replaying results

xtrobreg [, reporting_options ]

Prediction

predict [type]
newvar [if] [in]
[, predict_options ]

Convert data

xtrobreg convert depvar [indepvars] [if] [in] [weight]
[, convert_options ]

options description

fd use first differences rather than pairwise differences

gmin(#) required minimum number of observations per group

gmax(#) allowed maximum number of observations per group

cluster(clustvar) specify custom cluster variable

vce(vcetype) use bootstrap or jackknife for
variance estimation

robreg_options any other options allowed by
robreg

A panel variable (and a time variable if fd is specified) must be
set; use xtset.

indepvars may contain factor variables; see fvvarlist.

pweights are allowed; see weight; weights must be constant within
groups unless fd is specified.

predict_options description

xb a + xb, fitted values; the default

ue u_i + e_it, the combined residual

xbu a + xb + u_i, prediction including fixed effect

u u_i, the fixed effect

e e_it, the idiosyncratic error

convert_options description

fd generate first differences rather than pairwise differences

gmin(#) required minimum number of observations per group

gmax(#) allowed maximum number of observations per group

wvar(newvarname) custom name for weights variable

keep(varlist) additional variables to be kept in the data

clear overwrite current data in memory

A panel variable (and a time variable if fd is specified) must be
set; use xtset.

pweights and iweights are allowed; see weight; weights must
be constant within groups unless fd is specified.

Description

xtrobreg provides robust pairwise-differences estimators and robust
first-differences estimators for panel data. In case of least-squares
regression, the pairwise-differences estimator is equivalent to the
fixed-effects estimator. See Aquaro and Cizek (2010) for a discussion of
robust estimation based on pairwise differences.

xtrobreg works by applying robreg to appropriately transformed
data. xtrobreg restores the original data after estimation. Alternatively,
use xtrobreg convert to transform the data permanently and then apply
robreg manually (typically including option noconstant; see
example below). Note that xtrobreg convert also converts the
time variable (if a time variable has been set; that is, the resulting
time variable will contain time differences) and that xtset will be
cleared. A limitation of xtrobreg convert is that it does not allow factor variables.

xtrobreg requires robreg and moremata. See
ssc describe robreg
and
ssc describe moremata.

Options

xtrobreg

fd requests that the first-differences estimator be
computed. The default is to compute the pairwise-differences estimator. For
least-squares regression, the pairwise-differences estimator is equal to the
fixed-effects estimator. Option fd requires a time variable to be set.

In any case, the data from which the differences are computed will be
restricted to (non-missing) observations satisfying the if and in qualifiers, and
differences will be taken irrespective of whether there are gaps in the
time line. This means that option fd behaves differently from how
time-series operators work in Stata. If you are interested in a
first-differences estimate that treats the data in a way that is consistent
with time-series operators, you can use robreg with time-series
operator D. and option noconstant (see
example below).

gmin(#), with #>=2, specifies the required minimum number of
observations per group. The default is gmin(2). Groups with less than
# observations will be excluded from the estimation sample.

gmax(#), with #>=2, specifies the allowed maximum number of
observations per group. The default is to impose no limit. Groups with more
than # observations will be excluded from the estimation sample.

cluster(clustvar) specifies a custom cluster variable for influence-function based
standard errors. The default is to cluster on panel groups.

vce(vcetype) may be used to request replication-based variance
estimation; see bootstrap and jackknife in
vce_option. You may want to specify the
cluster(), idcluster(), and group() suboptions. The default is to report
cluster-robust standard errors based on influence functions.

robreg_options are any other options allowed by robreg.

predict

xb generates fitted values (a + xb). This is the default. The overall
constant, a, is computed as the mean (xtrobreg ls), quantile (xtrobreg q),
or median (all other estimators) of y - xb.

ue generates combined residuals (u_i + e_it).

xbu generates predictions including fixed effects (a + xb + u_i).

u generates the fixed effects (u_i). The fixed effects are computed as
group-specific means (xtrobreg ls), quantiles
(xtrobreg q), or medians (all other estimators) of y - (a + xb).

e generates the idiosyncratic errors (e_it).

convert

fd generates first differences. The default is to generate pairwise
differences.

gmin(#), with #>=2, specifies the required minimum number of
observations per group. The default is gmin(2). Groups with less than
# observations will be excluded from the converted data.

gmax(#), with #>=2, specifies the allowed maximum number of
observations per group. The default is to impose no limit. Groups with more
than # observations will be excluded from the converted data.

wvar(newvarname) specifies a custom name for the weights variable generated
by xtrobreg convert. The default name is _weight. Let wexp be the
the weights expression that was specified when calling xtrobreg convert (with
wexp=1 if weights were omitted). Furthermore, let n_g be the number
of observations in a group and let n_avg be the average group
size (unweighted). In case of pairwise differencing, the weights generated by
xtrobreg convert are equal to wexp * n_avg/n_g. In case of
first differencing (option fd), the weights are equal to wexp.

keep(varlist) specifies additional variables to be kept in the converted
data. These variables must be constant within groups unless fd is specified.

clear specifies that the data may be converted even though the dataset
has changed since it was last saved on disk.

Examples

Pairwise-differencing (fixed-effects) estimator

. webuse xtdatasmpl, clear
. xtreg ln_w age* ttl_exp* tenure* not_smsa south, fe cluster(idcode)
. xtrobreg ls ln_w age* ttl_exp* tenure* not_smsa south
. xtrobreg mm ln_w age* ttl_exp* tenure* not_smsa south

Using manually transformed data

. webuse xtdatasmpl, clear
. xtrobreg convert ln_w age* ttl_exp* tenure* not_smsa south, wvar(wt)
. robreg ls ln_w age* ttl_exp* tenure* not_smsa south [pw=wt], noconstant cluster(idcode)
. robreg s ln_w age* ttl_exp* tenure* not_smsa south [pw=wt], noconstant cluster(idcode)
. robreg mm, efficiency(75)
. robreg mm, efficiency(85)

Note that option noconstant must be specified with robreg in the transformed data
to obtain correct point estimates. Furthermore, to obtain standard errors as reported
by xtrobreg you need to cluster on the panel variable.

Option fd is different from time-series operator D.

. webuse xtdatasmpl, clear
. robreg ls D.(ln_w age* ttl_exp* tenure* not_smsa south), noconstant cluster(idcode)
. xtrobreg ls ln_w age* ttl_exp* tenure* not_smsa south, fd

Since some of the panels contain gaps, the two commands do
not yield the same results. Option fd takes differences between
consecutive observations irrespective of whether there is a gap or not,
whereas the D. operator only takes a difference if there is no gap. If
we redefine the time variable so that there are no gaps, robreg D.()
will yield the same results as xtrobreg, fd:

. drop if e(sample)==0
. bysort idcode (year): generate tvar = _n
. xtset idcode tvar
. robreg ls D.(ln_w age* ttl_exp* tenure* not_smsa south), noconstant cluster(idcode)

Stored results

In addition to the results from robreg, xtrobreg saves the following
results in e().

Scalars

e(N_g) number of groups

e(g_min) minimum number of observations per group

e(g_avg) average number of observations per group

e(g_max) maximum number of observations per group

e(_cons) value of overall constant

Macros

e(cmd) xtrobreg

e(predict) xtrobreg predict

e(ivar) name of panel variable

e(tvar) name of time variable (if set)

e(model) pd or fd

xtrobreg convert saves the following results in r().

Scalars

r(N_g) number of groups

r(g_min) minimum number of observations per group

r(g_avg) average number of observations per group

r(g_max) maximum number of observations per group

Macros

r(ivar) name of panel variable

e(tvar) name of (differenced) time variable (if set)

r(wvar) name of weights variable

e(model) pd or fd

References

Aquaro, M., P. Cizek (2010). One-Step Robust Estimation of Fixed-Effects
Panel Data Models. CentER Discussion Paper No. 2010-110. Tilburg
University. [link]

Author

Ben Jann, University of Bern, ben.jann@soz.unibe.ch

Vincenzo Verardi, University of Namur and Universite libre de Bruxelles

Thanks for citing this software as follows:

Jann, B., V. Verardi (2021). xtrobreg: Stata module providing pairwise-differences and
first-differences robust regression estimators. Available from
http://ideas.repec.org/c/boc/bocode/s458937.html.

Also see

xtreg,
xtset,
robreg