what i'm trying to do is to forecast GBP's volatility dynamicly, the estimation window is 500, and rolling forward daily, until the full sample is reached.
but when i run the code, it writes:
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
The Error Occurred At Location 1509, Line 44 of loop/block
could someone help? many thanks here is my code:
Code: Select all
all 3908
open data o:\GBP.xlsx
data(format=xlsx,org=obs) /
close data
set ph / = log(hi)
set pl / = log(lo)
set r / = (((ph-pl)**2.0)/(4*log(2)))**0.5
dofor tau2 = 1 5 20 60 120 240
comp step =fix(%IF(tau2>20,20,tau2))
comp tau1=fix(%max(1,tau2-19))
comp k=0
do i=500,3908-tau2, step
comp k=k+1
linreg(noprint) r i-499 i
#r{1 to 3}
frml(lastreg,vector=mu) meanf
compute omega=log(%seesq),delta=0.0
nonlin(parmset=meanparms) mu
clear u h
compute gstart=%regstart(),gend=%regend()
nonlin(parmset=garchparms) omega delta
frml varf = omega+log(1+delta*gap)
frml logl = u=r-meanf,h=exp(varf),%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl gstart gend
compute omega0=omega
nonlin(parmset=garchparms) omega delta psi1 phi1 phi2 theta gamma
compute psi1=-.8,phi1=1.0,phi2=0.0,theta=-.1,gamma=.2
compute uupresample=exp(omega0)
set uuadj = uupresample
set h = uupresample
set x = 0.0
set ax = 0.0
frml varf = omega+(1-phi1)*(1-phi2)*omega+$
log(1+delta*gap)-(phi1+phi2)*log(1+delta*gap{1})+phi1*phi2*log(1+delta*gap{2})+$
(phi1+phi2)*log(h{1})-phi1*phi2*log(h{2})+$
theta*(x{1}+psi1*x{2})+gamma*(ax{1}+psi1*ax{2})
frml logl = u=r-meanf,h=exp(varf),x=u/sqrt(h),ax=abs(x)-sqrt(2.0/%pi),%logdensity(h,u)
maximize(parmset=meanparms+garchparms,trace,iters=500) logl gstart gend
do j = tau1,tau2
set ract j j = r(i+j)
set rfor j j = exp(u+h+x+ax+%logdensity(h,u))
end do j
stat(noprint) ract tau1 tau2
set ractbar k k = %mean
stat(noprint) rfor tau1 tau2
set rforbar k k = %mean
end do i
linreg(noprint) ractbar 1 k
#constant rforbar
comp a=%beta(1);comp as=%stderrs(1)
comp b=%beta(2);comp bs=%stderrs(2)
comp rsq=%rsquared
test(noprint)
# 1 2
# 0.0 1.0
comp fstat=%cdstat
set error2 1 k = (ractbar-rforbar)**2.0
stat(noprint) error2 1 k
comp mse=(%mean*k/(k-1))**0.5
disp tau1 tau2 mse 100*a 100*as b bs rsq fstat
end dofor tau2