Announcement

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

  • Error code 2000 when running xtunitroot

    Question has been cross-posted here:

    I have an excel file that I opened in stata and set into panel data:

    Code:
    xtset panelid date
    Code:
    summarize
        
            Variable |       Obs        Mean    Std. Dev.       Min        Max
        -------------+--------------------------------------------------------
                date |      2418    2010.049    2.816131       2005       2014
           years_exp |      2418    10.96526    9.529847          0         60
        leg_totalb~s |      2418    6.753102    7.878725          1        156
             billsum |      2418    .4028122    .9150199          0         12
              amtsum |      2418    568.0935    2034.004          0   93395.88
        -------------+--------------------------------------------------------
            panel_id |      2418    384.1638    215.0956          1        816
           xtunitroot fisher leg_totalbills, dfuller trend demean lags(1)
    I run the xtunitroot with the following code:

    Code:
    xtunitroot fisher leg_totalbills, dfuller trend demean lags(1)
    and I get the following error:

    Code:
     . xtunitroot fisher leg_totalbills, dfuller trend demean lags(1)
        performing unit-root test on first panel using the syntax
        dfuller leg_totalbills, trend  lags(1)
        returned error code 2000
        r(2000);
    I read that this could be due to missing values so I ran a count missing command:

    Code:
      count if missing(date, years_exp, amtsum, billsum, leg_totalbills)
         0
    Last edited by John Michael Perdue; 03 Jun 2016, 11:39.

  • #2
    The problem is gaps in your data, which your xtset will have told you about.

    You do have missing values -- but they are omitted from the data.

    I don't know nearly enough about these tests to advise you what to do next.

    By the way, spreadsheets are recommended against here (FAQ Advice #12).
    Last edited by Nick Cox; 03 Jun 2016, 11:51.

    Comment


    • #3
      Cross-posted at http://stackoverflow.com/questions/3...ing-xtunitroot

      FAQ Advice, which you are reminded to read before posting, includes a statement at http://www.statalist.org/forums/help#crossposting

      8. May I cross-post to other forums?

      People posting on Statalist may also post the same question on other listservers or in web forums. There is absolutely no rule against doing that.
      But if you do post elsewhere, we ask that you provide cross-references in URL form to searchable archives. That way, people interested in your question can quickly check what has been said elsewhere and avoid posting similar comments. Being open about cross-posting saves everyone time.
      If your question was answered well elsewhere, please post a cross-reference to that answer on Statalist.

      Comment


      • #4
        Thanks for the suggestions Nick! I'm going to see what I can find out about removing the gaps.

        Comment


        • #5
          You have insufficient observations for the Dickey-Fuller test. I suspect you have the 3 or fewer observations in the first panel. When the Dickey-Fuller test regresses the differenced leg_totalbills on the lagged and differenced lagged variable you will only have 1 observation to estimated 3 coefficients. Try dropping the first group.

          Note to Stata: There is an inconsistency in how xtunitroot fisher handles groups with insufficient observations. If the first group is insufficient the test reports error code 2001 and stops. If the insufficient group in not the first, then the test proceeds and reports "could not compute test for panel #"; however, the number of panels reported is incorrect - it reports the total number of panels even those that did not contribute to the test.

          Code:
          . webuse grunfeld,clear
          
          . drop in 1/17
          (17 observations deleted)
          
          . xtunitroot fisher invest, dfuller lags(1)
          performing unit-root test on first panel using the syntax
          dfuller invest, lags(1) 
          returned error code 2001
          r(2001);
          
          . webuse grunfeld,clear
          
          . drop in 184/200
          (17 observations deleted)
          
          . xtunitroot fisher invest, dfuller lags(1)
          could not compute test for panel 10
          
          Fisher-type unit-root test for invest
          Based on augmented Dickey-Fuller tests
          --------------------------------------
          Ho: All panels contain unit roots           Number of panels       =     10
          Ha: At least one panel is stationary        Avg. number of periods =  18.30
          
          AR parameter: Panel-specific                Asymptotics: T -> Infinity
          Panel means:  Included
          Time trend:   Not included
          Drift term:   Not included                  ADF regressions: 1 lag
          ------------------------------------------------------------------------------
                                            Statistic      p-value
          ------------------------------------------------------------------------------
           Inverse chi-squared(18)   P        12.5420       0.8180
           Inverse normal            Z         2.4107       0.9920
           Inverse logit t(49)       L*        2.8914       0.9971
           Modified inv. chi-squared Pm       -0.9097       0.8185
          ------------------------------------------------------------------------------
           P statistic requires number of panels to be finite.
           Other statistics are suitable for finite or infinite number of panels.
          ------------------------------------------------------------------------------

          Comment


          • #6
            Thank you for your suggestion Scott! I have tried to 'clean' up my data by deleting all but three columns as well as observations from 2005: data, panel_id, leg_totalyears. I have not uploaded my data here because of the recommendation in FAQs; but, it is available here. After I put the data into panel it is still coming up with gaps. I was not sure what you meant by dropping the first group; I ended up dropping panels with fewer than 3 observations in years_exp but still had gaps when I sent the data into panel with xtset. Do you have any suggestions for this?
            Is there any information I can provide that will make my situation easier to understand?
            Last edited by John Michael Perdue; 04 Jun 2016, 02:22.

            Comment


            • #7
              You are asking questions of the data that it cannot answer. No amount of torture will make it confess.

              Take a look at missing patterns in the data:

              Code:
              . import excel "C:\Users\Scott\Desktop\unit_root_panel2.xlsx", sheet("Tabelle1") firstrow clear
              
              . encode panel_id, gen(cid)
              
              . drop panel_id
              
              . xtset cid date
                     panel variable:  cid (unbalanced)
                      time variable:  date, 2006 to 2014, but with gaps
                              delta:  1 unit
              
              . xtdescribe, patterns(1000)
              
                   cid:  1, 2, ..., 295                                    n =        295
                  date:  2006, 2007, ..., 2014                             T =          9
                         Delta(date) = 1 unit
                         Span(date)  = 9 periods
                         (cid*date uniquely identifies each observation)
              
              Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                                       3       4       4         5         5       6       6
              
                   Freq.  Percent    Cum. |  Pattern
               ---------------------------+-----------
                    119     40.34   40.34 |  1.1.1.1.1
                     39     13.22   53.56 |  1.1.1.1..
                     27      9.15   62.71 |  ....111.1
                     18      6.10   68.81 |  ..111.1.1
                     16      5.42   74.24 |  111.1.1.1
                     12      4.07   78.31 |  ..1.1.1.1
                      9      3.05   81.36 |  ..111.1..
                      9      3.05   84.41 |  1.1.1....
                      6      2.03   86.44 |  1.1.1...1
                      5      1.69   88.14 |  ..111...1
                      5      1.69   89.83 |  1...1.1.1
                      5      1.69   91.53 |  1.1...1.1
                      4      1.36   92.88 |  ...11.1.1
                      4      1.36   94.24 |  111.1.1..
                      3      1.02   95.25 |  .11.1.1.1
                      3      1.02   96.27 |  1.1.1.111
                      3      1.02   97.29 |  111.1....
                      2      0.68   97.97 |  ..1.1.1..
                      2      0.68   98.64 |  ..11..1.1
                      2      0.68   99.32 |  111...1.1
                      1      0.34   99.66 |  ...1111.1
                      1      0.34  100.00 |  111...1..
               ---------------------------+-----------
                    295    100.00         |  XXXXXXXXX
              
              .
              With all these gaps you will not be able to run a unit root test because there will be no observations after the data have been lagged and first differenced.

              Comment


              • #8
                Scott, if I were to remove the lagged variables from the data frame (as is done here), shouldn't that make a difference?

                Comment


                • #9
                  The question is addressed to Scott, but the answer can come from anyone. You have numerous very short gappy panels. There is no surgery, trickery or other manipulation possible to escape that fact and its consequences except the hypothetical case of getting more data.

                  Comment

                  Working...
                  X