Stata 15 help for _rmcollright


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


_rmcollright varblocklist [if] [in] [weight] [, noconstant collinear]

where varblocklist is a list of one or more varblocks, 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).

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


_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.


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.


_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.


. 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 varblocks 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)

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index