__Title__

**[P] _rmcollright** -- Remove collinear variables from the right

__Syntax__

**_rmcollright** *varblocklist* [*if*] [*in*] [*weight*] [**,** __nocons__**tant** __coll__**inear**]

where *varblocklist* is a list of one or more *varblock*s, and a *varblock* is
either *varname* or **(***varlist***)** (a *varlist* in parentheses indicates that this
list of variables is to be considered as a group).

**fweight**s, **aweight**s, **iweight**s, and **pweight**s are allowed; see weight.

__Description__

**_rmcollright** returns in **r(varblocklist)** the groups of variables from
*varblocklist* that form a noncollinear set. **_rmcollright** drops the
right-most among collinear variables. Thus the order of the variables in
*varblocklist* determines which variable is dropped in a set of collinear
variables.

If any variables are collinear, in addition to each not being included in
**r(varblocklist)**, a message is displayed for each:

note: ______ dropped due to collinearity.

__Options__

**noconstant** specifies that, in looking for collinearity, an intercept
should not be included. That is, a variable that contains the same
nonzero value in every observation should not be considered
collinear.

**collinear** specifies that collinear variables remain in the varlist.

__Remarks__

**_rmcollright** is typically used in estimation commands.

A code fragment for the caller of **_rmcollright** might read as

*...*
**syntax varlist [fweight iweight]** *...* **[, noCONStant** *...* **]**
**marksample touse**

**if "`weight'" != "" {**
**tempvar w**
**quietly gen double `w' = `exp' if `touse'**
**local wgt [`weight'=`w']**
**}**
**else local wgt** */* is nothing */*

**tokenize `varlist'**
**local depvar `1'**
**mac shift**
**_rmcollright `*' `wgt' if `touse', `constant'**
**local xvars `r(varlist)'**
*...*

In this code fragment, **`varlist'** contains one dependent variable and zero
or more independent variables. The dependent variable is split off and
stored in the local macro **depvar**. Then the remaining variables are
passed through **_rmcollright**, and the resulting noncollinear set stored in
the local macro **xvars**.

__Examples__

**. sysuse auto**
**. gen mpg2 = mpg**
**. gen tt = turn + trunk**
**. _rmcollright (mpg turn tt trunk) displ (gear mpg2 head)**
**. return list**

__Stored results__

**_rmcollright** stores the following in **r()**:

Scalars:
**r(k)** number of *varblock*s in **r(varblocklist)**

Macros:
**r(varlist)** list of remaining variables
**r(dropped)** list of dropped variables
**r(varblocklist)** *varblocklist* of remaining variables
**r(block#)** *#*th block of **r(varblocklist)**