Announcement

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

  • Xtabond - Exporting p values of Arellano Bond test

    Hi everyone

    I would like to export the p values of the Arellano Bond test for autocorrelation to my Excel output (the post estimation command of xtabond: estat abond). I am using the below code but it does not properly export the p value for the test for order 2. I would be grateful if you could advise what would be the error in my code.

    Thanks in advance.

    Jala




    local ivar1 a
    local ivar2 b
    local ivar3 c

    forv i=1/3 {
    xi: xtabond y control1 control2 control3 `ivar`i'' i.year, vce(gmm) twostep
    estat abond
    local p1= 2*normal(e(arm1))
    local p2= 2*normal(e(arm2))
    outreg2 using "$temp_dir\results.xls", keep(l.y control1 control2 control3 `ivar`i'') label addtext(Time fixed effects, Yes) addstat(Z-stat. Arellano Bond test of autocorrelation in FD errors (order 1), e(arm1), P-value of Arellano Bond test of autocorrelation in FD errors (order 1), `p1', Z-stat. Arellano Bond test of autocorrelation in FD errors (order 2), e(arm2), P-value of Arellano Bond test of autocorrelation in FD errors (order 2), `p2')
    }

  • #2
    xtabond and outreg2 are from SSC, as you are asked to explain (FAQ Advice #12). You do not present a reproducible example or show any output.

    but it does not properly export the p value for the test for order 2
    What does this mean? You get a p-value, but it is incorrect? Show us an example.

    Comment


    • #3
      Thanks a lot Andrew Musau for your prompt reply. Please find below an example:


      This is what I get in the regression:

      Arellano–Bond test for zero autocorrelation in first-differenced errors
      H0: No autocorrelation

      Order z Prob > z

      1 -1.4737 0.1406
      2 .89763 0.3694




      And this is what gets exported to Excel:
      Z-stat. Arellano Bond test of autocorrelation in FD errors (order 1) -1.474
      P-value of Arellano Bond test of autocorrelation in FD errors (order 1) 0.141
      Z-stat. Arellano Bond test of autocorrelation in FD errors (order 2) 0.898
      P-value of Arellano Bond test of autocorrelation in FD errors (order 2) 1.631

      Comment


      • #4
        You need

        Code:
        di 2*normal(-abs(`e(arm2)'))
        i.e.,

        Code:
        di 2*normal(-abs(.89763))
        Res.:

        Code:
        . di 2*normal(-abs(.89763))
        .36938284

        Comment


        • #5
          Andrew Musau I am sorry for the too many questions. I added di 2*normal(-abs(`e(arm2)')) after local p2= 2*normal(e(arm2)) and I still get the same error.

          Comment


          • #6
            Sorry, I did not elaborate on my reply. Your formula works fine if the statistic is negative, but if it is positive, we need to make it negative. Therefore, to guarantee that it is negative regardless of the sign of the statistic, we use the -abs()- function that takes the absolute value of the statistic, and then we add a negative sign in front of it. So #4 implies the following modifications to your code:

            Code:
            forv i=1/3 {
            xi: xtabond y control1 control2 control3 `ivar`i'' i.year, vce(gmm) twostep
            estat abond
            local p1= 2*normal(-abs(`e(arm1)'))
            local p2= 2*normal(-abs(`e(arm2)'))
            outreg2 using "$temp_dir\results.xls", keep(l.y control1 control2 control3 `ivar`i'') label addtext(Time fixed effects, Yes) addstat(Z-stat. Arellano Bond test of autocorrelation in FD errors (order 1), e(arm1), P-value of Arellano Bond test of autocorrelation in FD errors (order 1), `p1', Z-stat. Arellano Bond test of autocorrelation in FD errors (order 2), e(arm2), P-value of Arellano Bond test of autocorrelation in FD errors (order 2), `p2')
            }

            Comment


            • #7
              Thanks a lot Andrew Musau. This is super useful, it works perfectly.

              Comment


              • #8
                Dear Andrew Musau

                On a related front to my previous question, in case I am running the regressions this time separately and not in a loop, please find below code. I would be grateful if you could advise on the outreg2 command since it is not working. Thanks in advance.

                Jala



                xi: xtabond y x1 x2 x3 i.year, vce(gmm) twostep
                estat abond
                local p1_eq1 = 2*normal(-abs(`e(arm1)'))
                local p2_eq1 = 2*normal(-abs(`e(arm2)'))
                est store eq1

                xi: xtabond y x1 x3 i.year, vce(gmm) twostep
                estat abond
                local p1_eq2 = 2*normal(-abs(`e(arm1)'))
                local p2_eq2 = 2*normal(-abs(`e(arm2)'))
                est store eq2


                outreg2 [eq1] using "$temp_dir\results.xls", label addtext(Time fixed effects, Yes) addstat(Z-stat. Arellano Bond test of autocorrelation in FD errors (order 1), e(arm1), P-value of Arellano Bond test of autocorrelation in FD errors (order 1), `p1_eq1', Z-stat. Arellano Bond test of autocorrelation in FD errors (order 2), e(arm2), P-value of Arellano Bond test of autocorrelation in FD errors (order 2), `p2_eq1')

                outreg2 [eq2] using "$temp_dir\results.xls", label addtext(Time fixed effects, Yes) addstat(Z-stat. Arellano Bond test of autocorrelation in FD errors (order 1), e(arm1), P-value of Arellano Bond test of autocorrelation in FD errors (order 1), `p1_eq2', Z-stat. Arellano Bond test of autocorrelation in FD errors (order 2), e(arm2), P-value of Arellano Bond test of autocorrelation in FD errors (order 2), `p2_eq2')

                Comment

                Working...
                X