Announcement

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

  • Advice on extracting data from regression and exporting into a matrix

    Dear all,

    I am trying to extract data from a pvar and mold it into a matrix. The output of the pvar is as follows

    Code:
    Final GMM Criterion Q(b) =      .156
    Initial weight matrix: Identity
    GMM weight matrix:     Robust
                                                       No. of obs      =     44475
                                                       No. of panels   =        38
                                                       Ave. no. of T   =  1170.395
    
    
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    value_dif    |
       value_dif |
             L1. |  -.0113901   .0330503    -0.34   0.730    -.0761674    .0533873
                 |
        IV_c_dif |
             L1. |   1918.093   476.1653     4.03   0.000     984.8264     2851.36
                 |
         val_dif |
             L1. |    .000953   .0005652     1.69   0.092    -.0001548    .0020608
                 |
         sat_dif |
             L1. |   .0000536   .0005408     0.10   0.921    -.0010063    .0011136
                 |
        qual_dif |
             L1. |  -.0008847   .0007642    -1.16   0.247    -.0023824     .000613
                 |
        sent_pos |
             L1. |  -.0014811   .0003022    -4.90   0.000    -.0020735   -.0008887
                 |
        sent_neg |
             L1. |   .0016537   .0004451     3.72   0.000     .0007813     .002526
                 |
             fgc |
             L1. |  -.0273508   .0277591    -0.99   0.324    -.0817577     .027056
                 |
             MVE |
             L1. |   1.32e-06   6.93e-07     1.91   0.057    -3.69e-08    2.68e-06
                 |
              at |
             L1. |  -1.48e-06   7.05e-07    -2.10   0.036    -2.86e-06   -1.00e-07
                 |
           adv_s |
             L1. |   4.14e-06   9.14e-06     0.45   0.651    -.0000138     .000022
    -------------+----------------------------------------------------------------
    IV_c_dif     |
       value_dif |
             L1. |   4.10e-07   4.44e-07     0.92   0.356    -4.61e-07    1.28e-06
                 |
        IV_c_dif |
             L1. |  -.0403185   .0202629    -1.99   0.047    -.0800332   -.0006039
                 |
         val_dif |
             L1. |   4.59e-09   3.98e-08     0.12   0.908    -7.34e-08    8.26e-08
                 |
         sat_dif |
             L1. |  -4.87e-09   4.36e-08    -0.11   0.911    -9.03e-08    8.06e-08
                 |
        qual_dif |
             L1. |  -6.98e-08   6.18e-08    -1.13   0.259    -1.91e-07    5.13e-08
                 |
        sent_pos |
             L1. |   2.26e-08   2.48e-08     0.91   0.361    -2.59e-08    7.12e-08
                 |
        sent_neg |
             L1. |  -2.50e-08   3.81e-08    -0.66   0.512    -9.97e-08    4.97e-08
                 |
             fgc |
             L1. |  -.0000328   3.36e-06    -9.77   0.000    -.0000394   -.0000262
                 |
             MVE |
             L1. |  -6.84e-11   8.14e-11    -0.84   0.400    -2.28e-10    9.11e-11
                 |
              at |
             L1. |  -9.97e-11   3.92e-11    -2.54   0.011    -1.77e-10   -2.28e-11
                 |
           adv_s |
             L1. |  -1.19e-09   9.44e-10    -1.26   0.209    -3.04e-09    6.65e-10
    
    ---------------------------------------------------------------------------
    
    <from here repeating for all variables>
    My matrix should look like the following
    value_dif IV_c_dif val_dif
    value_dif coefficient *** coefficient ***
    t-statistic t-statistic
    IV_c_dif coefficient *** coefficient ***
    t-statistic t-statistic
    val_dif coefficient *** coefficient ***
    t-statistic t-statistic
    for all variables listed above.

    I tried to get the coefficient and t-statistics via

    Code:
    estout, cells (b(star) t(par))
    which works fine in extracting the data, but I am not sure on how to put it into a matrix.

    Can anyone provide advice on how to achieve the matrix?

    Any help would be most appreciated.

    Best
    Micha



  • #2
    After running the gmm command, start with

    Code:
    mat Results= r(table)
    mat list Results
    and then you can create other matrices based on the elements of this matrix.

    Comment


    • #3
      Thanks for your reply Andrew! The command you mentioned you gives me an empty 1x1 matrix. Do i need to change the initial mat command?

      Thanks again

      Best
      Micha

      Comment


      • #4
        You should get a results matrix, similar to below

        Code:
        webuse docvisits, clear
        gmm (docvis - exp({xb:private chronic female income} + {b0})),instruments(private chronic female age black hispanic) deriv(/xb= -1*exp({xb:} + {b0})) deriv(/b0 = -1*exp({xb:} + {b0})) twostep
        Result:

        Code:
        GMM estimation
        
        Number of parameters =   5
        Number of moments    =   7
        Initial weight matrix: Unadjusted                 Number of obs   =      4,412
        GMM weight matrix:     Robust
        
        ------------------------------------------------------------------------------
                     |               Robust
                     |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             private |    .535335    .159904     3.35   0.001      .221929     .848741
             chronic |   1.090126   .0617659    17.65   0.000     .9690668    1.211185
              female |   .6636579   .0959885     6.91   0.000      .475524    .8517918
              income |   .0142855   .0027162     5.26   0.000     .0089618    .0196092
        -------------+----------------------------------------------------------------
                 /b0 |  -.5983477    .138433    -4.32   0.000    -.8696714    -.327024
        ------------------------------------------------------------------------------
        Instruments for equation 1: private chronic female age black hispanic _cons
        
        . mat Results= r(table)
        
        .
        . mat list Results
        
        Results[9,5]
                        xb:         xb:         xb:         xb:         b0:
                   private     chronic      female      income       _cons
             b   .53533501   1.0901257   .66365793   .01428549  -.59834766
            se   .15990395   .06176589   .09598845   .00271624     .138433
             z   3.3478535   17.649315   6.9139351   5.2592952  -4.3222906
        pvalue    .0008144   1.030e-69   4.714e-12   1.446e-07   .00001544
            ll   .22192902   .96906681   .47552402   .00896177  -.86967135
            ul   .84874101   1.2111847   .85179184   .01960922  -.32702396
            df           .           .           .           .           .
          crit    1.959964    1.959964    1.959964    1.959964    1.959964
         eform           0           0           0           0           0
        
        .
        Here the matrix is 9\(\times\)5.

        Comment


        • #5
          I would like to create PVAR results in a matrix form using esttab. Please help me to find a code. My output is not using GMM, it is using the command PVAR, that means many depvars. Please help.

          Comment


          • #6
            Originally posted by Xavier Babu View Post
            I would like to create PVAR results in a matrix form using esttab.
            I do not use pvar from the Stata Journal (FAQ Advice #12). However, you can check whether the command stores results in matrices from either

            Code:
            return list
            or

            Code:
            ereturn list
            Then look at

            Code:
            help matrix list
            to show us any such matrices. From here, it should be possible to illustrate how to use estout to output the contents of the matrices.

            Comment

            Working...
            X