Announcement

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

  • Saving p value of z statistic after ivreg2

    Hi.

    For a falsification test, I want to run an IV regression and store the value of the coefficient of the instrumented variable and the corresponding p value for the coefficient.
    I am able to store the coefficient value using the following:

    matrix coef_IV = e(b)
    scalar b = coef_IV[1,1]
    What would be the command for saving the p value of the z statistic for the coefficient.

    Thanks.

  • #2
    You can get the coefficient more easily: Say the intrumented variable is called x, then the coefficient is _b[x] . Simmilarly, the standard error is in _se[x]. When applicable, the degrees of freedom are stored in e(df_r). Now you have all the ingredients necessary for computing p-values and confidence intervals.

    Alternatively you can look at r(table) which most estimation commands leave behind.

    Here is an example. I showed the parts for pcturban, as with non-significant coefficients it is easier to see that computations are correct as there are more numbers to show instead of many 0s

    Code:
    . webuse hsng2, clear
    (1980 Census housing data)
    
    . ivregress 2sls rent pcturban (hsngval = faminc i.region), small
    
    
    Instrumental variables 2SLS regression
    
          Source |       SS       df       MS         Number of obs   =         50
    -------------+------------------------------      F(  2,    47)   =      42.66
           Model |  36677.4033     2  18338.7017      Prob > F        =     0.0000
        Residual |  24565.7167    47  522.674823      R-squared       =     0.5989
    -------------+------------------------------      Adj R-squared   =     0.5818
           Total |    61243.12    49  1249.85959      Root MSE        =     22.862
    
    ------------------------------------------------------------------------------
            rent | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0022398   .0003388     6.61   0.000     .0015583    .0029213
        pcturban |    .081516   .3081528     0.26   0.793    -.5384074    .7014394
           _cons |   120.7065   15.70688     7.68   0.000     89.10834    152.3047
    ------------------------------------------------------------------------------
    Instrumented: hsngval
     Instruments: pcturban faminc 2.region 3.region 4.region
    
    .
    . di "p-value for pcturban = " 2*ttail(e(df_r),abs(_b[pcturban]/_se[pcturban]))
    p-value for pcturban = .79252738
    
    .
    . di "95% ci of pcturban = [" _b[pcturban] - invt(e(df_r),0.975)*_se[pcturban] ///
    >    " , " _b[pcturban] + invt(e(df_r),0.975)*_se[pcturban] "]"
    95% ci of pcturban = [-.53840744 , .70143938]
    
    .    
    . matlist r(table)
    
                 |   hsngval   pcturban      _cons
    -------------+---------------------------------
               b |  .0022398    .081516   120.7065
              se |  .0003388   .3081528   15.70688
               t |  6.611874    .264531   7.684943
          pvalue |  3.17e-08   .7925274   7.55e-10
              ll |  .0015583  -.5384074   89.10834
              ul |  .0029213   .7014394   152.3047
              df |        47         47         47
            crit |  2.011741   2.011741   2.011741
           eform |         0          0          0
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks a lot.

      Comment

      Working...
      X