Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • No observations error "r2000"

    Hello, I searched on various forums regarding the "no observations r2000 error" but can't seem to solve my problem. I have a case-control study survey dataset. When I run a logistic regression model, I get the error.

    The variables I use with no missing values and they're numeric. I've checked by "describe and summarize".
    Any help would be greatly appreciated.

    Thank you

  • #2
    Welcome to Statalist.

    The best suggestion I can offer at this point is to take a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Section 12.1 is particularly pertinent

    12.1 What to say about your commands and your problem

    Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
    You should show us the describe and summarize commands and their output, and the logistic regression command you ran and it's output. To to this, please copy them from Stata's Results window into a code block in the Forum editor using code delimiters [CODE] and [/CODE], as explained in section 12 of the Statalist FAQ linked to at the top of the page. For example, the following:

    [CODE]
    . sysuse auto, clear
    (1978 Automobile Data)

    . describe make price

    storage display value
    variable name type format label variable label
    -----------------------------------------------------------------
    make str18 %-18s Make and Model
    price int %8.0gc Price
    [/CODE]

    will be presented in the post as the following:
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . describe make price
    
                  storage   display    value
    variable name   type    format     label      variable label
    -----------------------------------------------------------------
    make            str18   %-18s                 Make and Model
    price           int     %8.0gc                Price

    Comment


    • #3
      Isthiaq:
      as an aside to William's excellent advice, did you impose any -if- clause in your code, as in the following toy-example?
      Code:
      use "C:\Program Files\Stata16\ado\base\a\auto.dta"
      
      . logit foreign mpg if rep78==98
      no observations
      r(2000);
      
      .
      Last edited by Carlo Lazzaro; 05 Oct 2020, 07:53. Reason: Example added.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        One possibility is that the response variable is coded with something other than 0/1, say 1/2. However, without the proper information, per William Lisowski's suggestions, that diagnosis is simply a guess.

        Comment


        • #5
          On #4 you can get r(2000) even when you (think you) have data that suits. Here is an illustration:


          Code:
          . sysuse auto, clear
          (1978 Automobile Data)
          
          . logit rep78 mpg
          
          outcome does not vary; remember:
                                            0 = negative outcome,
                  all other nonmissing values = positive outcome
          r(2000);
          Another less obvious reason is that you referred to lagged predictors but gaps mean that there are no observations to work with.

          Comment

          Working...
          X