1

我通过 stata 进行了回归reg y x并得到了这个结果。

      Source |       SS       df       MS              Number of obs =      10
-------------+------------------------------           F(  1,     8) =   19.35
       Model |  .158119449     1  .158119449           Prob > F      =  0.0023
    Residual |  .065358209     8  .008169776           R-squared     =  0.7075
-------------+------------------------------           Adj R-squared =  0.6710
       Total |  .223477658     9  .024830851           Root MSE      =  .09039

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           x |   .4183884   .0951025     4.40   0.002     .1990816    .6376952
       _cons |     3.2228   .2231597    14.44   0.000     2.708193    3.737407
------------------------------------------------------------------------------

我不确定 SS、df、MS 和 _con 等很多缩写是什么意思。我在哪里可以找到这些缩写的密钥?我试过help reg无济于事。最初,我只是想得到回归线的 y 截距和斜率。

4

1 回答 1

2

首先,您需要help regress在标题Saved results下键入并查看。您将看到如下所示:

regress saves the following in e():

Scalars        
  e(N)                number of observations
  e(mss)              model sum of squares
  e(df_m)             model degrees of freedom
  e(rss)              residual sum of squares
  e(df_r)             residual degrees of freedom

...

现在,如果您只对一两个数量感兴趣,请ereturn list在运行模型后键入,然后提取您想要的元素:

例子:

. sysuse auto
(1978 Automobile Data)


. reg mpg price length

      Source |       SS       df       MS              Number of obs =      74
-------------+------------------------------           F(  2,    71) =   66.65
       Model |   1594.2534     2  797.126698           Prob > F      =  0.0000
    Residual |  849.206062    71  11.9606488           R-squared     =  0.6525
-------------+------------------------------           Adj R-squared =  0.6427
       Total |  2443.45946    73  33.4720474           Root MSE      =  3.4584

------------------------------------------------------------------------------
         mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       price |  -.0003013   .0001522    -1.98   0.052    -.0006047    2.10e-06
      length |  -.1895347    .020155    -9.40   0.000    -.2297226   -.1493468
       _cons |   58.77451   3.509998    16.74   0.000     51.77577    65.77325
------------------------------------------------------------------------------

. ereturn list

scalars:
                  e(N) =  74
               e(df_m) =  2
               e(df_r) =  71
                  e(F) =  66.64577432164889
                 e(r2) =  .6524574781898139
               e(rmse) =  3.458417089846885
                e(mss) =  1594.253396977965
                e(rss) =  849.2060624814947
               e(r2_a) =  .6426675479979778
                 e(ll) =  -195.2902121561856
               e(ll_0) =  -234.3943376482347
               e(rank) =  3

macros:
            e(cmdline) : "regress mpg price length"
              e(title) : "Linear regression"
          e(marginsok) : "XB default"
                e(vce) : "ols"
             e(depvar) : "mpg"
                e(cmd) : "regress"
         e(properties) : "b V"
            e(predict) : "regres_p"
              e(model) : "ols"
          e(estat_cmd) : "regress_estat"

matrices:
                  e(b) :  1 x 3
                  e(V) :  3 x 3

functions:
             e(sample)  

你说你想要常数和斜率。然后你可以在 Stata 中使用 Mata :

 matrix list e(b)

e(b)[1,3]
         price      length       _cons
y1  -.00030128  -.18953472   58.774508
于 2013-09-11T12:33:25.907 回答