Page 1 of 1

ARMA-ANN-GARCH model

Posted: Fri Mar 11, 2011 5:24 pm
by John_Val
hi,
I am trying to estimate an ARMA-ANN-ARCH model. The ANN component of the model is defined within a function. When I write the function I get an error message that RATS expects a integer not real, which I donnot know how to get around.

Can you also look at the program to see if I wrote everything correctly. I get the feeling I am not combining the function and the frml command correctly in setting up the ANN component.

thanks.

set dssp = spp-spp{1}

dec vec ARMA(5)
dec vec ANN(2)
dec vec ARCH(3)

com ARMA=%ran(2)
com ANN=%ran(3)

nonlin(paramset=ARMApar) ARMA
nonlin(paramset=ANNpar) ANN
nonlin(paramset=ARCHpar) ARCH

lin(noprint) dssp
# constant dssp{1} dssp{2}
set h = %seesq
set res = 0.0
com ARCH(1) = %seesq ; com ARCH(2) = 0.3 ; com ARCH(3)=0.4



function Neu time
compute Neu=0.0
do i=1,2
com [real]inner = 0.0
do j=1,2
com w1 = sin(%pi*log(2+i+j))
com w2 = sin(%pi*log(5+i+j))
com inner = inner + (w1*dssp(time-j) + w2*dssp(time-j)^2)

## SX22. Expected Type INTEGER, Got REAL Instead
>>>> + (w1*dssp(time-j)<<<<

end do j
compute Neu = Neu + .01*(1+exp(ANN(i)*(inner))^1
end do i
end Neu


frml ANNN = neu(t)
frml mean = ARMA(1) + ARMA(2)*dssp{1} + ARMA(3)*dssp{2} + ARMA(4)*u{1} + ARMA{5}*u{2} + ANNN
frml u = dssp-mean
frml var = ARCH(1) + ARCH(2)*h{1} + ARCH(3)*u{1}^2
frml logly = (u(t)=res(t)),(var(t)=h(t)), %logdensity(h,u)
maximize(parset=ARMApar+ANNpar+ARCHpar) logly 10 *

Re: ARMA-ANN-GARCH model

Posted: Fri Mar 11, 2011 9:35 pm
by TomDoan
John_Val wrote:hi,
I am trying to estimate an ARMA-ANN-ARCH model. The ANN component of the model is defined within a function. When I write the function I get an error message that RATS expects a integer not real, which I donnot know how to get around.

Can you also look at the program to see if I wrote everything correctly. I get the feeling I am not combining the function and the frml command correctly in setting up the ANN component.

thanks.
function Neu time

You never declare TIME, which, by default, will be REAL. Include

type integer time

after the function statement.

Re: ARMA-ANN-GARCH model

Posted: Sat Mar 12, 2011 3:58 pm
by John_Val
Thanks on the above problem.

Using the same model, I wrote a program to loop over 20 different innial values, while saving the u,h series, the parameters and functional value.
When I introduce the loop I get a new error message in the function, which I donnot know what it means.

I pasted the full program again below. Also, am I correctly saving the u and h series?


Code: Select all

dec vector[series] res(20)
dec vector[series] variance(20)
dec vec func(20)
dec vec[vec] paramval(20)

dec vec ARMA(5)
dec vec ANN(2)
dec vec ARCH(3)

do k=1,20

nonlin(paramset=ARMApar) ARMA
nonlin(paramset=ANNpar) ANN
nonlin(paramset=ARCHpar) ARCH

lin(noprint) dssp
# constant dssp{1} dssp{2}
set h = %seesq
set u = 0.0
com ARCH(1) = %seesq ; com ARCH(2) = 0.3 ; com ARCH(3)=0.4
com ARMA=%ran(2)
com ANN=%ran(3)

function Neu time

## CP17. PROCEDURE/FUNCTION Must be Initial Statement in a Compiled Section
>>>>function <<<<


type integer time
compute Neu=0.0
do i=1,2
   com [real]inner  = 0.0
	do j=1,2
   	com w1 = sin(%pi*log(2+i+j))
      com w2 = sin(%pi*log(5+i+j))
      com inner = inner + (w1*dssp(time-j) + w2*dssp(time-j)^2)
	end do j
	compute Neu = Neu + .01*(1+exp(ANN(i)*inner)^1)
end do i
end Neu

frml ANNN = neu(t)
frml resid = dssp - (ARMA(1) + ARMA(2)*dssp{1} + ARMA(3)*dssp{2} + ARMA(4)*u{1} + ARMA(5)*u{2} + ANNN)
frml var = ARCH(1) + ARCH(2)*h{1} + ARCH(3)*(u{1}^2)
frml logly = (u=resid(t)),(h=var(t)), %logdensity(h,u)

maximize(parset=ARMApar+ANNpar+ARCHpar,method=simplex,iter=50,noprint) logly 10 256
maximize(parset=ARMApar+ANNpar+ARCHpar,method=bhhh,cvcrit=0.00000001,noprint) logly 10 256

set res(k) = u
set variance(k) = h
com paramval(k) = %beta
com func(k) = %funcval

end do k

Re: ARMA-ANN-GARCH model

Posted: Sat Mar 12, 2011 5:10 pm
by TomDoan
John_Val wrote:Thanks on the above problem.

Using the same model, I wrote a program to loop over 20 different innial values, while saving the u,h series, the parameters and functional value.
When I introduce the loop I get a new error message in the function, which I donnot know what it means.

I pasted the full program again below. Also, am I correctly saving the u and h series?


do k=1,20

nonlin(paramset=ARMApar) ARMA
nonlin(paramset=ANNpar) ANN
nonlin(paramset=ARCHpar) ARCH

lin(noprint) dssp
# constant dssp{1} dssp{2}
set h = %seesq
set u = 0.0
com ARCH(1) = %seesq ; com ARCH(2) = 0.3 ; com ARCH(3)=0.4
com ARMA=%ran(2)
com ANN=%ran(3)

function Neu time

## CP17. PROCEDURE/FUNCTION Must be Initial Statement in a Compiled Section
>>>>function <<<<


type integer time
compute Neu=0.0
do i=1,2
com [real]inner = 0.0
do j=1,2
com w1 = sin(%pi*log(2+i+j))
com w2 = sin(%pi*log(5+i+j))
com inner = inner + (w1*dssp(time-j) + w2*dssp(time-j)^2)
end do j
compute Neu = Neu + .01*(1+exp(ANN(i)*inner)^1)
end do i
end Neu
Move the definition of the FUNCTION up to before the DO loop.