help for the 2 factor EGARCH

Discussions of ARCH, GARCH, and related models
kingjia
Posts: 4
Joined: Wed Oct 16, 2013 6:23 pm

help for the 2 factor EGARCH

Unread post by kingjia »

please help
I already check the data delete all the data if it have hi<c<lo , hi=daily highest price, c= daily close price and lo= daily lowest price.
And also check out and delete the data if it have c(i)=c(i+1).
But still output error
## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 0788 of loop/block
Line 33 of loop/block
the code is below:

all 3876

open data X:\AUD.xls

data(format=xls,org=obs) /

close data

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



comp tau2 = 240

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

comp k=0



do i=500,5540-tau2,tau2

comp k=k+1

declare series u

declare series h

declare series Q

STATS(NOPRINT) RANGE

SET Q / = EXP(%MEAN)

SET H / = EXP(RANGE - 0.43)

SET U / = 0.0

nonlin A1 A3 A4 B1 B2 B3 B4

compute A1=0.5, A3=0.05,A4=-0.1, B1=1, B2=0.9,B3=0.05,B4=-0.1



frml res = (RANGE -0.43 -LOG(H))/0.29

frml QF = exp(B1+B2*log(Q{1})+B3*u{1} +B4*E{1}/h{1})

frml HF = exp(A1*LOG(Q{1})+(1-A1)*log(h{1}) +A3*u{1} +A4*E{1}/h{1})

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

maximize(method=genetic,NOPRINT, iters=100) LOGL I-497 I

maximize(method=BFGS,NOPRINT, iters=100) LOGL I-497 I



set Q i+1 i+1 = exp(%BETA(4)+ %BETA(5)*LOG(Q(i))+%BETA(6)*u(i) + %BETA(7)*E(i)/h(i))

set H i+1 i+1 = exp(%BETA(1)*LOG(Q(i))+(1-%BETA(1))*log(h(i))+%BETA(2)*u(i) + %BETA(3)*E(i)/h(i))



do j =1,tau2

set ract j j = r(i+j)



set Q i+j+1 i+j+1 = EXP(%BETA(4) +%BETA(5)*log(Q(I+j)))

set H i+j+1 i+j+1 = EXP(%BETA(1)*LOG(Q(i+j))+(1-%BETA(1))*log(H(I+j)))

end do j



stat(noprint) ract tau1 tau2

set ractbar k k = %mean

stat(noprint) H 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





## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 0788 of loop/block
Line 33 of loop/block
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: help for the 2 factor EGARCH

Unread post by TomDoan »

Could you edit your post and paste in your program directly so it doesn't have all those blank lines. Also, once you have it pasted into the message, select the code and hit the "Code" button. It will make it easier to read.
kingjia
Posts: 4
Joined: Wed Oct 16, 2013 6:23 pm

Re: help for the 2 factor EGARCH

Unread post by kingjia »

please help

I try to select the code then hit the code button, but it doesn't work,
I post a PRG file code, may it help?all 3876

Code: Select all

open data X:\AUD.xls

data(format=xls,org=obs) /

close data

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



comp tau2 = 240

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

comp k=0



do i=500,5540-tau2,tau2

comp k=k+1

declare series u

declare series h

declare series Q

STATS(NOPRINT) RANGE

SET Q / = EXP(%MEAN)

SET H / = EXP(RANGE - 0.43)

SET U / = 0.0

nonlin A1 A3 A4 B1 B2 B3 B4

compute A1=0.5, A3=0.05,A4=-0.1, B1=1, B2=0.9,B3=0.05,B4=-0.1



frml res = (RANGE -0.43 -LOG(H))/0.29

frml QF = exp(B1+B2*log(Q{1})+B3*u{1} +B4*E{1}/h{1})

frml HF = exp(A1*LOG(Q{1})+(1-A1)*log(h{1}) +A3*u{1} +A4*E{1}/h{1})

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

maximize(method=genetic,NOPRINT, iters=100) LOGL I-497 I

maximize(method=BFGS,NOPRINT, iters=100) LOGL I-497 I



set Q i+1 i+1 = exp(%BETA(4)+ %BETA(5)*LOG(Q(i))+%BETA(6)*u(i) + %BETA(7)*E(i)/h(i))

