Announcement

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

  • Manipulate the stored coefficients

    Hi, I'd like to manipulate regression results by adding a certain value to each coefficient in the stored matrix. I do a Difference-in-Differences regression and my aim is to plot a graph afterwards where I rotate the coefficents and the corresponding confidence intervals around the linear trend from the pre-treatment period. I saw this in some papers but they used R as I saw from the graphs. Is this also possible in Stata?

  • #2
    You would probably need to write a little program and use the command ereturn repost within it.
    https://www.kripfganz.de/stata/

    Comment


    • #3
      Originally posted by Sebastian Kripfganz View Post
      You would probably need to write a little program and use the command ereturn repost within it.
      Could you give me more advise here? Maybe a short example?

      Comment


      • #4
        Code:
        ssc install erepost, replace

        Code:
        sysuse auto, clear
        regress mpg weight disp turn
        mat list e(b)
        *ADD 1000 TO EACH COEFFICIENT
        mat b= e(b) + J(1, colsof(e(b)), 1000)
        erepost b=b, rename
        mat list e(b)
        Res.:

        Code:
        . regress mpg weight disp turn
        
              Source |       SS           df       MS      Number of obs   =        74
        -------------+----------------------------------   F(3, 70)        =     44.47
               Model |  1602.59024         3  534.196747   Prob > F        =    0.0000
            Residual |  840.869218        70  12.0124174   R-squared       =    0.6559
        -------------+----------------------------------   Adj R-squared   =    0.6411
               Total |  2443.45946        73  33.4720474   Root MSE        =    3.4659
        
        ------------------------------------------------------------------------------
                 mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
              weight |  -.0059274   .0014326    -4.14   0.000    -.0087847   -.0030701
        displacement |   .0055957    .009906     0.56   0.574    -.0141613    .0253527
                turn |  -.1386576   .1793412    -0.77   0.442    -.4963424    .2190272
               _cons |   43.58846   4.964215     8.78   0.000     33.68765    53.48928
        ------------------------------------------------------------------------------
        
        . 
        . mat list e(b)
        
        e(b)[1,4]
                  weight  displacement          turn         _cons
        y1    -.00592742      .0055957    -.13865764     43.588464
        
        . 
        . *ADD 1000 TO EACH COEFFICIENT
        
        . 
        . mat b= e(b) + J(1, colsof(e(b)), 1000)
        
        . 
        . erepost b=b, rename
        
        . 
        . mat list e(b)
        
        e(b)[1,4]
                   c1         c2         c3         c4
        y1  999.99407  1000.0056  999.86134  1043.5885

        Comment

        Working...
        X