全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
86800 26
2007-08-27
<P>[求助]在stata中,怎样进行分组回归</P>
<P>如有两年的面板数据,每年有1000个,现在想按第一年某变量x的大小进行分组,分5组,分别对每一组回归,请问stata中有什么命令吗?</P>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2007-8-27 17:21:00

命令格式:

by 分组变量名 : reg 因变量 自变量1...自变量k

例如:

sysuse auto

by foreign: reg mpg weight

请验证。

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-8-27 17:24:00

. by foreign: reg mpg weight

--------------------------------------------------------------------------------
-> foreign = Domestic

Source | SS df MS Number of obs = 52
-------------+------------------------------ F( 1, 50) = 164.85
Model | 880.404425 1 880.404425 Prob > F = 0.0000
Residual | 267.037883 50 5.34075765 R-squared = 0.7673
-------------+------------------------------ Adj R-squared = 0.7626
Total | 1147.44231 51 22.4988688 Root MSE = 2.311

------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0059751 .0004654 -12.84 0.000 -.0069098 -.0050403
_cons | 39.64696 1.576622 25.15 0.000 36.48023 42.8137
------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-> foreign = Foreign

Source | SS df MS Number of obs = 22
-------------+------------------------------ F( 1, 20) = 17.47
Model | 427.990298 1 427.990298 Prob > F = 0.0005
Residual | 489.873338 20 24.4936669 R-squared = 0.4663
-------------+------------------------------ Adj R-squared = 0.4396
Total | 917.863636 21 43.7077922 Root MSE = 4.9491

------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.010426 .0024942 -4.18 0.000 -.0156287 -.0052232
_cons | 48.9183 5.871851 8.33 0.000 36.66983 61.16676
------------------------------------------------------------------------------

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-8-27 17:56:00

谢谢楼上的,还有一个问题,怎样进行分组,譬如x为人均收入水平,我想将收入水平分为10组,然后对每一组进行回归。

再一次感谢minixi

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-8-27 19:01:00
Programming functions


autocode(x,n,x0,x1)
Domain x: -8e+307 to 8e+307
Domain n: integers 1 to 8e+307
Domain x0: -8e+307 to 8e+307
Domain x1: x0 to 8e+307
Range: x0 to x1
Description: partitions the interval from x0 to x1 into n
equal-length intervals and returns the upper bound
of the interval that contains x. This function is
an automated version of recode(). See [U] 25
Dealing with categorical variables for an example.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-3-15 15:58:02
请问一下,问什么我的stata运行autocode()出错呢?
. autocode(weight,300,2440,3860)
unrecognized command:  autocode
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群