*! version 1.0.0 17jan2026
help xtselfe

Title

xtselfe -- Fixed-effects estimation with sample selection correction

Syntax

Estimation

xtselfe
depvar
indepvars
[if] [in],
select(depvar_s
[=]
varlist_s
[, sel_options])
[options]

Prediction

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

Model
* select() specify selection equation: dependent and independent variables

rhotype(type) type may be unrestricted, stationary, or common (equivalent to exchangeable);
unrestricted places no restriction on the intertemporal correlations, stationary imposes stationarity across lags, and common assumes exchangeability;
default is stationary

nointeract use bias-correction term that is not interacted with period dummies

SE/Robust
vce(vcetype) vcetype may be robust, delta #.#, unadjusted, or unadjusted cluster clustvar;
delta #.# uses cluster variance estimation at panelvar adjusted for the generated regressors, where #.# is the perturbation size for numerical differentiation;
default is robust, equivalent to delta 1e-4;
unadjusted cluster clustvar does not adjust for the generated regressors;
unadjusted is identical to unadjusted cluster panelvar

Reporting
first report the first-stage probit regression results

nolog suppress the intermediate messages;
nolog is ignored if both first and nolog are given

debug report some information if an error occurs

* select() is required.

indepvars and varlist_s may contain factor variables; see fvvarlist.

sel_options

mundlak[(varlist)] use the Mundlak device to account for correlated random effects in probit regression;
apply the device only to varlist when specified;
default is mundlak

chamberlain[(varlist)] use the Chamberlain device instead of the Mundlak device

none suppress the inclusion of any device;
equivalent to mundlak() or chamberlain()

pool use pooled probit regression;
not allowed with the Chamberlain device

statistic

xb calculate the linear prediction of a + xb;
the default

u calculate the prediction of the fixed effects, u(i)

e calculate the prediction of the errors, e(it)

ue calculate the prediction of u(i) + e(it)

xbu calculate the prediction of a + xb + u(i)

Description

xtselfe fits a fixed-effects linear regression model with sample selection.
It is a pooled weighted least squares estimation based on pairwise differences that eliminate fixed effects.
Correction terms for sample selection are constructed from probit regression and plug-in maximum likelihood estimation.
Standard errors obtained via the delta method are robust to the generated regressors problem.
xtselfe requires Stata 16 or later, with version 16.1 conservatively specified as the minimum requirement, as it relies on frames introduced in Stata 16.

Examples

Setup

. webuse wagework, clear

. xtset personid year

. global x "c.age##c.age tenure"

. global z "c.age##c.age market"

Fixed-effects estimation with sample selection correction

. xtselfe wage $, select(working = $)

. xtselfe wage $, select(working = $, chamberlain)

. xtselfe wage $, select(working = $) rhotype(unrestricted)

. xtselfe wage $, select(working = $) vce(delta 0.00001)

. xtselfe wage $, select(working = $) vce(unadjusted)

. xtselfe wage $, select(working = $, mundlak(market)) first

Joint test for the correction terms

. test [correction]

Stored results

xtselfe stores the following in e():

Scalars

e(N) number of observations

e(N_selected) number of selected observations

e(N_g) number of groups

e(N_clust) number of clusters

e(N_pairs) number of pairwise-differenced observations

e(T) number of time periods

e(df_m) model degrees of freedom

e(k_correct) number of correction terms

e(k_rho) number of serial corrections

e(n_probit_t) number of observations in probit for time t

e(k_probit_t) number of parameters in probit for time t

Macros

e(cmd) xtselfe

e(cmdline) command as typed

e(depvar) name of dependent variable

e(seldep) name of dependent variable in selection equation

e(ivar) variable denoting groups

e(clustvar) name of cluster variable

e(device) mundlak, chamberlain, or none

e(rhotype) type specified in rhotype()

e(vce) vcetype specified in vce()

e(vcetype) robust

e(predict) xtselfe_p

e(properties) b V

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix

e(V_unadj) unadjusted variance

e(b_rho) estimated serial corrections

e(b_probit_t) coefficient vector in probit for time t

e(V_probit_t) variance-covariance matrix in probit for time t

Functions

e(sample) marks estimation sample

Authors

Chirok Han

Department of Economics

Korea University

Seoul, Republic of Korea

chirokhan@korea.ac.kr

Goeun Lee

Department of Economics

Kookmin University

Seoul, Republic of Korea

goeunlee@kookmin.ac.kr