help robstathttp://github.com/benjann/robstat/

Title

robstat -- Robust univariate statistics

Syntax

robstat varlist [if] [in] [weight]
[,
options
]

options Description

Main
statistics(stats) statistics
to be computed; default is statistics(mean)

over(varname) compute results for subpopulations defined by
the values of varname

total include overall results across all subpopulations; only
allowed with over()

swap swap coefficients and equations

SE/SVY
vce(vcetype) vcetype may
be analytic (the default), cluster clustvar,
bootstrap or jackknife

cluster(clustvar) synonym for
vce(cluster clustvar)

svy[(subpop)] take account
of survey design as set by svyset, optionally restricting
computations to subpop

nose supress computation of standard errors and confidence
intervals

generate[(prefix)] stores the values of the
influence functions

replace allows overwriting existing variables

Normality tests
jbtest[(tests)] compute
generalized Jarque-Bera tests for normality

wald employ Wald tests based on the estimated variance-covariance
matrix

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

cilog use log-transformed confidence intervals for scale statistics

noheader suppress output header

notable suppress output table

display_options standard
reporting options as described in
[R] estimation options

Technical options
tolerance(#) tolerance for the M estimates; default is
tolerance(1e-10)

iterate(#) maximum number of iterations for the M estimates; default
is iterate(16000) or as set by set maxiter

kernel(kernel) type of kernel function for density estimation;
default is kernel(epan2)

bw(type) type of bandwidth selector for density estimation; default
is bw(dpi)

adaptive(#) number of repetitions for adaptive density
estimation; default is adaptive(2)

n(#) number of evaluation points for density estimation; default
is n(512)

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

Description

robstat estimates various classic and robust measures of location, scale,
skewness, and kurtosis, and, optionally, performs robust tests for normality. For
methodological details see Jann, Verardi and Vermandele (forthcoming).

robstat without varlist replays the previous results. Reporting
options may be applied.

robstat requires moremata. See
ssc describe moremata.

Options

Main

statistics(stats) specifies the statistics to be computed. statistics()
is not allowed if the jbtest option is specified (see below). stats
is a space-separated list of the following statistics (we use upper case
letters in some of the statistics for purpose of clarity, but note that
stats is not case sensitive). Default is statistics(mean).

Location

mean arithmetic mean

alpha[#] alpha-trimmed mean, where # specifies the
trimming percentage; default is alpha5

median median

HL Hodges-Lehmann estimator (Hodges and Lehmann 1963)

Huber[#] Huber M estimate of location, where #
specifies the desired gaussian efficiency; default is Huber95

biweight[#] biweight M estimate of location, where #
specifies the desired gaussian efficiency; default is biweight95

Scale

sd standard deviation

IQR interquartile range

IQRc rescaled interquartile range

MAD median absolute deviation

MADN rescaled median absolute deviation

Qn Qn coefficient (Rousseeuw and Croux 1993)

S[#] M estimate of scale, where #
specifies the desired breakdown point; default is S50

Skewness

skewness classic skewness measure (Fisher coefficient)

SK[#] Hinkley (1975) skewness measure, where #
specifies the desired percentage; default is SK25, which is
equal to the Yule and Kendall (1968) skewness measure

MC medcouple (Brys et al. 2004)

Kurtosis

kurtosis classic kurtosis measure

QW[#] quantile tail weight measure, where #
specifies the desired percentage; default is QW25

LQW[#] left quantile tail weight measure, where #
specifies the desired percentage; default is LQW25

RQW[#] right quantile tail weight measure, where #
specifies the desired percentage; default is RQW25

LMC left medcouple tail weight measure (Brys et al. 2006)

RMC right medcouple tail weight measure (Brys et al. 2006)

over(varname) reports results for each subpopulation defined by the
values of varname.

total causes additional overall results across all subpopulations to
be reported. total is only allowed if over() is specified.

swap affects the layout of the results. Depending on
specified options, robstat groups results into several
"equations". Specify swap in such a case
if you want to flip equations and coefficients.

SE/SVY

vce(vcetype) determines how standard errors and confidence intervals
are computed. vcetype may be:

analytic
cluster clustvar
bootstrap [, bootstrap_options]
jackknife [, jackknife_options]

The default is vce(analytic), using approximate formulas for variance
estimation (based on influence functions) assuming independent data. For
clustered data, specify vce(cluster clustvar), where
clustvar is the variable identifying the clusters. For bootstrap and
jackknife estimation, see help vce_option. Variance estimation
is not supported if iweights or fweights are specified.

cluster(clustvar) is a synonym for vce(cluster clustvar).

svy[(subpop)] causes the survey design to be taken
into account for variance estimation. The data need to be set up for survey
estimation; see help svyset. Specify subpop to restrict survey
estimation to a subpopulation, where subpop is

[varname] [if]

The subpopulation is defined by observations for which varname!=0 and
for which the if condition is met. See help svy and
[SVY] subpopulation estimation for more information on subpopulation
estimation.

The svy option of robstat only works if the variance
estimation method is set to Taylor linearization by svyset (the
default). For other variance estimation methods you can use the usual svy
prefix command. For example, you could type svy brr: robstat ... to
use BRR variance estimation. robstat does not allow the svy
prefix for Taylor linearization due to technical reasons. This is why the
svy option is provided.

nose suppresses the computation of standard errors and confidence
intervals. The nose option may be useful to speed-up computations with
prefix commands that use replication techniques for variance estimation,
such as, e.g., svy jackknife. Options vce(bootstrap) and
vce(jackknife) imply nose.

generate[(prefix)] stores the values of the
influence functions used for the computation of standard errors and
confidence intervals. One influence function variable is stored for each
statistic per outcome variable in each over-group. The variable names
are prefixed by prefix, where the default prefix is "_IF_".
generate() has no effect if nose, vce(bootstrap),
or vce(jackknife) is specified.

replace allows overwriting existing variables. This is only relevant
if generate() has been specified.

Normality tests

jbtest[(tests)] computes generalized Jarque-Bera tests
for normality as suggested by Brys et al. (2008). The statistics()
option (see above) is not allowed if jbtest is specified. tests
is a space-separated list of the following tests.

Test Synonym

JB jbera classic Jarque-Bera skewness and kurtosis test

MOORS moors robust skewness and tail-weight test based on SK25 and QW25

MC-LR mclr robust skewness and tail-weight test based on MC, LMC and RMC

MC-L mcl robust skewness and left tail-weight test based on MC and LMC

MC-R mcr robust skewness and right tail-weight kurtosis test based on MC and RMC

MC mc robust skewness test based on MC

LR lr robust tail-weight test based on LMC and RMC

LMC lmc robust left tail-weight test based on LMC

RMC rmc robust right tail-weight test based on RMC

Specifying option jbtest without argument is equivalent to
jbtest(jbera moors mclr). Furthermore, jbtest(all) reports all
available tests.

wald specifies that the normality tests are to be based on the
estimated variance-covariance matrix of the involved skewness and kurtosis
or tail-weight parameters. The default is to base the tests on the
theoretical variance for normally distributed data. Specifying the
svy option, a vcetype other than analytic, or weights
other than fweights implies wald. wald is not allowed
with fweights.

Reporting

level(#) specifies the confidence level, as a percentage, for
confidence intervals. The default is level(95) or as set by
set level.

cilog causes log-transformed confidence intervals to be used for scale
statistics. This ensures that the confidence intervals do not include
zero. Log-transformed confidence intervals are computed as

exp(ln(S) +/- z * SE/S)

where S is estimated the scale statistic, z is the critical value for the given
confidence level, and SE is the standard error of S.

noheader suppresses the output header; only the coefficient table is
displayed.

notable suppresses the coefficient table.

display_options are standard reporting options such as cformat(),
pformat(), sformat(), or coeflegend. See
[R] estimation options.

Technical options

tolerance(#) specifies the tolerance for the M estimates. The default
is tolerance(1e-10).

iterate(#) specifies the maximum number of iterations for the M
estimates. If convergence is not reached within iterate() iterations,
the algorithm stops and returns error. The default is iterate(16000)
or as set by set maxiter.

kernel(kernel) specifies the kernel function for density estimation
(computation of standard errors involves density estimation for some of
the statistics). The default is kernel(epan2). See help
mm_density() for available kernels.

bw(type) specified the type of automatic bandwidth selector for
density estimation. The default is bw(dpi). See help
mm_density() for available bandwidth selectors.

adaptive(#) specifies the number of repetitions for adaptive
kernel density estimation. The default is adaptive(2). Specify
adaptive(0) for non-adaptive kernel density estimation.

n(#) specifies the size of the approximation grid for density
estimation. The default is n(512).

Examples

. sysuse auto
. robstat price, statistics(mean median alpha5 alpha25 HL Huber)
. robstat price, jbtest

Stored results

robstat stores the following in e():

Scalars

e(N) number of observations

e(N_over) number of subpopulations

e(N_clust) number of clusters

e(k_eq) number of equations in e(b)

e(N_stats) number of statistics

e(N_vars) number of variables

e(df_r) sample degrees of freedom

e(rank) rank of e(V)

e(level) confidence level for CIs

Macros

e(cmd) robstat

e(cmdline) command as typed

e(title) title in estimation output

e(depvar) variable names

e(statistics) requested statistics

e(over) name of over() variable

e(over_namelist) values from over() variable

e(over_labels) labels from over() variable

e(total) total or empty

e(wtype) weight type

e(wexp) weight expression

e(clustvar) name of cluster variable

e(vce) vcetype specified in vce()

e(vcetype) title used to label Std. Err.

e(title) title in estimation output

e(jbtitle) title in normality test output

e(jbtype) chi2 or F or empty

e(jbwald) wald or empty

e(properties) b V or b

Matrices

e(b) estimates

e(V) variance-covariance matrix of estimates

e(aux) tuning constants of M estimators

e(class) class of statistic (1 location, 2 scale, 3 skewness, 4 kurtosis)

e(_N) numbers of observations in subpopulations

e(jbtest) normality test results (if requested)

Functions

e(sample) marks estimation sample

If the svy option is specified, various additional results as described
in help svy are stored in e().

Methods and Formulas

Point estimates for mean, alpha, median, sd, IQR,
MAD, skewness, SK, kurtosis, QW, LQW,
and RQW are computed using summarize and
_pctile.

Point estimates for Huber, biweight, and S are computed by
the iterative re-weighted least square procedure (IRWLS).

Point estimates for HL, Qn, MC, LMC, and RMC
are computed using variants of the fast algorithm proposed by
Johnson and Mizoguchi (1978) (also see Croux and Rousseeuw 1992,
Brys et al. 2004).

The normality tests requested by the jbtest option are defined and
computed as suggested by Brys et al. (2008). In case of nonstandard VCE or
if the wald option is specify, Wald tests based on the
estimated variance-covariance matrix are performed using the test
command.

Approximate standard errors and confidence intervals are computed using an
influence-function approach. For each statistic a variable
containing the values of the influence function evaluated at the values of
the outcome variable is computed, while imputing the unknown quantities of the influence
function by their empirical counterparts. For some of the influence
functions density estimation is required, which is performed using the
binned approximation estimator implemented in mm_density(). The sampling
variance of the statistics is then estimated applying the mean command
to the variables containing the influence-function values.

For more information on methods and formulas see Jann, Verardi and
Vermandele (forthcoming).

References

Brys, G., M. Hubert, A. Struyf (2004). A Robust Measure of Skewness.
Journal of Computational and Graphical Statistics 13(4): 996-1017.

Brys, G., M. Hubert, A. Struyf (2006). Robust measures of tail weight.
Computational Statistics & Data Analysis 50: 733-759.

Brys, G., M. Hubert, A. Struyf (2008). Goodness-of-fit tests based on a
robust measure of skewness. Computational Statistics 23: 429-442.

Croux, C., P. J. Rousseeuw (1992). Time-efficient algorithms
for two highly robust estimators of scale. P. 411-428 in: Y. Dodge and J.
Whittaker (eds.). Computational Statistics. Heidelberg: Physica-Verlag.

Jann, B., V. Verardi, C. Vermandele (forthcoming). Applied Robust Regression
in Stata. College Station, Texas: The Stata Press.

Johnson, D. B., T. Mizoguchi (1978). Selecting the Kth element
in X + Y and X_1 + X_2 + ... + X_m. SIAM
Journal on Scientific Computing 7(2): 147–153.

Hinkley, D. V. (1975). On power transformations to symmetry. Biometrika
62(1): 101-111.

Hodges, Jr., J. L., E. L. Lehmann (1963). Estimates of location based on
rank tests. Annals of Mathematical Statistics 34(2): 598-611.

Rousseeuw, P. J., C. Croux (1993). Alternatives to the Median
Absolute Deviation. Journal of the American Statistical Association
88(424): 1273-1283.

Yule, G. U., M. G. Kendall (1968). An Introduction to the Theory of Statistics.
14th ed. London: Griffin.

Authors

Ben Jann (University of Bern),
Vincenzo Verardi (University of Namur and Universite libre de Bruxelles),
Catherine Vermandele (Universite libre de Bruxelles)

Support: ben.jann@soz.unibe.ch

Thanks for citing this software as follows:

Jann, B., V. Verardi, C. Vermandele (2018). robstat: Stata module to estimate
robust univariate statistics. Available from
http://ideas.repec.org/c/boc/bocode/s458524.html.

Also see

Online: help for
summarize,
mean,
tabstat,
centile,
ci,
pctile

From the SSC Archive:
robreg