Announcement

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

  • GMM post-estimation test for serial correlation of residuals

    Hello everyone,

    is there a way to test for serial correlation of the residuals after applying GMM?

    Looking at
    Code:
    gmm postestimation
    I was not able to find anything related.

    Thanks!

  • #2
    Generalized method of moments (GMM) is an estimation method, just like OLS and maximum likelihood. gmm is the Stata command that implements GMM estimation, and therefore, your question does not make sense. What model are you estimating? Do you have time-series data or panel data?

    Comment


    • #3
      Thanks Andrew for the reply!

      Let's say that I have a simple model with panel data:

      yit = alphai + beta*xit + uit

      Let me stress that I do not want to use other estimation methods that are not gmm (and, in particular, the command gmm of Stata).

      beta and alpha_i are estimated by minimizing (yit - alphai - beta*xit) conditionally on instruments.

      From this, I can recover fitted residuals as uit = yit - alphai - beta*xit.

      Trivially, I can regress uit on uit-1, but that would not give me a formal test of serial correlation.

      Is there a way to improve upon that?

      Comment


      • #4
        From this, I can recover fitted residuals as uit = yit - alphai - beta*xit.

        Trivially, I can regress uit on uit-1, but that would not give me a formal test of serial correlation.
        The issue that I see with this approach is that with panel data, you can order the residuals in many different ways as the panel identifier is assigned arbitrarily. Even with a non-parametric random order test, you can get different results depending on how you order the residuals.

        Code:
        help runtest
        Testing for serial correlation in panel data differs from how you do it in time-series data. See https://journals.sagepub.com/doi/pdf...867X0300300206 for a discussion and the corresponding xtserial command which implements Wooldridge's test of 1st order serial correlation.

        Let me stress that I do not want to use other estimation methods that are not gmm
        You seem to imply that serial correlation is a function of the estimator. Unless the estimation method models the serial correlation, I don't think that finding the existence of 1st order serial correlation in a linear panel-data model can be ignored if you are using an estimation method that does not address the serial correlation.
        Last edited by Andrew Musau; 09 Apr 2024, 19:00.

        Comment


        • #5
          For a simple linear panel data model, you can use my xtdpdgmm command to estimate the coefficients by GMM. This package comes with postestimation commands estat serial and estat serialpm for serial-correlation testing.
          https://www.kripfganz.de/stata/

          Comment


          • #6
            Originally posted by Andrew Musau View Post
            Testing for serial correlation in panel data differs from how you do it in time-series data. See https://journals.sagepub.com/doi/pdf...867X0300300206 for a discussion and the corresponding xtserial command which implements Wooldridge's test of 1st order serial correlation.
            Yes, I was aware of xtserial, but it does not seem right to use it on the demeaned residuals. Happy to be wrong about this.

            Originally posted by Sebastian Kripfganz View Post
            For a simple linear panel data model, you can use my xtdpdgmm command to estimate the coefficients by GMM. This package comes with postestimation commands estat serial and estat serialpm for serial-correlation testing.
            Thanks for the suggestion. Unfortunately, this will not do as I specifically want to work with the command gmm.

            Comment


            • #7
              Going back to my point in #4, what matters is the model and not the estimator. Notice that the predicted residuals are the same below if I estimate the linear FE model with xtreg, fe (the within-estimator) and gmm on the demeaned variables (GMM). xtserial tests for 1st order serial correlation in random- or fixed-effects one-way linear models. So if this is the model that you are estimating with GMM, then the test is valid for such a model. I also suspect that you can estimate the same model that you are estimating in gmm using Sebastian's xtdpdgmm command, in which case its tests of serial correlation would be valid for your model.

              Code:
              webuse grunfeld, clear
              xtset company year
              xtdata, fe
              gmm (invest - {xb: mvalue kstock} - {b0}), ///
              instruments(mvalue kstock)
              predict res, res
              list res in 1/10, sep(0)
              
              webuse grunfeld, clear
              xtset company year
              xtreg invest mvalue kstock, fe
              predict res2, e
              list res in 1/10, sep(0)
              Res.:

              Code:
              . webuse grunfeld, clear
              
              . xtset company year
              
              Panel variable: company (strongly balanced)
               Time variable: year, 1935 to 1954
                       Delta: 1 year
              
              . xtdata, fe
              
              . gmm (invest - {xb: mvalue kstock} - {b0}), ///
              > instruments(mvalue kstock)
              
              Step 1
              Iteration 0:  GMM criterion Q(b) =  29908.181  
              Iteration 1:  GMM criterion Q(b) =  7.288e-22  
              Iteration 2:  GMM criterion Q(b) =  5.503e-29  
              
              Step 2
              Iteration 0:  GMM criterion Q(b) =  3.998e-33  
              Iteration 1:  GMM criterion Q(b) =  3.588e-33  
              
              note: model is exactly identified.
              
              GMM estimation
              
              Number of parameters =   3
              Number of moments    =   3
              Initial weight matrix: Unadjusted                 Number of obs   =        200
              GMM weight matrix:     Robust
              
              ------------------------------------------------------------------------------
                           |               Robust
                           | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                    mvalue |   .1101238   .0187877     5.86   0.000     .0733006     .146947
                    kstock |   .3100653   .0414913     7.47   0.000     .2287439    .3913868
              -------------+----------------------------------------------------------------
                       /b0 |  -58.74393   22.66214    -2.59   0.010    -103.1609   -14.32695
              ------------------------------------------------------------------------------
              Instruments for equation 1: mvalue kstock _cons
              
              . predict res, res
              
              . list res in 1/10, sep(0)
              
                   +-----------+
                   |       res |
                   |-----------|
                1. |   48.0124 |
                2. | -67.57689 |
                3. | -161.0005 |
                4. | -44.35663 |
                5. | -136.9566 |
                6. | -44.15273 |
                7. |  1.972566 |
                8. |  66.87722 |
                9. |  41.59961 |
               10. |  73.02239 |
                   +-----------+
              
              .
              . webuse grunfeld, clear
              
              . xtset company year
              
              Panel variable: company (strongly balanced)
               Time variable: year, 1935 to 1954
                       Delta: 1 year
              
              . xtreg invest mvalue kstock, fe
              
              Fixed-effects (within) regression               Number of obs     =        200
              Group variable: company                         Number of groups  =         10
              
              R-squared:                                      Obs per group:
                   Within  = 0.7668                                         min =         20
                   Between = 0.8194                                         avg =       20.0
                   Overall = 0.8060                                         max =         20
              
                                                              F(2, 188)         =     309.01
              corr(u_i, Xb) = -0.1517                         Prob > F          =     0.0000
              
              ------------------------------------------------------------------------------
                    invest | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                    mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
                    kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
                     _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
              -------------+----------------------------------------------------------------
                   sigma_u |  85.732501
                   sigma_e |  52.767964
                       rho |  .72525012   (fraction of variance due to u_i)
              ------------------------------------------------------------------------------
              F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
              
              . predict res2, e
              
              . list res in 1/10, sep(0)
              
                 +-----------+
                   |      res2 |
                   |-----------|
                1. |   48.0124 |
                2. | -67.57689 |
                3. | -161.0005 |
                4. | -44.35663 |
                5. | -136.9566 |
                6. | -44.15273 |
                7. |  1.972566 |
                8. |  66.87722 |
                9. |  41.59961 |
               10. |  73.02239 |
                   +-----------+

              Comment


              • #8
                Originally posted by Andrew Musau View Post
                Going back to my point in #4, what matters is the model and not the estimator. Notice that the predicted residuals are the same below if I estimate the linear FE model with xtreg, fe (the within-estimator) and gmm on the demeaned variables (GMM). xtserial tests for 1st order serial correlation in random- or fixed-effects one-way linear models. So if this is the model that you are estimating with GMM, then the test is valid for such a model. I also suspect that you can estimate the same model that you are estimating in gmm using Sebastian's xtdpdgmm command, in which case its tests of serial correlation would be valid for your model.
                [/CODE]
                Thanks, but an alternative solution to gmm is not what the question is asking for. For example, if I want to include coefficient restrictions or cross-equation restrictions, this will not work.

                Seems like there is no easy way to address this on Stata! Thanks for the help.

                Comment

                Working...
                X