全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Gauss专版
3207 7
2012-04-20
    在网上直接下载的源程序,不知道为什么我运行不了。gauss求助程序解释。另求该怎么修改可运行出结果?
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Decomposition of REAL GNP into random walk (stochastic trend) component
vs. stationary (cyclical) component
Model:
             y_t = y_{1t} + y_{2t}
  Trend:   y_{1t}=g_{t-1} + y_{1,t-1} + v_t,  v_t -- i.i.d. N(0,sigma_v^2)
                    g_t = g_{t-1} + w_t       w_t -- i.i.d. N(0,sigma_w^2)
  Cycle:   y_{2t}=phi_1* y_{2,t-1} + phi_2* y_{2,t-2} + u_t,
                                              u_t -- i.i.d. N(0,sigma_u^2)
cjkim@korea.ac.kr
WRITTEN BY C.J. KIM, DEPT. OF ECONOMICS, KOREA UNIVERSITY
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

new;
library  optmum, pgraph;——————这是什么意思啊
format /m1 /rd 9,6;
  load data[195,1]=gdp4795.prn;  @Real GDP 1947.1 - 1995.3; From CITIBASE@

yy= LN(data[1:195,1]);
t=rows(yy);


@ Maximum Likelihood Estimation @

START=21;  @1951.I @
prmtr_in={ 2  2  2  2  1 };
PRMTR_IN=PRMTR_IN';
                     @Initial values of the parameters @

{xout,fout,gout,cout}=optmum(&lik_fcn,PRMTR_IN);
                     @ prmtr estimates, -log lik value, Grandient, code@


prm_fnl=trans(xout);
"Calculating Hessian..... Please be patient!!!!";
                  hessn0=hessp(&lik_fcn,xout);
                  cov0=inv(hessn0);
grdn_fnl=gradfd(&TRANS,xout);
cov=grdn_fnl*cov0*grdn_fnl';
SD =sqrt(diag(cov)); @Standard errors of the estimated coefficients@

output file=clrk_uc1.out reset;
"==FINAL OUTPUT========================================================";
"initial values of prmtr is";
                 trans(prmtr_in)';
"==============================================================";
"likelihood value is ";; -fout;
"code";;cout;
"Estimated parameters are:";
prm_fnl';
XOUT';
"Standard errors of parameters are:"; sd';
OUTPUT OFF;
DATA = filter(xout);
output file=clrk_uc1.dta reset;
yy[start:t]~DATA;
output off;
XY(SEQA(1,1,ROWS(DATA)),YY[START:T,1]~DATA[.,1]);
XY(SEQA(1,1,ROWS(DATA)),DATA[.,2]~zeros(rows(data),1));
XY(SEQA(1,1,ROWS(DATA)),DATA[.,3]);

@ end OF MAIN PROGRAM @
@========================================================================@
@========================================================================@


proc LIK_FCN(PRMTR1);
     local SV,SE,F,H,Q,R,BETA_LL,P_LL,BETA_TL,P_TL,BETA_TT,P_TT,vt,ft, VAL,
     LIK_MAT,J_ITER, phi1,phi2,vecpll,prmtr,mu,SW;

     PRMTR=TRANS(PRMTR1);
LOCATE 20,1;  PRMTR';
     SV=PRMTR[1,1];  @s.e. of the random walk component@
     SE=PRMTR[2,1];  @s.e. of the AR component@
     SW=PRMTR[3,1];
     phi1=prmtr[4,1];
     phi2=prmtr[5,1];

      F=(1~0~0~1)|
        (0~phi1~phi2~0)|
        (0~1~0~0)|
        (0~0~0~1);

     H=1~1~0~0;
     Q= ZEROS(4,4);
     Q[1,1]=SV^2; Q[2,2]=SE^2;  Q[4,4]=SW^2;

     R= 0;

     BETA_LL=0|0|0|0;
     P_LL=EYE(4)*100;
     LIK_MAT=ZEROS(T,1);
J_ITER = 1;
do until J_ITER>T;
      BETA_TL = F * BETA_LL ;
      P_TL = F * P_LL * F' + Q;
      vt=yy[j_iter,1] - H * BETA_TL ; @prediction error@
      ft= H * P_TL * H' + R;       @variance of forecast error@

      BETA_TT= BETA_TL + P_TL * H' * inv(ft) * vt;
      P_TT= P_TL - P_TL * H' * inv(ft) * H * P_TL;
      LIK_MAT[J_ITER,1] =  -0.5*(LN(2*pi*ft) + vt^2/ft);
      BETA_LL=BETA_TT;
      P_LL=P_TT;

J_ITER = J_ITER+1;
endo;
VAL =-SUMC(LIK_MAT[START:T]);
LOCATE 2,20;  VAL;
retp(VAL);
endp;

@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>@
proc FILTER(PRMTR1);
     local SV,SE,F,H,Q,R,BETA_LL,P_LL,BETA_TL,P_TL,BETA_TT,P_TT,
     vt,ft, VAL, LIK_MAT,J_ITER,
     phi1,phi2,vecpll,prmtr,mu,SW,BETA_MAT;
     BETA_MAT=ZEROS(T,3);
     LIK_MAT=ZEROS(T,1);
     PRMTR=TRANS(PRMTR1);
