Dear all,
I am trying to back out the implied parameters using observed options prices
and the Heston-Nandi Garch model via NLS.
For this purpose I am using Diethelm Wuertz's pricing algorithm in a
function called hnoption similar to this:
hnoption <- function(b) #where b is the vector of parameters passed on
to the pricing algorithm
{
....
hnoption <- value obtained via pricing algorithm
}
calccall <- function(b)
{
for (jj in 1:num1)
{
counter <<- jj
qq[jj] <- hnoption(b)
}
calccall <- sum((c-qq)^2)
}
# some initial guess of parameters
bstart <- c(.1,.1,1,-.5,.7)
p <- optim(bstart,calccall,hessian = TRUE)
The code works fine for a few iterations of optim(). However, at some point
it produces parameter values that cause an integral that's being evaluated
in hnoption to drift off to infinity. At least that's what I think happens
when R produces the error: error in integrate(): non-finite function value.
I have tried to constrain some parameters in optim() but keep receiving the
same error.
I would really appreciate if someone could point me to possible solutions.
Regards
Tobias