全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1739 2
2015-12-07
悬赏 60 个论坛币 已解决
数据分不同行业不同国家。现在要对每个公司同时按行业按国家回归,想要得到的是每家公司的残差是多少。这个代码怎么写?小白求指教。

最佳答案

风向我吹 查看完整内容

egen group=group(country industry) sum group local n=r(max) gen e=. forvalue i=1/`n' { reg y x1 x2 x3 x4 if g==`i' est store m_`i' predict r if e(sample), res replace e=r if e(sample) drop r } drop g
二维码

扫码加我 拉你入群

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

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

全部回复
2015-12-7 13:36:59
egen group=group(country industry)
sum group
local n=r(max)
gen e=.
forvalue i=1/`n' {
reg  y x1 x2 x3 x4 if g==`i'   
est store m_`i'
predict r if e(sample), res
replace e=r if e(sample)
drop r
}
drop g
二维码

扫码加我 拉你入群

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

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

2015-12-7 17:04:01
est store m_`i' 是我为了看回归系数加的,如果只需要求残差,可以去掉
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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