Announcement

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

  • - xtqptest - now on SSC: Bias-corrected Q(P) test for serial correlation in a fixed effect panel setting

    Dear all

    -xtqptest- is now available on SSC, thanks to Kit Baum. It performs the Born & Breitung (2016) bias-corrected LM-based test for serial correlation. It takes the combined residuals (fixed effect + idiosyncratic error; option ue in predict) as input and returns the Q(p) statistic described on page 1303 of aforementioned paper, as well as the corresponding p-values.

    It takes on option p, which is the order up to which should be checked for serial correlation. E.g. if p = 3, the null hypothesis is H0: No serial correlation up to order 3. If it is not specified, I set the default to 2 (somewhat arbitrarily).

    You can specify as many variables to be tested as you want (it loops internally).

    Example usage
    Code:
    sysuse xtline1, clear
    xtreg calories, fe
    predict ue, ue
    xtqptest ue
    xtqptest ue, p(1)
    Output is at the bottom of this post.

    Cheers
    Jesse

    References
    Testing for Serial Correlation in Fixed-Effects Panel Data Models, Benjamin Born and Jörg Breitung, Econometric Reviews 2016
    http://www.tandfonline.com/doi/abs/1...38.2014.976524

    Click image for larger version

Name:	xtqptest.PNG
Views:	1
Size:	19.0 KB
ID:	1353187
    Last edited by Jesse Wursten; 15 Aug 2016, 06:36.

  • #2
    Thanks to Kit Baum, there is a new version of xtqptest on ssc.

    Changelist
    - the syntax has changed from p() to lags(), to be consistent with the syntax of wntestq
    - new option: order(). This will calculate serial correlation of order k, rather than up to order k. This is the "LM" test in the BB(2016) paper.
    - Now supports unbalanced panels (adapted from the paper, not literally prescribed, hence not peer-reviewed - use at own risk!)
    - Can now be used as postestimation command after xtreg

    Comment


    • #3
      Nice work. Yet, I believe there might be a bug in your latest version; or am I doing something wrong?

      No matter which lag order I specify, I always receive the same output for p (lags): 2
      Code:
      . sysuse xtline1, clear
      
      . qui xtreg calories, fe
      
      . predict ue, ue
      
      . xtqptest ue
      
      Bias-corrected Born and Breitung (2016) Q(p)-test on variables ue
      Panelvar: person
      Timevar: day
      p (lags): 2
      --------------------------------------------------------------------------------------+
                 Variable           | Q(p)-stat   p-value   |      N    maxT |   balance?   |
      ------------------------------+-----------------------+----------------+--------------|
                    ue              +   15.84      0.000    +      3     365 +   balanced   |
      --------------------------------------------------------------------------------------+
       Notes: Under H0, Q(p) ~ chi2(p)
          H0: No serial correlation up to order p.
          Ha: Some serial correlation up to order p.
      
      . xtqptest ue, lags(1)
      
      Bias-corrected Born and Breitung (2016) Q(p)-test on variables ue
      Panelvar: person
      Timevar: day
      p (lags): 2
      --------------------------------------------------------------------------------------+
                 Variable           | Q(p)-stat   p-value   |      N    maxT |   balance?   |
      ------------------------------+-----------------------+----------------+--------------|
                    ue              +   15.84      0.000    +      3     365 +   balanced   |
      --------------------------------------------------------------------------------------+
       Notes: Under H0, Q(p) ~ chi2(p)
          H0: No serial correlation up to order p.
          Ha: Some serial correlation up to order p.
      and so on.
      https://www.kripfganz.de/stata/

      Comment


      • #4
        Good catch! A side-effect of switching from p to lags, I'll have it fixed tomorrow! Thanks!

        Comment


        • #5
          It should be fixed now.

          Comment


          • #6
            -xtqptest- has been updated on ssc, thanks to Kit Baum as usual. I recommend redoing any serial correlation tests of unbalanced data - there was a bug in the program due to an incorrect understanding of Mata's mean() function, which led to slightly incorrect test statistics if the residuals were of varying time lengths. This applies both to the Q(p) and LM(k) tests. It has been fixed in the current version (1.1.0). On the plus side, the authors of the original paper (Born & Breitung, 2006) have confirmed that the method used to calculate the Q(p) statistic for unbalanced data is correct (it is not explicitly mentioned in the paper).

            Comment

            Working...
            X