Jeph:
I'm not aware of anything built into -regress- that does what you
describe, but you could use - _rmcoll- to identify (and -macro
lists- commands to remove) the collinear variables.
E.g., let's say that I *always* want to retain rep78 & price when
they are collinear:
**************
clear
cap est clear
webuse auto
//generate some collin vars
g collin1 = rep78*2
g collin2 = price*2
local all rep78 price collin1 collin2 turn foreign
regress mpg `all'
est store ALL
//identify collin vars & remove
_rmcoll `all'
di "`r(varlist)'"
local collinear `r(varlist)'
di "`collinear'"
local new_all: list all & collinear
// will keep the intersection of two lists //
/*
or, to keep collin1 and collin2:
local new_all: list all - collinear
*/
di "`new_all'"
/*
now the collinear vars are gone & you keep rep78 & price
*/
regress mpg `new_all'
est store NOCOLLIN
/*
combinations of variables in varlist 'new_all' without the collinear
vars (collin1 collin2)
*/
tokenize `new_all'
while "`1'" !="" {
qui regress mpg `1' `2' `3'
est store `1'`2'`3'
macro shift
}
est table *, b(%5.3f) se(%5.3f) stats(N r2_a)
**************
Note that the order of the variables in the local macro that you use
in -_rmcoll- makes a difference for which one it assigns the "o."
prefix & therefore the first of the collinear variables in the list
remains in the model ((that is, if the -local- `all' read:
local all collin1 collin2 rep78 price turn foreign
instead of:
local all rep78 price collin1 collin2 turn foreign
then collin1 and collin2 would be retained & rep78 and price discarded.
~Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On Sep 11, 2009, at 10:58 AM, Jeph Herrin wrote:
This must be doable - I am running a large
number of models using -regress-, often with
a large number of independent variables. There
is one variable I would like to always be retained;
however, -regress- is omitting it in some cases
for collinearity. It seems there should be a
way to force regress to lock in a certain term,
and omit something else?
Jeph
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/