epoh 发表于 2011-10-15 22:28
你那已经是旧版的了现在winrats 8.0已改用garchmv.rpf第一个series garch(1,1) Mean(1) C(1) A(1) B(1) ...
epoh老师,您好!
garchmv.rpf这个文件能在winrats7.0上运行吗?
与7.0的以下程序有什么区别?
GARCHMV.PRG
* Manual Example 12.2
*
open data g10xrate.xls
data(format=xls,org=columns) 1 6237 usxjpn usxfra usxsui
*
set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})
*
garch(p=1,q=1,iters=200,hmatrices=hh) / xjpn xfra xsui
garch(p=1,q=1,mv=bek,method=bfgs,iters=200,pmethod=simplex,piters=10) / xjpn xfra xsui
garch(p=1,q=1,mv=diag,hmatrices=hd,rvectors=rd) / xjpn xfra xsui
garch(p=1,q=1,mv=cc) / xjpn xfra xsui
garch(p=1,q=1,mv=dcc,method=bfgs) / xjpn xfra xsui
*
* Compute the covariance matrix of the standardized residuals from
* the diagonal GARCH
*
set z1 = rd(t)(1)/sqrt(hd(t)(1,1))
set z2 = rd(t)(2)/sqrt(hd(t)(2,2))
set z3 = rd(t)(3)/sqrt(hd(t)(3,3))
vcv(matrix=cc)
# z1 z2 z3
*
* Compute the correlations from the multivariate GARCH
*
set rho12 = hh(t)(1,2)/sqrt(hh(t)(1,1)*hh(t)(2,2))
set rho13 = hh(t)(1,3)/sqrt(hh(t)(1,1)*hh(t)(3,3))
set rho23 = hh(t)(2,3)/sqrt(hh(t)(2,2)*hh(t)(3,3))
graph(header="Correlation of JPN with FRA",vgrid=||cc(1,2)||)
# rho12
graph(header="Correlation of JPN with SUI",vgrid=||cc(1,3)||)
# rho13
graph(header="Correlation of FRA with SUI",vgrid=||cc(2,3)||)
# rho23
*
* AR(1) models for each
*
equation(constant) jpneq xjpn 1
equation(constant) fraeq xfra 1
equation(constant) suieq xsui 1
group ar1 jpneq fraeq suieq
garch(p=1,q=1,model=ar1,mv=dcc,pmethod=simplex,piter=20,method=bfgs,iters=200,trace) / xjpn xfra xsui
*
* Compute correlations into the forecast period, and graph them along with some of the final
* values from the actual sample. The GRID option puts a vertical line at the separation
* between actual data and forecasts.
*
garch(p=1,q=1,iters=200,hmatrices=hh,rvectors=us) / xjpn xfra xsui
@MVGarchFore(steps=100) hh us
set rho12 6238 6337 = hh(t)(1,2)/sqrt(hh(t)(1,1)*hh(t)(2,2))
set rho13 6238 6337 = hh(t)(1,3)/sqrt(hh(t)(1,1)*hh(t)(3,3))
set rho23 6238 6337 = hh(t)(2,3)/sqrt(hh(t)(2,2)*hh(t)(3,3))
graph(header="Correlation of JPN with FRA",vgrid=||cc(1,2)||,grid=(t==6237))
# rho12 6100 6337
graph(header="Correlation of JPN with SUI",vgrid=||cc(1,3)||,grid=(t==6237))
# rho13 6100 6337
graph(header="Correlation of FRA with SUI",vgrid=||cc(2,3)||,grid=(t==6237))
# rho23 6100 6337
*
* Estimation using MAXIMIZE
* The initial few lines of this set the estimation range, which needs to be done explicitly,
* and the number of variables. Then, vectors for the dependent variables, residuals and
* residuals formulas are set up. The SET instructions copy the dependent variables over into
* the slots in the vector of series.
*
compute gstart=2,gend=6237
compute n=3
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = xjpn
set y(2) = xfra
set y(3) = xsui
*
* This is specific to a mean-only model. It sets up the formulas (the &i are needed in the
* formula definitions when the FRML is defined in a loop), and estimates them using NLSYSTEM.
* This both initializes the mean parameters, and computes the unconditional covariance matrix.
* If you want more general mean equations, the simplest way to do that would be to define each
* FRML separately.
*
dec vect b(n)
nonlin(parmset=meanparms) b
do i=1,n
frml resid(i) = (y(&i)-b(&i))
end do i
nlsystem(parmset=meanparms,resids=u) gstart gend resid
compute rr=%sigma
*
* The paths of the covariance matrices and uu' are saved in the SERIES[SYMM] names H and UU.
* UX and HX are used to pull in residuals and H matrices.
*
declare series[symm] h uu
*
* ux is used when extracting a u vector
*
declare symm hx(n,n)
declare vect ux(n)
*
* These are used to initialize pre-sample variances.
*
gset h * gend = rr
gset uu * gend = rr
*
* This is a standard (normal) log likelihood formula for any multivariate GARCH model.
* The difference among these will be in the definitions of HF and RESID. The function
* %XT pulls information out of a matrix of SERIES.
*
declare frml[symm] hf
*
frml logl = $
hx = hf(t) , $
%do(i,1,n,u(i)=resid(i)) , $
ux = %xt(u,t), $
h(t)=hx, uu(t)=%outerxx(ux), $
%logdensity(hx,ux)
*****************************************************
*
* Standard GARCH(1,1)
*
dec symm vcs(n,n) vas(n,n) vbs(n,n)
compute vcs=rr,vbs=%const(0.05),vas=%const(0.05)
nonlin(parmset=garchparms) vcs vas vbs
frml hf = vcs+vbs.*h{1}+vas.*uu{1}
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs,iters=400) logl gstart gend
*****************************************************
*
* CCC
* The correlations are parameterized using an (n-1)x(n-1) matrix for
* the subdiagonal. The (i,j) element of this will actually be the
* correlation between i+1 and j.
*
dec symm qc(n-1,n-1)
dec vect vcv(n) vbv(n) vav(n)
*
function hfcccgarch time
type symm hfcccgarch
type integer time
do i=1,n
compute hx(i,i)=vcv(i)+vav(i)*h(time-1)(i,i)+vbv(i)*uu(time-1)(i,i)
do j=1,i-1
compute hx(i,j)=qc(i-1,j)*sqrt(hx(j,j)*hx(i,i))
end do j
end do i
compute hfcccgarch=hx
end
*
frml hf = hfcccgarch(t)
nonlin(parmset=garchparms) vcv vbv vav qc
compute vcv=%xdiag(rr),vbv=%const(0.05),vav=%const(0.05),qc=%const(0.0)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs) logl gstart gend
GARCH Model - Estimation by BFGS
Convergence in 60 Iterations. Final criterion was 0.0000000 <= 0.0000100
Usable Observations 6236
Log Likelihood -11835.65541089
Variable Coeff Std Error T-Stat Signif
*******************************************************************************
1. Mean(1) 0.004649082 0.006576630 0.70691 0.47962269
2. Mean(2) -0.003482788 0.006942195 -0.50168 0.61588981
3. Mean(3) -0.002343658 0.008167577 -0.28695 0.77415329
4. C(1,1) 0.009018787 0.001134922 7.94661 0.00000000
5. C(2,1) 0.005698447 0.000749274 7.60530 0.00000000
6. C(2,2) 0.011514300 0.001467482 7.84630 0.00000000
7. C(3,1) 0.006014742 0.000786802 7.64454 0.00000000
8. C(3,2) 0.009941049 0.001281123 7.75964 0.00000000
9. C(3,3) 0.012776962 0.001603110 7.97011 0.00000000
10. A(1,1) 0.105858581 0.007515938 14.08455 0.00000000
11. A(2,1) 0.093978611 0.006049520 15.53489 0.00000000
12. A(2,2) 0.128210057 0.006786935 18.89072 0.00000000
13. A(3,1) 0.088845884 0.005500928 16.15107 0.00000000
14. A(3,2) 0.113667210 0.005960698 19.06945 0.00000000
15. A(3,3) 0.111557248 0.006229681 17.90738 0.00000000
16. B(1,1) 0.883925113 0.007977380 110.80394 0.00000000
17. B(2,1) 0.890949460 0.006338829 140.55426 0.00000000
18. B(2,2) 0.860817189 0.007062831 121.87990 0.00000000
19. B(3,1) 0.897615376 0.005766485 155.66075 0.00000000
20. B(3,2) 0.874823517 0.006191925 141.28459 0.00000000
21. B(3,3) 0.877439677 0.006275555 139.81866 0.00000000
MV-GARCH, BEKK - Estimation by BFGS
Convergence in 95 Iterations. Final criterion was 0.0000068 <= 0.0000100
Usable Observations 6236
Log Likelihood -11821.74555534
Variable Coeff Std Error T-Stat Signif
*******************************************************************************
1. Mean(1) 0.005278552 0.006003487 0.87925 0.37926700
2. Mean(2) -0.002367253 0.005423869 -0.43645 0.66250955
3. Mean(3) -0.002512941 0.006388059 -0.39338 0.69403817
4. C(1,1) 0.082829938 0.005052362 16.39430 0.00000000
5. C(2,1)