Announcement

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

  • r(2000) no observations when running xtreg

    I have an unbalanced panel dataset. When I do the following regression, Stata produces output without any error:

    Code:
     xtreg rgdpgrowth sxp sxp2 extdebtGDP i.year, fe vce(robust)
    
    Fixed-effects (within) regression               Number of obs      =       315
    Group variable: country                         Number of groups   =        65
    
    R-sq:  within  = 0.1066                         Obs per group: min =         3
           between = 0.1082                                        avg =       4.8
           overall = 0.1036                                        max =         5
    
                                                    F(7,64)            =      5.88
    corr(u_i, Xb)  = 0.0506                         Prob > F           =    0.0000
    
                                   (Std. Err. adjusted for 65 clusters in country)
    ------------------------------------------------------------------------------
                 |               Robust
      rgdpgrowth |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sxp |   -.043291    .097015    -0.45   0.657    -.2371007    .1505187
            sxp2 |   .0285514   .1760005     0.16   0.872      -.32305    .3801529
      extdebtGDP |  -.0000597   .0000177    -3.38   0.001     -.000095   -.0000245
                 |
            year |
           1980  |  -.0117597   .0054863    -2.14   0.036    -.0227198   -.0007996
           1985  |  -.0206939   .0057291    -3.61   0.001    -.0321392   -.0092487
           1990  |  -.0123391    .005445    -2.27   0.027    -.0232167   -.0014615
           1995  |    -.01004   .0051349    -1.96   0.055    -.0202981    .0002182
                 |
           _cons |   .0297318    .010096     2.94   0.004     .0095628    .0499008
    -------------+----------------------------------------------------------------
         sigma_u |   .0212606
         sigma_e |  .02712922
             rho |  .38047986   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    But when I include a lagged version of extdebtGDP, Stata shows the following error:

    Code:
      xtreg rgdpgrowth sxp sxp2 extdebtGDP L.extdebtGDP i.year, fe vce(robust)
    no observations
    r(2000);
    In a previous related post, I saw Dr. Nick Cox mentioning that string variables/missing observations may cause this error.


    Code:
     count if !missing( rgdpgrowth, sxp, sxp2, extdebtGDP)
      315
    
    . count if !missing( rgdpgrowth, sxp, sxp2, extdebtGDP, L.extdebtGDP)
        0
    
    xtdes
    
     country:  1, 2, ..., 104                                    n =         65
        year:  1975, 1980, ..., 1995                             T =          5
               Delta(year) = 1 unit
               Span(year)  = 21 periods
               (country*year uniquely identifies each observation)
    
    Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                             3       4       5         5         5       5       5
    
         Freq.  Percent    Cum. |  Pattern*
     ---------------------------+----------
           60     92.31   92.31 |  11111
            3      4.62   96.92 |  ..111
            2      3.08  100.00 |  .1111
     ---------------------------+----------
           65    100.00         |  XXXXX
     --------------------------------------
     *Each column represents 5 periods.
    Any help will be highly appreciated. Thanks.
    Last edited by Taz Raihan; 09 May 2018, 00:37.

  • #2
    xtset would not have worked at all with a string identifier. xtset did work, but you forgot to specify delta(5) to indicate 5 year spacing.

    Comment


    • #3
      Amazing! Can't thank you enough!

      Comment


      • #4
        Taz:
        as a sidelight (and despite that squared exp does not seem to play any role in your regression model), relying on -fvvarlist- notation for creating catagorical variables and interactions, is still then best approach (see also the relationships between -fvvralist-, -margins- and -marginsplot-).
        Hence, your second code could have been written as:
        Code:
         xtreg rgdpgrowth c.sxp##c.sxp extdebtGDP L.extdebtGDP i.year, fe vce(robust)
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Carlo Lazzaro thank you for chiming in. I deliberately did not use c.sxp##c.sxp since I was using outreg2 to output my results in tex format with variable names replaced by their labels. If I had used c.sxp##c. sxp, then I would have to manually change the labels of squared sxp in each of the tex files that were being generated. But is my method going to affect the results in a significant way?

          Again, thanks for your advice.

          Comment


          • #6
            Taz:
            Admittedly, I did not notice that you mentioned -outreg2- in your previous post.
            No, your results will be the same; set aside the post-estimation issues (see -margins-and -marginsplot-), the only difference is that plugging in a squared term by hand makes Stata think that the linear and the squared term refer to two different predictors, whereas it obviously not the case.
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              Carlo Lazzaro thank you for enlightening. Learning new stuff every moment.

              Comment


              • #8
                Hello everybody,

                I am new to stata and up till now previous posts helped me to where I am now, thanks for that to all.
                I have ran a rangestat regression to get the coefficient for a four factor model regression, I think I succeeded in this. For this I used the following regression

                rangestat (reg) ER ERM SMB HML WML , interval(Date . -1)

                The problem however is that when I want to use the coefficient in another regression: xtreg, this returns the error message: r2000 no observations.
                This regression I mentioned does not have string variables, but does have missing values so I think the panel data is unbalanced.

                For the first one mentioned below there is a table that is produced, but with a zero as the coefficient in the results, for the second one not even a table can be produced mentioning the error r2000.

                xtreg b_consNet Ratingnr i.Date
                outreg2 using 1.1A1.doc, replace ctitle (1) tstat addtext (Firm FE, YES, Time FE, YES)

                xtreg b_consNet SRI EstimatedFundLevelNetFlow Averagetimereturn Tenurelongest Age Turnover NETER Holdings Stdev Load dummy90 SIZE_ln i.Date
                outreg2 using 1.2A.doc, replace ctitle (1) tstat addtext (Firm FE, YES, Time FE, YES)

                I really do not know where I go wrong. Do you guys have any tips or pointers that can lead me in the right direction?

                Thanks in advance,
                Jur

                Comment


                • #9
                  Hi, I am trying to run a panel data regression and I am facing the issue of "no observations" error. My dependent variable is continuous that is an acquisition deal level variable. SDCDealNo uniquely identifies each deal. Independent variable is binary that is a country level variable. Both are not string. I checked for missing values.

                  Code:
                  count if !missing (ownership p_shift)
                  missing not found
                  r(111);
                  Code:
                  xtreg ownership l.p_shift
                  no observations
                  r(2000);
                  This is how I set my panel data.
                  Code:
                  xtset SDCDealNo year
                         panel variable:  SDCDealNo (unbalanced)
                          time variable:  year, 1995 to 2020
                                  delta:  1 unit
                  Code:
                  xtdes
                  
                  SDCDealNo:  1.669e+08, 1.800e+08, ..., 4.067e+09            n =      46309
                      year:  1995, 1996, ..., 2020                             T =         26
                             Delta(year) = 1 unit
                             Span(year)  = 26 periods
                             (SDCDealNo1*year uniquely identifies each observation)
                  
                  Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                                           1       1       1         1         1       1       1
                  
                       Freq.  Percent    Cum. |  Pattern
                   ---------------------------+----------------------------
                       2313      4.99    4.99 |  ...1......................
                       2300      4.97    9.96 |  .....1....................
                       2109      4.55   14.52 |  ............1.............
                       2086      4.50   19.02 |  ........................1.
                       2085      4.50   23.52 |  ....1.....................
                       2082      4.50   28.02 |  .......................1..
                       2071      4.47   32.49 |  .........................1
                       1990      4.30   36.79 |  ....................1.....
                       1984      4.28   41.07 |  ......................1...
                      27289     58.93  100.00 | (other patterns)
                   ---------------------------+----------------------------
                      46309    100.00         |  XXXXXXXXXXXXXXXXXXXXXXXXXX
                  Any help much appreciated!
                  Last edited by Sowmya Kannan; 14 Mar 2024, 00:44.

                  Comment


                  • #10
                    Sowmya:
                    you're probably experiencing something like:
                    Code:
                    use "C:\Program Files\Stata18\ado\base\a\auto.dta"
                    (1978 automobile data)
                    
                    . g id=_n
                    
                    . g time=1
                    
                    . tsset id time
                    
                    Panel variable: id (strongly balanced)
                     Time variable: time, 1 to 1
                             Delta: 1 unit
                    
                    . regress price l.mpg
                    no observations
                    r(2000);
                    
                    .
                    Kind regards,
                    Carlo
                    (StataNow 18.5)

                    Comment


                    • #11
                      To run a panel regression you would need some units with observations in multiple years. It appears that you have only one observation for each SDCDealno.

                      Comment

                      Working...
                      X