LOCATE 20,1;  PRMTR';
     SV=PRMTR[1,1];  @s.e. of the random walk component@
     SE=PRMTR[2,1];  @s.e. of the AR component@
     SW=PRMTR[3,1];
     phi1=prmtr[4,1];
     phi2=prmtr[5,1];

      F=(1~0~0~1)|
        (0~phi1~phi2~0)|
        (0~1~0~0)|
        (0~0~0~1);

      H=1~1~0~0;
      Q= ZEROS(4,4);
              Q[1,1]=SV^2; Q[2,2]=SE^2;  Q[4,4]=SW^2;

      R= 0;
      BETA_LL=0|0|0|0;  @initial value            @
      P_LL=EYE(4)*100;
J_ITER = 1;
do until J_ITER>T;

      BETA_TL = F * BETA_LL ;
      P_TL = F * P_LL * F' + Q;
      vt=yy[j_iter,1] - H * BETA_TL ;
                  @prediction error@
      ft= H * P_TL * H' + R;       @variance of forecast error@

      BETA_TT= BETA_TL + P_TL * H' * inv(ft) * vt;
      P_TT= P_TL - P_TL * H' * inv(ft) * H * P_TL;

BETA_MAT[J_ITER,.]=BETA_TT[1,1]~BETA_TT[2,1]~BETA_TT[4,1];
      BETA_LL=BETA_TT;
      P_LL=P_TT;

J_ITER = J_ITER+1;
endo;

retp(BETA_MAT[START:T,.]);
endp;

@================================================================@
proc TRANS(c0); @ constraining values of reg. coeff.@
         local c1,d1,d2;
     c1=c0;
     c1[1:3,.]=exp(-1*c0[1:3,.])/10;
     d1=c0[4,1]./(1+abs(c0[4,1]));
     d2=c0[5,1]./(1+abs(c0[5,1]));
     c1[4,1]=d1+d2;
     c1[5,1]= -1* d1*d2 ;

retp(c1);
endp;



请大虾给看看,稍稍指点下,不胜感激。
二维码

扫码加我 拉你入群

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

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

全部回复
2012-4-20 18:59:46
另外运行结果是:
Line 19 in d:\我的文档\桌面\uc_uni.opt
   Library not found G0290 : 'D:\gauss10\optmum.lcg'
Undefined symbols:
    optmum                             d:\我的文档\桌面\uc_uni.opt(44)
    gradfd                             d:\我的文档\桌面\uc_uni.opt(56)
是不是因为我没有安装相应的软件包啊?还是由于其他的什么问题。
二维码

扫码加我 拉你入群

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

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

2012-4-21 14:56:24
少gauss模块3------optimal.rar,论坛内搜
二维码

扫码加我 拉你入群

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

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

2012-4-21 19:30:21
xuehe 发表于 2012-4-21 14:56
少gauss模块3------optimal.rar,论坛内搜
谢谢,可是下载了这儿模块后该安装呢?直接复制那三个文件夹到高斯根目录就可以了,覆盖原来的??我是真么做的,可是依然运行不出来,乱码就是
二维码

扫码加我 拉你入群

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

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

2012-4-21 20:00:31
wppwinterhappy 发表于 2012-4-21 19:30
谢谢,可是下载了这儿模块后该安装呢?直接复制那三个文件夹到高斯根目录就可以了,覆盖原来的??我是真 ...
还有就是程序的第三行,format/m1/rd 9,6;又是什么含义呢
二维码

扫码加我 拉你入群

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

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

2012-4-21 20:39:18

The  format comand sets the output format for matrices, string arrays, and strings  printed out with print. The format command is formatted as follows:

/mf options:
/m0                     print no delimiters before or after rows of a matrix
/m1 or /mb1,           print 1 or 2 carriage return/linefeeds (cr/lfs) before each row
/m2 or /mb2                     of a matrix with more than one row.
/m3 or /mb3        print "Row 1", "Row 2"... before each row of a matrix with
more than one row.
/ma1, /ma2              print 1 or 2 cr/lfs after each row of a matrix with more than
                        one row.
/b1, /b2                print 1 or 2 cr/lfs before each row of any matrix.
/b3                    print "Row1", "Row 2"... before each row of any matrix.
/a1, /a2                print 1 or 2 cr/lfs after each row of any matrix.
If nothing is specified  /m0 is assumed.

/jnt options:                These are important.
/rd     right-justified, [-]######.###.  prec = Number of digits after "."
/re     right-justified, [-]#.###E+-##.  prec = Number of digits after "."
/ro     /rd or /re format, depending on which is more compact. /re used only
if exponent is less than -4 or greater than precision.  If /re used, "." always appears.
/rz     same as /ro, except that if /re used, trailing zeros are suppressed,
                                                and "." appears only if digits follow it.
/ld, /le, /lo, /lz are like /rd, /re, /ro, /rz, but left-justified.
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群