楼主: Lee_iris
499 1

[回归分析求助] 计算因变量前后一期的和 stata代码 [推广有奖]

教授

36%

还不是VIP/贵宾

-

威望
0
论坛币
1628 个
通用积分
1141.1382
学术水平
36 点
热心指数
43 点
信用等级
35 点
经验
2682 点
帖子
878
精华
0
在线时间
1387 小时
注册时间
2019-3-5
最后登录
2024-5-26

楼主
Lee_iris 在职认证  学生认证  发表于 2022-10-21 14:33:54 |只看作者 |坛友微信交流群|倒序 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
数据是日度 city pair 层面,想要参考文献将因变量加总,相当于在每一条数据上都加上上一期和下一期的因变量值,参考文献的说法是𝑌𝑔𝑡 are three-day totals, beginning on day 𝑡 and including the following two days, 𝑡 + 1 and 𝑡 + 2.,文中的g是年龄的Group,参考文献见附件。

计算这个加总的因变量不能直接加总到三天后删除多余值,而是在在每一条数据上都加上上一期和下一期的因变量值,想到了两个代码,但算出来貌似都不太对

部分数据如下:
  1. [/size]
  2. [size=14px]* Example generated by -dataex-. To install: ssc install dataex[/size]
  3. [size=14px]clear[/size]
  4. [size=14px]input float city_pair long dataDate float rate[/size]
  5. [size=14px]200 20190103  .001170275[/size]
  6. [size=14px]200 20190111  .001170275[/size]
  7. [size=14px]200 20190124  .001170275[/size]
  8. [size=14px]200 20190127  .001170275[/size]
  9. [size=14px]200 20190207  .001170275[/size]
  10. [size=14px]200 20190211  .001170275[/size]
  11. [size=14px]200 20190221  .001170275[/size]
  12. [size=14px]200 20190225  .001170275[/size]
  13. [size=14px]200 20190321  .001170275[/size]
  14. [size=14px]200 20190324  .001170275[/size]
  15. [size=14px]200 20190329 .0005851375[/size]
  16. [size=14px]200 20190403  .001170275[/size]
  17. [size=14px]200 20190408  .001170275[/size]
  18. [size=14px]200 20190413  .001170275[/size]
  19. [size=14px]200 20190425  .001170275[/size]
  20. [size=14px]200 20190430  .001170275[/size]
  21. [size=14px]200 20190521    .0046811[/size]
  22. [size=14px]200 20190522  .001170275[/size]
  23. [size=14px]200 20190529  .001170275[/size]
  24. [size=14px]200 20190601  .001170275[/size]
  25. [size=14px]200 20190607  .001170275[/size]
  26. [size=14px]200 20190620 .0005851375[/size]
  27. [size=14px]200 20190621  .001170275[/size]
  28. [size=14px]200 20190714 .0029256875[/size]
  29. [size=14px]200 20190726 .0017554126[/size]
  30. [size=14px]200 20190727  .001170275[/size]
  31. [size=14px]200 20190802  .001170275[/size]
  32. [size=14px]200 20190803  .001170275[/size]
  33. [size=14px]200 20190804  .001170275[/size]
  34. [size=14px]200 20190808 .0005851375[/size]
  35. [size=14px]200 20190810 .0029256875[/size]
  36. [size=14px]200 20190812  .003510825[/size]
  37. [size=14px]200 20190814 .0005851375[/size]
  38. [size=14px]200 20190818 .0017554126[/size]
  39. [size=14px]200 20190819  .001170275[/size]
  40. [size=14px]200 20190821  .001170275[/size]
  41. [size=14px]200 20190827  .001170275[/size]
  42. [size=14px]200 20190831 .0005851375[/size]
  43. [size=14px]200 20190901 .0017554126[/size]
  44. [size=14px]200 20190902  .001170275[/size]
  45. [size=14px]200 20190903  .001170275[/size]
  46. [size=14px]200 20190905  .001170275[/size]
  47. [size=14px]200 20190906 .0017554126[/size]
  48. [size=14px]200 20190907   .00234055[/size]
  49. [size=14px]200 20190909  .001170275[/size]
  50. [size=14px]200 20190910  .001170275[/size]
  51. [size=14px]200 20190913 .0005851375[/size]
  52. [size=14px]200 20190914   .00234055[/size]
  53. [size=14px]200 20190916  .001170275[/size]
  54. [size=14px]200 20190918  .001170275[/size]
  55. [size=14px]200 20190920  .001170275[/size]
  56. [size=14px]200 20190922  .001170275[/size]
  57. [size=14px]200 20190923  .001170275[/size]
  58. [size=14px]200 20190925  .001170275[/size]
  59. [size=14px]200 20190927  .001170275[/size]
  60. [size=14px]200 20191003  .001170275[/size]
  61. [size=14px]200 20191005  .001170275[/size]
  62. [size=14px]200 20191006  .001170275[/size]
  63. [size=14px]200 20191008 .0005851375[/size]
  64. [size=14px]200 20191009  .001170275[/size]
  65. [size=14px]200 20191011  .001170275[/size]
  66. [size=14px]200 20191012  .001170275[/size]
  67. [size=14px]200 20191016 .0005851375[/size]
  68. [size=14px]200 20191018  .001170275[/size]
  69. [size=14px]200 20191020  .001170275[/size]
  70. [size=14px]200 20191021  .001170275[/size]
  71. [size=14px]200 20191029  .001170275[/size]
  72. [size=14px]200 20191031  .001170275[/size]
  73. [size=14px]200 20191102   .00234055[/size]
  74. [size=14px]200 20191103   .00234055[/size]
  75. [size=14px]200 20191105  .001170275[/size]
  76. [size=14px]200 20191106 .0005851375[/size]
  77. [size=14px]200 20191107  .001170275[/size]
  78. [size=14px]200 20191108  .001170275[/size]
  79. [size=14px]200 20191109   .00234055[/size]
  80. [size=14px]200 20191110   .00234055[/size]
  81. [size=14px]200 20191111   .00234055[/size]
  82. [size=14px]200 20191113   .00234055[/size]
  83. [size=14px]200 20191115  .001170275[/size]
  84. [size=14px]200 20191118 .0005851375[/size]
  85. [size=14px]200 20191119  .001170275[/size]
  86. [size=14px]200 20191121 .0005851375[/size]
  87. [size=14px]200 20191128 .0005851375[/size]
  88. [size=14px]200 20191204  .001170275[/size]
  89. [size=14px]200 20191205 .0017554126[/size]
  90. [size=14px]200 20191206 .0005851375[/size]
  91. [size=14px]200 20191210 .0005851375[/size]
  92. [size=14px]200 20191212 .0005851375[/size]
  93. [size=14px]200 20191215 .0017554126[/size]
  94. [size=14px]200 20191220  .001170275[/size]
  95. [size=14px]200 20191226 .0017554126[/size]
  96. [size=14px]200 20191228  .001170275[/size]
  97. [size=14px]200 20191230  .001170275[/size]
  98. [size=14px]end[/size]
  99. [size=14px]
复制代码



[code]
        sort city_pair date
        drop group*
        gen group3_1=sum(rate[_n] + rate[_n+1] + rate[_n-1] )
        gen group3_2=sum(rate[_n] + l.rate + f.rate)
        sum group3*
        list city_pair date rate group*        if city_pair==200

[\code]


二维码

扫码加我 拉你入群

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

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

关键词:Stata tata 因变量 including generated

沙发
黃河泉 在职认证  发表于 2022-10-21 15:36:33 |只看作者 |坛友微信交流群
你的本文与 dataex 的资料都有一些乱码,无法看清楚你的问题,资料也无法使用,请重发问题与资料。

使用道具

藤椅
Lee_iris 在职认证  学生认证  发表于 2022-10-21 16:31:51 |只看作者 |坛友微信交流群
黃河泉 发表于 2022-10-21 15:36
你的本文与 dataex 的资料都有一些乱码,无法看清楚你的问题,资料也无法使用,请重发问题与资料。
谢谢!发现了问题,代码应为:

  1.         bys city_pair: gen group3=rate[_n] + rate[_n+1] + rate[_n-1] // 因变量三天加总
复制代码

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-28 18:39