*! version 1.0.0 18jul2026

Title

xtrobust -- Robust estimation of linear panel models (S-estimator and WLE)

Syntax

xtrobust depvar indepvars [if] [in], fe|re [options]

Model (one required)
fe fixed-effects (within-transformed) robust fit

re random-effects (quasi-demeaned) robust fit

Estimator
method(s|wle|all) which robust estimator(s) to report; default all

nsamp(#) elemental subsamples for fast-S; default nsamp(200)

csteps(#) concentration steps per fast-S subsample; default csteps(2)

tune(#) Tukey biweight tuning constant c; default tune(1.547)

bconst(#) M-scale target K; default bconst(0.199)

bwidth(#) WLE kernel bandwidth, as a multiple of the robust scale; default bwidth(0.5)

seed(#) random-number seed for fast-S

Reporting
level(#) confidence level; default level(95)

graph draw the weight and residual diagnostic figures

name(string) stub for graph names; default name(xtrobust)

Description

xtrobust fits linear panel-data models robustly, resisting outliers that
would bias ordinary least squares. It implements the two estimators studied by
Jaseem and Mohammad (2024):

o the S-estimator (Rousseeuw-Yohai), which minimises a robust
M-scale of the residuals using Tukey's biweight, with a 50% breakdown point;

o the Weighted Likelihood Estimator (WLE) (Agostinelli-Markatou),
which down-weights observations whose residual density departs from the model
density, via a Pearson residual and a residual-adjustment function.

For fe, the data are within-transformed (each observation minus its panel
mean, no constant). For re, the data are quasi-demeaned with the
Swamy-Arora weight {&lambda}i obtained from a preliminary
xtreg, re. The robust estimator is then applied to the transformed
data. OLS on the same transformed data is reported alongside for comparison.

Options

method(s|wle|all) chooses the estimator(s). All three columns
(OLS, S, WLE) are always shown; method() is retained for stored-result
labelling and future extension.

nsamp(#) and csteps(#) control the fast-S resampling
algorithm: nsamp random elemental subsets, each refined by csteps
concentration (I-)steps, keeping the fit with the smallest M-scale, followed by
full IRLS convergence. Increase nsamp for a harder problem.

tune(#) and bconst(#) are the biweight tuning constant and
the M-scale target. The defaults c=1.547, K=0.199 give the 50%
breakdown, consistency-at-normal S-estimator of the source paper (note
K = c^2/6 {&divide} 2).

bwidth(#) is the Gaussian kernel bandwidth of the WLE, expressed as
a multiple of the robust scale. Smaller values sharpen the density comparison
and down-weight more aggressively.

Method

See xtoutliers methods for the equation map. The
biweight {&rho}(u) = u^2/2 - u^4/(2c^2) + u^6/(6c^4)
for |u|{&le}c; the S-estimator solves
{&beta}^ = argmin {&sigma}S, with {&sigma}S
the M-scale defined by mean {&rho}(ri/{&sigma}) = K. The WLE
weight is wi = min{1, [A({&delta}i)+1]+/({&delta}i+1)}
with RAF A({&delta}) = 2[({&delta}+1)^(1/2)-1] and Pearson
residual {&delta}i = f*(ri)/m*(ri)-1.

Interpreting the output

o OLS / S-est / WLE columns - coefficients with standard errors
in parentheses; significance stars from the respective t/z. Compare the robust
columns with OLS to see the pull of outliers.

o S-scale / WLE-scale - the robust residual scale from each
estimator; much smaller than the OLS residual SD when outliers are present.

o graph - (a) S weights and (b) WLE weights by observation
(values near 0 are down-weighted outliers); (c)-(d) residual-versus-fitted
plots for each estimator.

Examples

. webuse nlswork

. xtrobust ln_wage age tenure hours, fe method(all) seed(123) graph

. xtrobust ln_wage age tenure hours, re

Stored results

Scalars

r(N) number of observations

r(k) number of regressors

r(scaleS) S-estimator M-scale

r(scaleWLE) WLE residual scale

Macros

r(model) fe or re

r(method) requested method

r(depvar) dependent variable

Matrices

r(b_ols), r(V_ols) OLS coefficients and variance

r(b_s), r(V_s) S-estimator coefficients and variance

r(b_wle), r(V_wle) WLE coefficients and variance

References

Jaseem, H.N., and L.A. Mohammad. 2024. Detecting Outliers and Using
Robust Methods in Linear Panel Data Model. Al-Nahrain Journal of Science
27(4): 40-46.

Rousseeuw, P.J., and V.J. Yohai. 1984. Robust regression by means of
S-estimators. In Robust and Nonlinear Time Series Analysis. Springer.

Agostinelli, C., and M. Markatou. 1998. A one-step robust estimator for
regression based on the weighted likelihood reweighting scheme.
Statistics & Probability Letters 37: 341-350.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

github.com/merwanroudane