Announcement

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

  • xtscc error: "too many values r(134)";

    Hi,
    I am currently trying to estimate a Dynamic Panel Data Model (including a first-order lag of the dependent variable and other control variables as regressors) utilizing a panel data set. The panel data set consists of N = 30 panels and T (very) large, which varies across panels. If panel-i and panel-j denote the panels with the shortest and longest time-span, respectively, then T_i is 162 and T_j is 10433. The average T-length across panels is 2136.47.

    The panel data set is 'unbalanced', as it is composed of 'stacked' periods of observations for each panel. Within these periods, however, the panel data are balanced.
    I am estimating the Dynamic Panel Data model using fixed-effects, as it should allow me to estimate a different intercept for each of the panels. Tests are highly indicative of autocorrelated and heteroskedastic error terms.
    I obtain 'problematic' std. errors using -xtreg, vce(robust)- (all of the parameters estimates on the included regressors suddenly become statistically significant at the 0.01-percent level, as compared to conventional std. errors. According to economic theory, the included regressors should not all be significant).

    As I know that across-panels dependencies are very likely to be present in my data set, I wish to account for these dependencies using DK standard errors (-xtscc, fe- ). However, I obtain the following error: "too many values. r(134);". Does anyone know why this error arises and what I could do to circumvent this?

    Kind regards,
    Cecilie



  • #2
    I do not know, but you can help troubleshooting the error by

    Code:
    set trace on
    and seeing what is causing the error.

    Comment


    • #3
      Thank you, Joro Kolev. Your suggestion helped me find the source. According to the code, it is my "DateTime" variable (variable containing date and time in one) that 'has too many values'. I tried to exclude half of my data sat, yet I obtain the same error.

      Comment


      • #4
        I know what is the problem.

        1) On line 75 of the ado file, there is this command
        Code:
         qui tab `timevar'
        2) You have Stata IC (Am I right?)

        So the -tab- command hits into the limitations of Stata IC.

        I have Stata SE, so for me the limitation hits at larger sample size, but still it hits sooner or later.

        This is not very good code. It is not a good idea to -tab- a variable which in this setup is supposed to grow to infinity.

        Comment


        • #5
          Try the following. Open the ado file of xtscc, and comment out like I have done the following section of code between about line 73 and about 83
          Code:
          /*        
                * Check if the panel dataset's timevar is regularly spaced
                  qui tab `timevar'
                          scalar `N_Tperiods'=r(r)
                          sum `timevar', meanonly
                          scalar `N_conseqTPeriods'=r(max)-r(min)+1
                          if `N_Tperiods'<`N_conseqTPeriods' {
                              di as err "`timevar' is not regularly spaced: there are contemporaneous gap(s) across all subjects in `panelvar'"
                              exit 101
                          }
          */
          Then report back whether this has solved the problem.

          For me it seems that this solves the problem:

          Code:
          . set obs 1000000
          number of observations (_N) was 0, now 1,000,000
          
          . gen t = _n
          
          . gen x = rnormal()
          
          . gen id = 1
          
          . xtset id t
                 panel variable:  id (strongly balanced)
                  time variable:  t, 1 to 1000000
                          delta:  1 unit
          
          . xtscc x
          
          Regression with Driscoll-Kraay standard errors   Number of obs     =   1000000
          Method: Pooled OLS                               Number of groups  =         1
          Group variable (i): id                           F(  0,999999)     =         .
          maximum lag: 30                                  Prob > F          =         .
                                                           R-squared         =    0.0000
                                                           Root MSE          =    1.0001
          
          ------------------------------------------------------------------------------
                       |             Drisc/Kraay
                     x |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                 _cons |  -.0010106    .001002    -1.01   0.313    -.0029745    .0009534
          ------------------------------------------------------------------------------
          Last edited by Joro Kolev; 02 Aug 2020, 09:24.

          Comment


          • #6
            Hello Joro,

            I have encountered the same problem as Cecilie. I changed the ADO file and silenced those lines, but the same warning message arises: "too many values r(134);".

            I have hourly production data at the facility level, here is the code I am using:

            Code:
            . tsset ID date
            
            Panel variable: ID (strongly balanced)
            Time variable: date, 01jan2009 01:00:00 to 31dec2020 23:00:00, but with gaps
            Delta: .001 seconds
            
            .
            . xtscc y x1 x2 x3 x4 i.hour#i.month i.month#i.year
            too many values
            r(134);
            
            end of do-file
            Do you know any other way I could fix this?

            I also tried to uninstall/install the xtscc package, but it didn't help. I am using Stata 17.

            Thank you!

            Comment


            • #7
              xtscc y x1 x2 x3 x4 i.hour#i.month i.month#i.year
              OLS has to invert a matrix, so including too many indicators (highlighted) is not a good idea. Install ivreghdfe from SSC and absorb these indicators.

              Comment


              • #8
                Thank you Andrew for the ivreghdfe command. I am going to try it and let everyone knows if it works.

                Comment


                • #9
                  I just have some updates if someone encounters the same problems I did.

                  First of all, as Andrew pointed out, xtscc seems to not work properly with too many fixed effects. And I tried as he suggested: ivreghdfe.

                  I could not make ivreghdfe work. It took more than a day to run. I also tried to restrict my data several times, but it didn't help.

                  So, now I am trying an old version of reghdfe, this could work because as ivreghdfe, it absorbs the fixed effects, so computationally-wise should be faster. I can also cluster at the date dimension and use the DK standard error.
                  This worked great! just in case you also need to install avar, and for the code to work you need to put the word old (code below)

                  Code:
                  reghdfe y x1 x2 x3 x4,  a(i.hour#i.month i.month#year) old vce( cluster date, dkraay(4))
                  Thank you Andrew and Joro for the help!
                  and I hope this help someone in the future

                  Comment


                  • #10
                    Originally posted by Lucia Altesor View Post

                    I could not make ivreghdfe work.

                    Not sure what you ran, but the estimation

                    Code:
                    reghdfe y x1 x2 x3 x4, a(i.hour#i.month i.month#year) old vce( cluster date, dkraay(4))
                    in ivreghdfe should be specified as:

                    Code:
                    ivreghdfe y x1 x2 x3 x4, a(i.hour#i.month i.month#year)  cluster(date) dkraay(4)

                    Comment


                    • #11
                      Yes, sorry I should have been more precise. What I meant is that ivreghdfe worked but it took so long to show the output that I had to stop it.

                      Thanks again!

                      Comment

                      Working...
                      X