Announcement

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

  • Calculating the mean of a coefficient of SUR regression

    Hello,

    I am performing an event study using SUR regression, where the abnormal stock return is shown by the coefficient "dummyEvent". The output shown below is a subset of 3 out of a total of 85 firms for which the SUR is run. Now I would like to calculate the average of the coefficient "dummyEvent" of all 85 regressions of the SUR and store it in a new variable. Reading other threads and Stata's help page, I came across the possibility to read out the individual coefficients via the following code.
    Code:
    matrix b = e(b)
    display el(b,1,3) el(b,1,7) el(b,1,11)
    One could sum the coefficients and divide by the number of companies, however this procedure is cumbersome for 85 companies in the SUR regression. Does anyone have any ideas on how to solve it more efficiently? Maybe with a foreach loop?

    Code:
     
    Coef. Std. Err. z P>z [Interval]
    Amazon
    Dow Jones .5122257 .0651809 7.86 0.000 .3844734 .639978
    dummyDayBefore -.0005352 .0069166 -0.08 0.938 -.0140915 .0130212
    dummyEvent .0023194 .0069305 0.33 0.738 -.0112642 .0159029
    _cons -.0005643 .0006683 -0.84 0.398 -.0018742 .0007455
    Tesla
    DowJones 1.542822 .0984094 15.68 0.000 1.349943 1.735701
    dummyDayBefore -.0095792 .0104426 -0.92 0.359 -.0300464 .0108879
    dummyEvent .0006608 .0104636 0.06 0.950 -.0198475 .0211691
    _cons -.0008611 .001009 -0.85 0.393 -.0028387 .0011164
    Apple
    DowJones 1.169062 .1275515 9.17 0.000 .9190661 1.419059
    dummyDayBefore .0157705 .013535 1.17 0.244 -.0107576 .0422986
    dummyEvent .0132543 .0135622 0.98 0.328 -.0133271 .0398357
    _cons -.0016939 .0013078 -1.30 0.195 -.0042571 .0008693
    Best,
    Oscar

  • #2
    Code:
    sysuse auto, clear
    sureg (price foreign weight length) (mpg foreign weight) (displ foreign weight)
    mat b=e(b)
    local coleqs: coleq(b)
    local coleqs: list uniq coleqs
    *e.g., average "foreign" and "weight" coefficients across equations
    foreach eq of local coleqs{
        di "equation is for `eq' "
        margins, expression(0.5*_b[`eq':foreign] + 0.5*_b[`eq':weight])
    }
    Res.:

    Code:
    . sureg (price foreign weight length) (mpg foreign weight) (displ foreign weight)
    
    Seemingly unrelated regression
    --------------------------------------------------------------------------
    Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
    --------------------------------------------------------------------------
    price                 74       3    1967.769    0.5488      89.74   0.0000
    mpg                   74       2    3.337283    0.6627     145.39   0.0000
    displacement          74       2    39.60002    0.8115     318.62   0.0000
    --------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    price        |
         foreign |    3575.26   621.7961     5.75   0.000     2356.562    4793.958
          weight |   5.691462   .9205043     6.18   0.000     3.887307    7.495618
          length |  -88.27114    31.4167    -2.81   0.005    -149.8467   -26.69554
           _cons |   4506.212   3588.044     1.26   0.209    -2526.225    11538.65
    -------------+----------------------------------------------------------------
    mpg          |
         foreign |  -1.650029   1.053958    -1.57   0.117    -3.715748    .4156902
          weight |  -.0065879   .0006241   -10.56   0.000     -.007811   -.0053647
           _cons |    41.6797   2.121197    19.65   0.000     37.52223    45.83717
    -------------+----------------------------------------------------------------
    displacement |
         foreign |   -25.6127   12.50621    -2.05   0.041    -50.12441   -1.100984
          weight |   .0967549   .0074051    13.07   0.000     .0822411    .1112686
           _cons |  -87.23548   25.17001    -3.47   0.001    -136.5678   -37.90317
    ------------------------------------------------------------------------------
    
    
    equation is for price 
    Warning: expression() does not contain predict() or xb().
    Warning: prediction constant over observations.
    
    Predictive margins                              Number of obs     =         74
    
    Expression   : 0.5*_b[price:foreign] + 0.5*_b[price:weight]
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |   1790.476   310.9925     5.76   0.000     1180.942     2400.01
    ------------------------------------------------------------------------------
    equation is for mpg 
    Warning: expression() does not contain predict() or xb().
    Warning: prediction constant over observations.
    
    Predictive margins                              Number of obs     =         74
    
    Expression   : 0.5*_b[mpg:foreign] + 0.5*_b[mpg:weight]
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |  -.8283085   .5271639    -1.57   0.116    -1.861531    .2049138
    ------------------------------------------------------------------------------
    equation is for displacement 
    Warning: expression() does not contain predict() or xb().
    Warning: prediction constant over observations.
    
    Predictive margins                              Number of obs     =         74
    
    Expression   : 0.5*_b[displacement:foreign] + 0.5*_b[displacement:weight]
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |  -12.75797   6.255299    -2.04   0.041    -25.01813   -.4978111
    ------------------------------------------------------------------------------
    
    .
    Last edited by Andrew Musau; 26 Apr 2021, 09:28.

    Comment


    • #3
      Hello Andrew,

      thank you for your helpful reply. Unfortunately, when I run your code, I don't get any output, Stata just shows that the code has been run (see attached output).

      Code:
      . matrix b=e(b)
      
      . local coleqs: coleq(b)
      
      . local coleqs: list uniq colegs
      
      . foreach eq of local coleqs{
        2.         di "equation is for `eq' "
        3.     margins, expression(0.5*_b[`eq':dummyDayBefore] + 0.5*_b[`eq':dummyEvent])
        4. }
      Do you know what could be the reason for this? I have specified my SUR regression as follows:

      Code:
      local subsetvar Amazon-Apple
      sureg (`subsetvar' = DowJones-dummyEvent) if inrange(mdy(Month,Day,Year),mdy(9,1,2010),mdy(2,8,2011))
      Thank you very much,
      Oscar

      Comment


      • #4
        My apologies Oscar Damgaard, I completely missed your response. It looks like you have a typo in your code:

        . matrix b=e(b) . local coleqs: coleq(b)
        . local coleqs: list uniq colegs
        . foreach eq of local coleqs{ 2
        . di "equation is for `eq' " 3
        . margins, expression(0.5*_b[`eq':dummyDayBefore] + 0.5*_b[`eq':dummyEvent]) 4
        . }
        should be "coleqs"

        Comment

        Working...
        X