Announcement

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

  • After regression, how can I do calculation using r2 and N?

    After regression, I want to calculate the scalar, that is r2*N

    How should I do that? I know my bad method is that copy and paste numbers from the result window, but since the numbers shown on the screen are truncated this method is bad.

    Many thanks in advance!

  • #2
    Perhaps this:
    Code:
    sysuse auto, clear
    (1978 Automobile Data)
    
    . reg 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 |      Coef.   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
    ------------------------------------------------------------------------------
    
    . ereturn list
    
    scalars:
                      e(N) =  74
                   e(df_m) =  1
                   e(df_r) =  72
                      e(F) =  20.25835256291883
                     e(r2) =  .2195828561874974
                   e(rmse) =  2623.652888667586
                    e(mss) =  139449473.5462301
                    e(rss) =  495615922.5753915
                   e(r2_a) =  .2087437291901015
                     e(ll) =  -686.5395809065244
                   e(ll_0) =  -695.7128688987767
                   e(rank) =  2
    
    macros:
                e(cmdline) : "regress price mpg"
                  e(title) : "Linear regression"
              e(marginsok) : "XB default"
                    e(vce) : "ols"
                 e(depvar) : "price"
                    e(cmd) : "regress"
             e(properties) : "b V"
                e(predict) : "regres_p"
                  e(model) : "ols"
              e(estat_cmd) : "regress_estat"
    
    matrices:
                      e(b) :  1 x 2
                      e(V) :  2 x 2
    
    functions:
                 e(sample)   
    
    . display e(N)*e(r2)
    16.249131

    Comment

    Working...
    X