Announcement

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

  • Regreesion slope coeafficint

    Hello,

    I am working on accounting and financial data. And I need to translate the following equation to Stata: (1+k), where k is the slope coefficient from a regression of variable 1 on variable 2. Meaning I want to store the slope coefficient from a regression of variable 1 on variable 2 in a new variable.

    Thank you in advance for any help!

  • #2
    Mhm:
    welcome to this forum.
    Do you mean somethng like:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . regress price mpg
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =     20.26
           Model |   139449474         1   139449474   Prob > F        =    0.0000
        Residual |   495615923        72  6883554.48   R-squared       =    0.2196
    -------------+----------------------------------   Adj R-squared   =    0.2087
           Total |   635065396        73  8699525.97   Root MSE        =    2623.7
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
           _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
    ------------------------------------------------------------------------------
    
    . mat list e(b)
    
    e(b)[1,2]
               mpg       _cons
    y1  -238.89435   11253.061
    
    . g wanted=1+_b[mpg]
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X