全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
3736 2
2008-06-18

我在做一个分组回归的数据分析,共有480组,我需要对每一组分别求出估计值和残差。但是我不知道怎么来做,请多多赐教啊。

如果先用分组条件下的Regress,出来了所有的结果

然后用Predict,是不是会出错呢?

二维码

扫码加我 拉你入群

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

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

全部回复
2015-1-8 10:36:41
用if语句或者循环都可以,并用est store保存这个结果,predict命令应该可以使用。
二维码

扫码加我 拉你入群

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

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

2015-1-8 11:29:44
Assume your group variable name is var_group,the value of which ranges from 1 to 480, your dependent variable is y, and independent variables are x1, x2 and x3. Then You may try codes here below:


gen residual = .
forval i = 1/480{
    reg y x1 x2 x3 if var_group == `i'
    capture drop res_temp
    predict res_temp if var_group == `i'
    replace residual = res_temp if var_group == `i'
    drop res_temp
}

gen y_hat = y-residual

二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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