Announcement

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

  • Insufficient observations when running panel data

    Hello all,
    I have a question I am trying to run a linear probability model with the following command

    To do that I create a panel by
    xtreg id year
    But the error comes that I can not do so to a string variable. So I convert it with the following command
    Encode id , generate(id1)
    Now when I set the panel I get the error that “ repeated time values within the panel”
    And when I run the regression I get the error “insufficient observations”
    The ID is unqiue for each observation.
    My data on dataex command is as follows:
    input long id1 float(year mig_dummy age_cat SPEIx)
    1 1988 0 20 -.222614
    1 1989 0 20 -.272857
    1 1990 0 20 1.33297
    1 1991 0 20 .469962
    1 1992 0 20 1.3215
    1 1993 0 20 -.194207
    1 1994 0 20 1.63262
    1 1995 0 20 1.16407
    1 1996 0 20 .389528
    1 1997 0 20 1.39639
    1 1998 0 20 .910947
    1 1999 0 20 -.860725
    1 2000 0 20 -.617814
    1 2001 0 20 .0590388
    1 2002 0 20 -1.03181
    1 2003 0 20 1.3444
    1 2004 0 20 .698185
    1 2005 0 20 .816702
    1 2006 0 20 .916122
    1 2007 0 20 .859999
    1 2008 0 20 1.46291
    1 2009 0 20 -.0181454
    1 2010 1 20 .610469
    2 1990 0 20 1.33297

  • #2
    Shifa:
    1) if Stata throws out the error message “repeated time values within the panel” and you are 100% sure that repeated values are not genuine duplicates (ie, the offspring of a mistaken data entry) and you do not plan to use time-series related commands, such as lags and leads, you can -xtset- your data with the -panelid- only:
    Code:
    xtset id1
    2) it's ok that the id for the same panel does not change across years. I cannot replicate the second error message with the data excerpt you shared (and assuming the regressand is -mig_dummy-; please note that, as recommended by the FAQ, reporting what you typed and what Stata gave you back is often helpful for those interested in replying. Thanks).
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      See advice at https://www.stata.com/support/faqs/d...d-time-values/

      Here are some common reasons for that report.

      1. You don't have panel data in Stata's strong sense that (identifier, time) pairs occur at most once. Carlo Lazzaro is focusing on this case.

      2. Some data entry errors, as exemplified in the FAQ.

      3. There are repeated missing values on the identifiers or times or both. That can happen particularly with spreadsheets where people leave blank rows on purpose or by accident in a worksheet, which Stata interprets as missing values.

      Comment


      • #4
        Thank you for your response, I was able to delete the missing values through duplicate drop and the panel was made. Highly appreciate your response.

        Comment

        Working...
        X