I basically modified VEGARCH.RPF and thought based on the following from VEGARCH.RPF and previous posts in this thread that the message on nonconvergence is just a warning.
* indicate that. If you have RATS 8.1 or later, you can activate the
* next instruction to get cleaner output. (It forces more accurate, but
I have to think about the zero contemporaneous correlation.
I ran the programs separately, once with two exogenous regressors, the second time with just one, and cleared the memory before each run. Here is the code with the two exogenous regressors ind1 and ind2. For the code with just 1 exogenous regressor, I dropped ind2 and its coefficient and retained ind1 and its coefficient in all relevant places.
Code: Select all
set dlogp = log(price/price{1})*100.0
set dlogp2 = log(ADMD/ADMD{1})*100.0
compute n=2
*
* Define the return series
*
dec vect[series] y1(n)
set y1(1) = dlogp
set y1(2) = dlogp2
dec vect[series] s(n)
set s(1) = ind1
set s(2) = ind2
dec vect[series] db1(7)
dec vect[series] db2(17)
*set dummy variables for breakpoints
do j=1,7
set db1(j) = 0.0
end do j
do j=1,17
set db2(j) = 0.0
end do j
set db1(1) = %if(t>100.and.t<126, 1, 0)
set db1(2) = %if(t>125.and.t<444, 1, 0)
set db1(3) = %if(t>443.and.t<714, 1, 0)
set db1(4) = %if(t>713.and.t<990, 1, 0)
set db1(5) = %if(t>989.and.t<1021, 1, 0)
set db1(6) = %if(t>1020.and.t<1153, 1, 0)
set db1(7) = %if(t>1152.and.t<1218, 1, 0)
set db2(1) = %if(t>69.and.t<113, 1, 0)
set db2(2) = %if(t>112.and.t<172, 1, 0)
set db2(3) = %if(t>171.and.t<276, 1, 0)
set db2(4) = %if(t>275.and.t<312, 1, 0)
set db2(5) = %if(t>311.and.t<367, 1, 0)
set db2(6) = %if(t>366.and.t<510, 1, 0)
set db2(7) = %if(t>509.and.t<543, 1, 0)
set db2(8) = %if(t>542.and.t<637, 1, 0)
set db2(9) = %if(t>636.and.t<814, 1, 0)
set db2(10) = %if(t>813.and.t<855, 1, 0)
set db2(11) = %if(t>854.and.t<884, 1, 0)
set db2(12) = %if(t>883.and.t<910, 1, 0)
set db2(13) = %if(t>909.and.t<936, 1, 0)
set db2(14) = %if(t>935.and.t<959, 1, 0)
set db2(15) = %if(t>958.and.t<992, 1, 0)
set db2(16) = %if(t>991.and.t<1110, 1, 0)
set db2(17) = %if(t>1109.and.t<1218, 1, 0)
inquire(reglist) gstart gend
# dlogp dlogp2 ind1 ind2
display gstart gend
*
* This is the period of estimation, allowing for the lost data point for
* converting to returns, and the loss for the lags in the VAR.
*
compute gstart=3
*
* Table 1
*
dec vect[labels] vl(2)
compute vl=||"dlogp","dlogp2"||
report(action=define,title="Preliminary Statistics")
report(atrow=1,atcol=1,fillby=cols) "Statistics" "$\mu$" "$\sigma$" "S" "K" "D" $
"$LB(12) for R_t" "$LB(12) for R_t^2$"
do i=1,n
stats(noprint) y1(i) gstart gend
report(atrow=1,atcol=i+1,fillby=cols) vl(i) %mean sqrt(%variance) %skewness %kurtosis
@adtest(noprint) y1(i) gstart gend
report(atrow=6,atcol=i+1) %cdstat
corr(noprint,number=12,qstats) y1(i) gstart gend
report(atrow=7,atcol=i+1) %qstat
@mcleodli(noprint,number=12) y1(i) gstart gend
report(atrow=8,atcol=i+1) %cdstat
end do i
report(action=format,picture="*.####")
report(action=show)
*
* Template for mean equation. This is a VAR(1)
*
equation meaneq *
# constant y1(1){1} y1(2){1}
*
dec vect[series] u(n) ;* Residuals
dec vect[frml] mean(n) ;* Model for mean
dec vect[frml] z(n) ;* EGARCH indexes
dec series[vect] hhd ;* Variances
dec series[symm] hh ;* Full covariance matrices
*
* Coefficient vectors for the VAR (b)
*
dec vect[vect] beta(n)
nonlin(parmset=meanparms) beta
*
* The variance for equation i takes the form:
*
* log h(i) = c(i) + sum_j a(i)(j) z(j){1} + g(i) log h(i){-1} + d2 + cad(i) ind1{1} + cex(i) ind2{1}
*
* z(i) = abs(u(i)/sqrt(h(i))) - sqrt(2/pi) + d1(i)*u(i)/sqrt(h(i))
*
dec vect c(n) ;* Variance intercepts in EGARCH
dec vect g(n) ;* Lagged variance coefficients in EGARCH
dec vect d1(n) ;* Asymmetry coefficients in EGARCH
dec vect[vect] a(n) ;* Lagged z terms in EGARCH
dec vect cad(n) ;* Coefficients of ind1 in vol equation
dec vect cex(n) ;* Coefficients of ind2 in vol equation
dec vec ddb1(7)
dec vec ddb2(17)
nonlin(parmset=garchparms) c g a d1 cad cex ddb1 ddb2
*
* Set up the formulas for the mean and for calculating the "z". The z(i)
* FRML uses &i for all references to i, so they are resolved now as the
* formulas are being defined.
*
do i=1,n
frml(equation=meaneq,vector=beta(i)) mean(i)
frml z(i) = abs(u(&i){0})/sqrt(hhd{0}(&i))-sqrt(2/%pi)+$
d1(&i)*u(&i){0}/sqrt(hhd{0}(&i))
end do i
*
* Subdiagonal for correlation matrix. This is how CC models are handled.
*
dec packed rr(n-1,n-1)
nonlin(parmset=ccparms) rr
*
* Do calculations at time <<t>> for the residuals (u), variances (v) and
* full covariance matrix (return value for function).
*
function EGARCHSpillover t
type symmetric EGARCHSpillover
type integer t
*
local integer i j
local real hlog
dim EGARCHSpillover(n,n)
*
do i=1,n
compute hlog=c(i)+g(i)*log(hhd(t-1)(i))+cad(i)*ind1(t-1)+cex(i)*ind2(t-1)
do j=1,n
compute hlog=hlog+a(i)(j)*z(j)(t-1)
if j==1
do k1=1,7
compute hlog=hlog+ddb1(k1)*db1(k1) (t-1)
end do k1
else if j==2
do k2=1,17
compute hlog=hlog+ddb2(k2)*db2(k2) (t-1)
end do k2
end do j
compute hhd(t)(i) = exp(hlog)
end do i
ewise EGARCHSpillover(i,j)=$
%if(i==j,hhd(t)(i),rr(i-1,j)*sqrt(hhd(t)(i)*hhd(t)(j)))
compute hh(t)=EGARCHSpillover
do i=1,n
compute u(i)(t) = y1(i)(t)-mean(i)(t)
end do i
end EGARCHSpillover
*
* Log likelihood
*
frml logl = hh(t)=EGARCHSpillover(t),%logdensity(hh(t),%xt(u,t))
*
* Initial guess values from running regressions. The b's are the OLS
* estimates, a's, g's and d's are (except for the constant) standard
* guess values.
*
do i=1,n
linreg(equation=meaneq,noprint) y1(i) gstart gend
set u(i) = %if(%valid(%resids),%resids,0.0)
compute beta(i) = %beta
compute c(i) = log(%seesq)*(1-.80)
compute g(i) =.80
compute a(i) = %unitv(n,i)*.25
compute d1(i) =0.0
compute cad(i) =0.0
compute cex(i) =0.0
end do i
do i2=1,7
compute ddb1(i2)=0.0
end do i2
do i3=1,17
compute ddb2(i3)=0.0
end do i3
*
vcv gstart gend
# u
gset hhd = %xdiag(%sigma)
gset hh = %sigma
ewise rr(i,j)=%cvtocorr(%sigma)(i+1,j)
*
* The model actually converges properly, though the diagnostics don't
* indicate that. If you have RATS 8.1 or later, you can activate the
* next instruction to get cleaner output. (It forces more accurate, but
* slower numerical derivatives).
*
*nlpar(derives=second)
*
maximize(parmset=meanparms+garchparms+ccparms,$
pmethod=simplex,piters=10,method=bfgs,iters=500) logl gstart gend
*
* Diagnostics
*
dec vect[series] ustd(n)
*
report(action=define)
report(atrow=2,atcol=1,fillby=cols) "$E(z_{i,t})$" "$E(z^2_{i,t})$" "$LB(12);z_{i,t}$" "$LB(12);z^2_{i,t}$"
do i=1,n
report(atrow=1,atcol=i+1,align=center) vl(i)
set ustd(i) %regstart() %regend() = u(i)/sqrt(hh(t)(i,i))
set ustdsq = ustd(i)^2
sstats(mean) %regstart() %regend() ustd(i)>>eustd ustdsq>>eustdsq
report(atrow=2,atcol=i+1,fillby=cols) eustd eustdsq
corr(number=12,qstats,noprint) ustd(i)
report(atrow=4,atcol=i+1,special=1+fix(%qsignif<.05)) %qstat
corr(number=12,qstats,noprint) ustdsq
report(atrow=5,atcol=i+1,special=1+fix(%qsignif<.05)) %qstat
end do i
report(action=format,atrow=2,atcol=2,picture="*.####",align=decimal)
report(action=show)
*