楼主: 夏目贵志
1900 3

[程序分享] Pesaran and Shin Generalized IRF程序 [推广有奖]

贵宾

学科带头人

96%

还不是VIP/贵宾

-

威望
1
论坛币
238580 个
通用积分
17198.0688
学术水平
851 点
热心指数
971 点
信用等级
711 点
经验
759262 点
帖子
4029
精华
1
在线时间
793 小时
注册时间
2012-7-15
最后登录
2017-9-16

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
之前问过关于这个东西的问题。statalist上的那个解答是错的。见https://bbs.pinggu.org/thread-2515395-1-1.html
昨晚好好做了一下。其实挺简单的。没有写一个完整的程序,只是把计算过程做出来了。供大家参考。
对于一个有5个变量的VAR(1)来说,可以是这样的:(注意需要让当前的估计是这个VAR)
  1. /* obtain estimated coefficients and vce matrix */
  2. mata
  3. b=rowshape(st_matrix("e(b)"),5)
  4. s=st_matrix("e(Sigma)")
  5. m0=I(5,5)
  6. end

  7. /* calculate all the M matrix */
  8. forvalues i = 1/24 {
  9.     local ii = `i'-1
  10.     /* for higher order var this needs to be changed */
  11.     mata: m`i' = b*m`ii'
  12. }

  13. /* generalized impulse response */
  14. mata: e=I(5,5)
  15. /* period 1 */
  16. forvalues i = 1/5 {
  17.     mata: phi`i' = s[`i',`i']^(-1/2)*m0*s*e[.,`i']
  18. }   
  19. /* other periods */
  20. forvalues t = 1/24 {
  21.     forvalues i = 1/5 {
  22.         mata: tmp = s[`i',`i']^(-1/2)*m`t'*s*e[.,`i']
  23.         mata: phi`i' = (phi`i',tmp)
  24.     }
  25. }
  26. forvalues i = 1/5 {
  27.     mata: phi`i' = phi`i''
  28. }   
复制代码

我已经验证过,当估计VAR时使用dfk选项时,这个和EViews的GIRF做出的结果是完全一样的。

二维码

扫码加我 拉你入群

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

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

关键词:Generalized Generalize General Pesaran Shin 程序

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
h3327156 + 5 + 5 + 5 I really appreciate it. Nice going!

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

沙发
夏目贵志 发表于 2013-7-9 19:17:57 |只看作者 |坛友微信交流群
另外,谁能顺便告诉我macro (global and local)能在mata里用吗?

使用道具

藤椅
h3327156 发表于 2013-7-9 20:12:29 |只看作者 |坛友微信交流群
夏目贵志 发表于 2013-7-9 19:17
另外,谁能顺便告诉我macro (global and local)能在mata里用吗?
William Gould 在他的paper里有几段说到:

"The first rule for programming in Mata is to forget that macros even exist. Macros
are not necessary and, in fact, all your ado-file instincts will mislead you. Everything
macros do for you in ado-files is performed in Mata by Mata variables.
........
Mata does not need macros, but that does not mean you cannot work with macros in
Mata. Macros are such an important part of Stata that you will sometimes want to
access a macro’s contents or change those contents.
........."

简言之,按理mata不须要macro,
但如果您真的手痒,好吧!

help st_local
help st_global

参考就好,我mata不熟的。

使用道具

板凳
夏目贵志 发表于 2013-7-9 20:27:36 |只看作者 |坛友微信交流群
h3327156 发表于 2013-7-9 20:12
William Gould 在他的paper里有几段说到:

"The first rule for programming in Mata is to forget th ...
非常感谢!我可以想象比如说,用像是matlab里的multidimensional array之类的东西来代替macro用来给矩阵命名什么的,不过我最喜欢stata的地方就是macro的存在。

使用道具

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

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

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

GMT+8, 2024-5-13 05:00