Statalist The Stata Listserver


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

st: RE: How to skip logit when there is no variation in the dependent variable


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to skip logit when there is no variation in the dependent variable
Date   Mon, 19 Mar 2007 11:33:24 +0100

if pseudo Stata code (assuming that drought`i' is missing for other countries than country `i'):

forval i=1/214 {
    count if drought`i'==0
    if r(N) > 0 logit drought`i' variable1 variable 2 etc. 
}

Hope this helps,
Maarten

-----------------------------------------
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/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Thomas de Hoop
Sent: maandag 19 maart 2007 11:11
To: [email protected]
Subject: st: How to skip logit when there is no variation in the dependent variable

Dear Statalist users,

I have created dummy variables for 214 countries. For each of these
countries I want to estimate several logit models to estimate chances of
certain situations to occur,  and create chance variables from the
prediction of these models. I estimate these chances using data from the
past. I have data of these situation For this I created loops with the
foreach and forvalue commands from stata. The problem is that in some
countries a certain situation never occurred. For these situations there
are only 0 value observations. Of course logistic regression is not
possible in these kind of situations. For this reason I would like to
skip these equations in the loop.
For this reason I counted the number of times a situation did occur in
the past and created a variable.

I tried to skip the equation as follows:

forval i=1/214 {
logit drought`i' variable1 variable 2 etc. if  droughtcount`i'>0
}

i= the country number
variable1 variable2 etc are the explanatory variables.

drought`i'=the situation in a certain country
droughtcount`i'=the number of times a situation did occur in the past.

For country 3 this results in the following error:
no observations
r(2000);

How can I prevent this error?

Best regards,

Thomas de Hoop





*
*   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/

*
*   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