set H i+1 i+1 = exp(%BETA(1)*LOG(Q(i))+(1-%BETA(1))*log(h(i))+%BETA(2)*u(i) + %BETA(3)*E(i)/h(i))



do j =1,tau2

set ract j j = r(i+j)



set Q i+j+1 i+j+1 = EXP(%BETA(4) +%BETA(5)*log(Q(I+j)))

set H i+j+1 i+j+1 = EXP(%BETA(1)*LOG(Q(i+j))+(1-%BETA(1))*log(H(I+j)))

end do j



stat(noprint) ract tau1 tau2

set ractbar k k = %mean

stat(noprint) H 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





## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 0788 of loop/block
Line 33 of loop/block
Attachments
2f-var.PRG
code
(1.85 KiB) Downloaded 733 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: help for the 2 factor EGARCH

Unread post by TomDoan »

Why do you have all those blank lines in your program file?

Your loop is producing no output at all, so you don't know where it even is having the problem. At least put a DISPLAY I instruction in there so you can trace where the problem is.
kingjia
Posts: 4
Joined: Wed Oct 16, 2013 6:23 pm

Re: help for the 2 factor EGARCH

Unread post by kingjia »

Dear tom
I am not understand what you mean of put a display, this is the data I used is not work out, I try to display
disp tau1 tau2 mse 100*a 100*as b bs rsq fstat
but just have error:
## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 0788 of loop/block
Line 33 of loop/block

and I resent the code again , to help you delete those blank line:

Code: Select all

all 3876
open data X:\AUD.xls
data(format=xls,org=obs) /
close data
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
comp tau2 = 240
comp tau1=fix(%max(1,tau2-19))
comp k=0
do i=500,5540-tau2,tau2
comp k=k+1
declare series u
declare series h
declare series Q
STATS(NOPRINT) RANGE
SET Q / = EXP(%MEAN)
SET H / = EXP(RANGE - 0.43)
SET U / = 0.0
nonlin A1 A3 A4 B1 B2 B3 B4
compute A1=0.5, A3=0.05,A4=-0.1, B1=1, B2=0.9,B3=0.05,B4=-0.1
frml res = (RANGE -0.43 -LOG(H))/0.29
frml QF = exp(B1+B2*log(Q{1})+B3*u{1} +B4*E{1}/h{1})
frml HF = exp(A1*LOG(Q{1})+(1-A1)*log(h{1}) +A3*u{1} +A4*E{1}/h{1})
frml logl = (h(t)=hf(t)),(q(t)=qf(t)),(u(t)=res(t)),-0.5*u(t)**2/.29**2
maximize(method=genetic,NOPRINT, iters=100) LOGL I-497 I
maximize(method=BFGS,NOPRINT, iters=100) LOGL I-497 I
set Q i+1 i+1 = exp(%BETA(4)+ %BETA(5)*LOG(Q(i))+%BETA(6)*u(i) + %BETA(7)*E(i)/h(i))
set H i+1 i+1 = exp(%BETA(1)*LOG(Q(i))+(1-%BETA(1))*log(h(i))+%BETA(2)*u(i) + %BETA(3)*E(i)/h(i))
do j =1,tau2
set ract j j = r(i+j)
set Q i+j+1 i+j+1 = EXP(%BETA(4) +%BETA(5)*log(Q(I+j)))
set H i+j+1 i+j+1 = EXP(%BETA(1)*LOG(Q(i+j))+(1-%BETA(1))*log(H(I+j)))
end do j
stat(noprint) ract tau1 tau2
set ractbar k k = %mean
stat(noprint) H 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

## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 0788 of loop/block
Line 33 of loop/block
hope this time you can read the code...
Attachments
AUD.xls
2F data
(348.5 KiB) Downloaded 673 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: help for the 2 factor EGARCH

Unread post by TomDoan »

If you add the disp i instruction here

do i=500,5540-tau2,tau2
disp i

you'll see that it fails with I=4100. Since you have only 3876 data points, that's probably not a surprise.
kingjia
Posts: 4
Joined: Wed Oct 16, 2013 6:23 pm

Re: help for the 2 factor EGARCH

Unread post by kingjia »

WOoooooo, it works. Cool.
thank you for your help, Tom.
Post Reply