我通过reg y x
在stata中做了回归并得到了这个结果。
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截距和斜率。
答案 0 :(得分:2)
首先,您需要输入help regress
并在标题已保存的结果下查看。您将看到如下所示:
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