Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Variable dropped from regression: how to capture event?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Variable dropped from regression: how to capture event?
Date   Sat, 18 Nov 2006 10:46:21 +0000 (GMT)

--- Friedrich Huebler <[email protected]> wrote:
> I am running a loop of regressions that should only be completed when
> all variables are included. In case a variable is dropped I want to
> skip the rest of the loop and continue with the next regression.
> The regression still runs, but with an incomplete set of variables.
> How can I check whether a variable was dropped? 

One way to see if one or more variables are dropped is by counting the
number of rows in the e(b) matrix and compare it with the number of
variables + constant if no variable is dropped like in the example
below:

*------------- begin example -------------
/*getting and preparing data*/
sysuse auto, clear
gen rep1 = rep78 <= 2
gen rep2 = rep78 == 3
gen rep3 = rep78 == 4
gen rep4 = rep78 == 5

/*getting list of variables*/
local varlist "rep1 rep2 rep3 rep4"
local allk : word count varlist
local allk = `allk' + 1 /// add the constant

logit foreign `varlist'

/*see if a variable was dropped*/
matrix b = e(b)
local k = rowsof(b)
di `allk'-`k' /// if > 0 a variable is dropped
*------------- end example -----------------



-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

Send instant messages to your online friends http://uk.messenger.yahoo.com 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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