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   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to skip logit when there is no variation in the dependentvariable
Date   Mon, 19 Mar 2007 11:47:16 +0100

Thomas de Hoop wrote:

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 believe that you became a victim to the dangerous "missing is large"
trap: missing values are very large numbers, and the expression
droughtcount3>0 is evaluated to true if droughtcount3 is missing.
Solution:

   logit drought`i' ... if droughtcount`i'>0 & droughtcount`i'<. 

Read more in
   help missing

Hope this helps,
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index