Statalist The Stata Listserver


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

Re: st: How to skip logit when there is no variation in the dependentvariable


From   Thomas de Hoop <[email protected]>
To   [email protected]
Subject   Re: st: How to skip logit when there is no variation in the dependentvariable
Date   Mon, 19 Mar 2007 11:27:18 +0100

Thomas de Hoop wrote:
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);
I add some more information that might be useful. Country 3 is a country where the situation never occurred.

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