function jumpgarchx u h lambda deltasq theta ek
type real jumpgarchx u h lambda deltasq theta *ek
*
local integer k
local real jsd wt jp
*
compute wt=0.0
compute ek=0.0
compute jumpgarchx=0.0
do k=0,kmax
compute jsd=sqrt(h+k*deltasq)
compute jp =exp(k*log(lambda)-%lngamma(k+1))
compute wt =wt+jp
compute jpu=jp*%density((u-k*theta)/jsd)/jsd
compute jumpgarchx=jumpgarchx+jpu
compute ek=ek+k*jpu
end do k
compute ek=ek*jumpgarchx
compute jumpgarchx=log(jumpgarchx/wt)
end jumpgarchx
TomDoan wrote:There's an earlier post that shows how to compute the expected number of jumps:
viewtopic.php?p=7979#p7979
The change to the GARCH formula is relatively simple given that.
TomDoan wrote:The use of the source file is to simplify the use of that function, which is needed in both of those programs. If you're just doing a single program, you may not need to strip that out.
The trickiest part about using a function inside a FRML is that, in most cases, it somehow depends upon time "T" information. If possible, it's usually simplest to make the time T references in the FRML rather than the function. For instance, in this:
frml logl = u=uf,h=hf,lambda_t=lambda0,deltasq_t=zeta0^2,theta_t=eta0,$
arjigarch(u,h,lambda_t,deltasq_t,theta_t,xi_t)
all six arguments actually refer to something that depends upon the entry number (U is the current residual, H the current GARCH process variance, etc.) which is what everything on that first line is computing. As long as you're still in the FRML definition, U (if U is a series) means U(T), and same for the other. Thus ARJIGARCH and JUMPGARCH and JUMPGARCHX don't actually need to know what time period they're computing.
Return to Examples and Sample Code
Users browsing this forum: No registered users and 1 guest