楼主: 3qsir
1687 1

[问答] About EViews : How to store the rolling estimates coefficient by martix [推广有奖]

  • 2关注
  • 1粉丝

副教授

52%

还不是VIP/贵宾

-

威望
0
论坛币
13606 个
通用积分
3.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
71839 点
帖子
368
精华
0
在线时间
931 小时
注册时间
2011-5-18
最后登录
2021-3-6

5论坛币

Sir : Can you teach me how to store rolling estimates coefficient using matix ?

The code  copy from the Eview8 's sample programs (rollfcst1.prg), I wrote some lines myself (marked on red) on the original codes.I want to store all beta cofficient(coeff1     coeff2     coeff3 ) and statistics(coeff4     coeff5     coeff6) on every one looping, from  OLS estimate procedure, I hope result like below table:

nroll     coeff1     coeff2     coeff3     coeff4     coeff5     coeff6

1            -13.5         8.6           4.3          -1.65       1.96       2.54   

2             -3.6           7.2           2.1         - 3.01     2.04       1.89

3               .                 .                .                .            .                .

4

' create workfile

wfcreate rollfcst q 1968 1982

' fill data

series y

y.fill3.733,3.567,3.533,3.400,3.400,3.433,3.576,3.567,4.167,4.733,5.167,5.867,5.900,5.900,6.033,5.967,5.767,5.633,5.600,5.333,4.933,4.867,4.833,4.800,5.033,5.133,5.633,6.667,8.133,8.767,8.600,8.433,7.633,7.467,7.833,7.900,7.467,7.100,6.900,6.633,6.200,6.000,5.967,5.833,5.733,5.767,5.800,5.867,6.133,7.500,7.633,7.500,7.333,7.400,7.333,8.367,8.767,9.367,9.500,10.53

' set window size

!window = 20

' get size of workfile

!length = @obsrange

' declare equation for estimation

equation eq1

' declare series for final results

series yhat                       'point estimates

series yhat_se         ' forecast std.err.

' set step size

!step = 4

'calculate number of rolls

!nrolls = @floor((!length-!window)/!step)

'matrix to store coefficient estimates

matrix(!nrolls ,3) coeff  ' where 3 is the number of coefficients

' move sample !step obs at a time

for !i = 1 to  !length-!window+1-!step step!step

        'set sample to estimation period

        smpl@first+!i-1 @first+!i+!window-2

        'estimate equation

        eq1.lsy c y(-1) y(-2)

coeff(!i,1)= eq1.@coef(1)

coeff(!i,2)=eq1.@coef(2)

coeff(!i,3)=eq1.@coef(3)

coeff(!i,4)=eq1.@coef(4)

coeff(!i,5)=eq1.@coef(5)

coeff(!i,6)=eq1.@coef(6)

        'reset sample to forecast period

        smpl@first+!i+!window-1 @first+!i+!window-2+!step

        'make forecasts in temporary series first

        eq1.forecast(f=na)tmp_yhat tmp_se

        'copy data in current forecast sample

        yhat= tmp_yhat

        yhat_se= tmp_se

next

THS !

关键词:coefficient EFFICIENT Estimates estimate rolling create original programs store
右键Save或 Save as

使用道具

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

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

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

GMT+8, 2024-11-6 03:40