搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  tradeweek.dta
资料下载链接地址: https://bbs.pinggu.org/a-1809034.html
附件大小:
19.94 MB   举报本内容
想计算两个股价崩盘风险指标。这样算的





我写的stata句子是这样的:
  1. clear
  2. use tradeweek

  3. /*对原始数据的一点处理*/
  4. gen week=substr(trdwnt,6,7)
  5. replace week="1" if strpos(trdwnt,"Jan")
  6. replace week="2" if strpos(trdwnt,"Feb")
  7. replace week="3" if strpos(trdwnt,"Mar")
  8. replace week="4" if strpos(trdwnt,"Apr")
  9. replace week="5" if strpos(trdwnt,"May")
  10. replace week="6" if strpos(trdwnt,"Jun")
  11. replace week="7" if strpos(trdwnt,"Jul")
  12. replace week="8" if strpos(trdwnt,"Aug")
  13. replace week="9" if strpos(trdwnt,"Sep")
  14. replace week="10" if strpos(trdwnt,"Oct")
  15. replace week="11" if strpos(trdwnt,"Nov")
  16. replace week="12" if strpos(trdwnt,"Dec")
  17. gen m_year=string(year)
  18. gen Yweek=m_year+week
  19. destring Yweek,replace force
  20. drop trdwnt id markettype m_year week

  21. /*计算周市场加权平均收益率*/
  22. bysort Yweek:egen p=pc(wsmvttl),prop
  23. bysort Yweek:egen rm=sum(wretnd*p)

  24. /*方程1的估计*/
  25. xtset stkcd Yweek
  26. reg wretnd l2.rm l.rm rm f.rm f2.rm

  27. predict e/*残差项与指标计算*/

  28. gen w=log(1+e)

  29. bysort stkcd year:egen n=count(year) /*全年交易周数*/

  30. /*指标2的计算*/
  31. bysort stkcd year:egen sum1=sum(w^3)
  32. bysort stkcd year:egen sum2=sum(w^2)
  33. gen n1=n*[(n-1)^(3/2)]
  34. gen n2=(n-1)*(n-2)
  35. gen n3=sum2^(3/2)
  36. gen nsckew=-(n1*sum1)/[n2*n3]


  37. duplicates drop
复制代码
算出来的东西乍一看没问题,可是到后面sort year stkcd以后就发现,同一年份下很多公司的指标值都是一样的。这不就是我算错了吗!可是我无法轻松的看出问题所在。
还请大家多多指教。

数据在此


感谢感谢


    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

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

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

GMT+8, 2025-12-27 01:17