求助各位高手帮我改一下这个编程,怎么也运行不了,蓝色标记处老是报错,马上就要交作业了,悲催啊……不懂编程的真伤心,谢谢各位啦
smpl @all
ls s c f
series ecm=resid
series y1 = d(s)
series y2 = d(f)
' set sample
' first observation of s1 need to be one or two periods after
' the first observation of s0
sample s0 2 225
sample s1 4 225
' initialization of parameters and starting values
' change below only to change the specification of model
smpl s0
'get starting values from univariate GARCH
equation eq1.arch(m=100,c=1e-5) y1 c ecm(-1)
equation eq2.arch(m=100,c=1e-5) y2 c ecm(-1)
' declare coef vectors to use in bi-variate GARCH model
' see above for details
coef(2) mu
mu(1) = eq1.c(1)
mu(2) = eq2.c(1)
coef(3) omega
omega(1)=(eq1.c(2))^.5
omega(2)=0
omega(3)=eq2.c(2)^.5
coef(2) alpha
alpha(1) = (eq1.c(3))^.5
alpha(2) = (eq2.c(3))^.5
coef(2) beta
beta(1)= (eq1.c(4))^.5
beta(2)= (eq2.c(4))^.5
' constant adjustment for log likelihood
!mlog2pi = 2*log(
2*@acos(-1))
series yy2=y2-mu(2)-eq2.c(2)*ecm(-1)-eq2.c(3)*y1(-1)
series yy1=y1-mu(1)-eq1.c(2)*ecm(-1)-eq1.c(3)*y2(-1)
series
cov_y1y2=@cov(yy1,yy2)
series var_y1 = @var(y1)
series var_y2 = @var(y2)
series sqres1 = (yy1)^2
series sqres2 = (yy2)^2
series res1res2 = (yy1)*(yy2)
' ...........................................................
' LOG LIKELIHOOD
' set up the likelihood
' 1) open a new blank likelihood object (L.O.) name bvgarch
' 2) specify the log likelihood model by append
' ...........................................................
logl bvgarch
bvgarch.append @logl logl
bvgarch.append sqres1 = (yy1)^2
bvgarch.append sqres2 = (yy2)^2
bvgarch.append res1res2 = (yy1)*(yy2)
' calculate the variance and covariance series
bvgarch.append var_y1 = omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)
bvgarch.append var_y2 = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)
bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)
' determinant of the variance-covariance matrix
bvgarch.append deth = var_y1*var_y2 - cov_y1y2^2
' inverse elements of the variance-covariance matrix
bvgarch.append invh1 = var_y2/deth
bvgarch.append invh3 = var_y1/deth
bvgarch.append invh2 = -cov_y1y2/deth
' log-likelihood series
bvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth))
' remove some of the intermediary series
' bvgarch.append @temp invh1 invh2 invh3 sqres1 sqres2 res1res2 deth
' estimate the model
smpl s1
bvgarch.ml(showopts, m=100, c=1e-5)
' change below to display different output
show bvgarch.output
series h=cov_y1y2/var_y2
series dd=@ var(d(sp))
series sd=@ stdev (d(sp)/sp)
series sdbv=@ stdev(d(sp)-h*d(fp)/(sp-h*fp))
show varcov