**[R] rreg** -- Robust regression

__Syntax__

**rreg** *depvar* [*indepvars*] [*if*] [*in*] [**,** *options*]

*options* Description
-------------------------------------------------------------------------
Model
__tu__**ne(***#***)** use *#* as the biweight tuning constant; default is
**tune(7)**

Reporting
__l__**evel(***#***)** set confidence level; default is **level(95)**
__g__**enwt(***newvar***)** create *newvar* containing the weights assigned to
each observation
*display_options* control columns and column formats, row spacing,
line width, display of omitted variables and
base and empty cells, and factor-variable
labeling

Optimization
*optimization_options* control the optimization process; seldom used
__g__**raph** graph weights during convergence

__coefl__**egend** display legend instead of statistics
-------------------------------------------------------------------------
*indepvars* may contain factor variables; see fvvarlist.
*depvar* and *indepvars* may contain time-series operators; see tsvarlist.
**by**, **mfp**, **mi estimate**, **rolling**, and **statsby** are allowed; see prefix.
**coeflegend** does not appear in the dialog box.
See **[R] rreg postestimation** for features available after estimation.

__Menu__

**Statistics > Linear models and related > Other > Robust regression**

__Description__

**rreg** performs one version of robust regression of *depvar* on *indepvars*.

Also see *Robust standard errors* in **[R] regress** for standard regression
with robust variance estimates and **[R] qreg** for quantile (including
median or least-absolute-residual) regression.

__Options__

+-------+
----+ Model +------------------------------------------------------------

**tune(***#***)** is the biweight tuning constant. The default is 7, meaning seven
times the median absolute deviation from the median residual; see
*Methods and formulas* in **[R] rreg**. Lower tuning constants downweight
outliers rapidly but may lead to unstable estimates (less than 6 is
not recommended). Higher tuning constants produce milder
downweighting.

+-----------+
----+ Reporting +--------------------------------------------------------

**level(***#***)**; see **[R] estimation options**.

**genwt(***newvar***)** creates the new variable *newvar* containing the weights
assigned to each observation.

*display_options*: **noci**, __nopv__**alues**, __noomit__**ted**, **vsquish**, __noempty__**cells**,
__base__**levels**, __allbase__**levels**, __nofvlab__**el**, **fvwrap(***#***)**, **fvwrapon(***style***)**,
**cformat(***%fmt***)**, **pformat(%***fmt***)**, **sformat(%***fmt***)**, and **nolstretch**; see **[R]**
**estimation options**.

+--------------+
----+ Optimization +-----------------------------------------------------

*optimization_options*: __iter__**ate(***#***)**, __tol__**erance(***#***)**, [__no__]__lo__**g**. **iterate()**
specifies the maximum number of iterations; iterations stop when the
maximum change in weights drops below **tolerance()**; and **log**/**nolog**
specifies whether to show the iteration log. These options are
seldom used.

**graph** allows you to graphically watch the convergence of the iterative
technique. The weights obtained from the most recent round of
estimation are graphed against the weights obtained from the previous
round.

The following option is available with **rreg** but is not shown in the
dialog box:

**coeflegend**; see **[R] estimation options**.

__Examples__

Setup
**. sysuse auto**

Robust regression
**. rreg mpg foreign#c.weight foreign**

Same as above, but save estimated weights in **genwt(w)**
**. rreg mpg foreign#c.weight foreign, genwt(w)**

__Stored results__

**rreg** stores the following in **e()**:

Scalars
**e(N)** number of observations
**e(mss)** model sum of squares
**e(df_m)** model degrees of freedom
**e(rss)** residual sum of squares
**e(df_r)** residual degrees of freedom
**e(r2)** R-squared
**e(r2_a)** adjusted R-squared
**e(F)** F statistic
**e(rmse)** root mean squared error
**e(rank)** rank of **e(V)**

Macros
**e(cmd)** **rreg**
**e(cmdline)** command as typed
**e(depvar)** name of dependent variable
**e(genwt)** variable containing the weights
**e(title)** title in estimation output
**e(model)** **ols**
**e(properties)** **b V**
**e(predict)** program used to implement **predict**
**e(marginsok)** predictions allowed by **margins**
**e(asbalanced)** factor variables **fvset** as **asbalanced**
**e(asobserved)** factor variables **fvset** as **asobserved**

Matrices
**e(b)** coefficient vector
**e(V)** variance-covariance matrix of the estimators

Functions
**e(sample)** marks estimation sample