Average forecast value

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
likykiki
Posts: 11
Joined: Mon Aug 12, 2013 11:42 am

Average forecast value

Unread post by likykiki »

Hi, I write some code to do EGARCH forecast model of Brandt and Jones(2006), use a rolling window of 500 observations and move forward daily.
but i met some problem when given value to hbar below,

Code: Select all

set lh / = log(hi)
set ll / = log(lo)
set r  / = (((lh-ll)**2.0)/(4*log(2)))**0.5

SET Range = log(LH - LL)
SET Ret = LOG(C/C{1})
linreg(NOPRINT) Ret / E
#constant


dofor tau2 = 1 5 20 60 120 240

comp tau1=fix(%max(1,tau2-19))

comp k=0

do i=500,3908-tau2,tau2

comp k=k+1
declare series u
declare series h
nonlin A1 A2 A3 A4

SET H / = EXP(RANGE - 0.43)
SET U / = 0.0
compute A1=1, A2=0.9,A3=0.05,A4=-0.1
frml res = (RANGE - 0.43 - LOG(H))/0.29
frml HF = exp(A1+A2*log(h{1})+A3*u{1} + A4*E{1}/h{1})
frml logl = (h(t)=hf(t)),(u(t)=res(t)),-0.5*u(t)**2/.29**2
maximize(method=BFGS,NOPRINT, iters=10) LOGL i-495 i

do j = tau1,tau2

set H J J = EXP(%BETA(1)*(1-%BETA(2)**j)/(1-%BETA(2))+log(H(I))*%BETA(2)**J)

end do j

stat h tau1 tau2
set hbar k k = %mean

end do i

end dofor tau2
when i run the code, it always say : ## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
The Error Occurred At Location 684, Line 20 of loop/block
and NO MATTER how i change the code, it always get the same sentence.
please help me with it! many thanks in advance!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Average forecast value

Unread post by TomDoan »

Did you notice that it runs for a while first? So it doesn't happen right away.

If you do

DISP I

it shows that it failed at 1745. So there's a problem in the window with I=1745. If you check the data, you'll discover:

ENTRY LH LL RANGE
1250 0.488641362630 0.494574283180 NA
likykiki
Posts: 11
Joined: Mon Aug 12, 2013 11:42 am

Re: Average forecast value

Unread post by likykiki »

TomDoan wrote:Did you notice that it runs for a while first? So it doesn't happen right away.

If you do

DISP I

it shows that it failed at 1745. So there's a problem in the window with I=1745. If you check the data, you'll discover:

ENTRY LH LL RANGE
1250 0.488641362630 0.494574283180 NA
Yes, you are right! there is an abnormal data in the file. thank you so much!
but why the forecast value becomes so abnormal, for example, the F-statistic become very very big
for example the test for one day forecast horizon
tau1 tau2 mse 100*a 100*as b bs rsq fstat

1 1 0.75071 0.54505 0.00515 -2.64357e-004 6.84783e-005 0.00436 117939403.46700
and the graph of hforbar is also very wrong, huge difference with true value
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Average forecast value

Unread post by TomDoan »

This doesn't look at all right:

frml logl = (h(t)=hf(t)),(u(t)=res(t)),-0.5*u(t)**2/.29**2

Have you checked out your calculations for a single fixed sample before trying to do the complicated loop?
Post Reply