Announcement

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

  • P Value after xtreg

    How to calculate p value after running xtreg?

    I tried to use the following formula, but the p value is different from the stata output.
    (2 * ttail(e(df_m), abs(_b[weight]/_se[weight]))) I really appreciate if anyone can answer this. Zhen

  • #2
    It's e(df_r), not e(df_m).

    Comment


    • #3
      By using xtreg, there's no e(df_r), only e(df_m)

      Comment


      • #4
        I used random effect for xtreg.

        Comment


        • #5
          Notice that with -xtreg, re- you get a z statistic and not a t statistic. You do not need any degrees of freedom here

          Code:
           2*(normal(-(_b[weight]/_se[weight])))

          Comment


          • #6
            Re #3, I thought you had used -xtreg, fe-, which does leave e(df_r).

            Comment


            • #7
              Thanks Andrew. I didn't notice the z score. It works great

              Thanks Clyde for clarification.

              Comment


              • #8
                Thanks to all, this forum is really helpful. To get the p-value after random effects xtreg, the coefficient should be in absolute value:

                2*(normal(-(abs(_b[`var'])/_se[`var'])))

                Comment


                • #9
                  Thanks for the correction! As this thread is a few years old, also note the following way to obtain P-values:

                  Code:
                  webuse grunfeld, clear
                  xtreg invest mvalue kstock, re
                  di r(table)["pvalue", "mvalue"]
                  di r(table)["pvalue", "kstock"]
                  di r(table)["pvalue", "_cons"]
                  Res.:

                  Code:
                  . xtreg invest mvalue kstock, re
                  
                  Random-effects GLS regression                   Number of obs     =        200
                  Group variable: company                         Number of groups  =         10
                  
                  R-sq:                                           Obs per group:
                       within  = 0.7668                                         min =         20
                       between = 0.8196                                         avg =       20.0
                       overall = 0.8061                                         max =         20
                  
                                                                  Wald chi2(2)      =     657.67
                  corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
                  
                  ------------------------------------------------------------------------------
                        invest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                        mvalue |   .1097811   .0104927    10.46   0.000     .0892159    .1303464
                        kstock |    .308113   .0171805    17.93   0.000     .2744399    .3417861
                         _cons |  -57.83441   28.89893    -2.00   0.045    -114.4753   -1.193537
                  -------------+----------------------------------------------------------------
                       sigma_u |   84.20095
                       sigma_e |  52.767964
                           rho |  .71800838   (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------
                  
                  . di r(table)["pvalue", "mvalue"]
                  1.282e-25
                  
                  . di r(table)["pvalue", "kstock"]
                  6.411e-72
                  
                  . di r(table)["pvalue", "_cons"]
                  .04536391
                  
                  .
                  Last edited by Andrew Musau; 10 Feb 2022, 14:10.

                  Comment


                  • #10
                    Thank you, Andrew!

                    Comment

                    Working...
                    X