黃河泉 发表于 2020-2-10 18:27 
请 ssc install asreg 并见其 help asreg。
非常感谢老师的回复,目前已有思路!
还有两个问题想要请教一下:
1.我使用bys code: asreg y RiskPremium2 SMB2 HML2 RMW2 CMA2, wind(time 90) se fit这个代码算出来第90天的数据是用1-90的数据算出来的,但是我想实现1-90天的残差作为第91天数据,2-91天残差作为第92天数据,依次类推,没有在help asreg找到相对应的指令,麻烦老师指教。
2.在得到残差后,我还需要算出残差的标准差,在bys code: asreg y RiskPremium2 SMB2 HML2 RMW2 CMA2, wind(time 90) se fit命令后使用了egen sd_residuals = sd(_residuals)命令,结果每个公司所有日期后面的sd(_residuals)都是一样的值,见下面数据,请问老师是什么原因呢?
_residuals sd_residuals
.53588784 3.191237
.36001451 3.191237
.51752133 3.191237
.40787734 3.191237
-.07012066 3.191237
.14765539 3.191237
-.14690281 3.191237
.08603605 3.191237
.48559799 3.191237
.57112105 3.191237
.17930717 3.191237
.21237007 3.191237
.35595928 3.191237
.89296548 3.191237
.57422912 3.191237