*! version 1.1 30may2017
help screen

Title

screen -- Stata command to quickly identify possible outliers based on the
interquartile range, percentile or standard deviation.

Syntax

screen
varlist
[if] [in]
[, options]

Main
type(string) string may be iqr, per, or sd;
e.g. type(sd)

lower(numeric) lower-tail cutoff;
e.g. lower(0.1)

upper(numeric) upper-tail cutoff;
e.g. upper(3)

Options
iter(integer) screening iterations and only applicable
to type(sd); e.g. iter(2)

gen(integer) generates a varlist clone and replaces potential outliers with the
cutoff, mean, median, or missing value; e.g. gen(2)

second(varlist) screens varlist excluding observations with varlist outliers

Description

Stata command to quickly identify possible outliers based on the interquartile range,
percentile or standard deviation. For example, screen can identify Tukey’s severe outliers (more than 3 IQR away
from the nearer quartile) and mild outliers (between 1.5 and 3 IQR away from the nearer quartile),
Gaussian outliers based on the three-sigma-rule (more than 3 SD away from the mean), Chebyshev's inequality (no more than 1/k^2 of
values can be more than k standard deviations away from the mean), and percentile outliers (top and bottom sample trimming).

Options

Main

type(iqr|per|sd) indicates screening method and may only be percentile, standard deviation, or interquartile range.

lower(#)	specifies lower-tail cutoff. If lower(1) and type(per),
values below the 1st percentile are identified; if lower(3) and type(sd),
values 3 standard deviations below the mean are identified; if lower(1.5) and type(iqr),
values more than 1.5 IQR (75th percentile - 25th percentile) below the first quartile (25th percentile) are identified.

upper(#)	specifies upper-tail cutoff. If upper(1) and type(per),
values above the 99th percentile are identified; if upper(3) and type(sd),
values 3 standard deviations above the mean are identified; if upper(1.5) and type(iqr),
values more than 1.5 IQR (75th percentile - 25th percentile) above the third quartile (75th percentile) are identified.

Options

iter(#) number of screening iterations and only applicable to type(sd). If iter(2) values are screened twice.
This is useful when extreme values (possibly data collection errors)
distort the mean and standard deviation which are necessary for outlier detection in the SD method.

gen(#) generates a varlist clone and replaces potential outliers with the cutoff value if gen(1);
with the mean if gen(2) and type(per|sd); with the median if gen(2) and type(iqr);
and with missing values if gen(3).

second(varlist) screens varlist (e.g. protein, iron, and zinc intake) excluding observations
with varlist (e.g. daily meat consumption) outliers.

Example

. screen expenditure, type(sd) lower(3) upper(3) iter(2)

. screen consumption, type(per) upper(2.5) second(kcal iron protein)

. screen kcal if poor==1, type(iqr) lower(3) gen(1)

Author

Marco Santacroce, International Food Policy Research Institute, Washington DC, USA (marcosantacroce.it@gmail.com)

Citation

Santacroce, Marco (2017).
screen: STATA command to quickly identify possible outliers based on the interquartile range, percentile or standard deviation.