I am using the R-package ghyp
in order to calibrate and model. In fact my coding is based on this paper.
I know that I could do quite a robust fit using fit.ghypuv
but I try to maximize a rather complicated likelihood function bases on a Markov-chain with ghyp marginals given the state.
Therefore I use a non-linear optimizer (nloptr
with parameter NLOPT_LN_NELDERMEAD and optim
with parameter Nelder-Mead).
In the alpha-bar parametrization I assure that $\bar{\alpha}$ and $\sigma$ are great zero. Do I have to restrict the parameters further? If yes, then how can I do this? I use $\log$ and $\exp$ transformations to transform the non-negative parameters to the real line and some $(0,1)\rightarrow \mathbb{R}$ mapping for the probabilities of the chain.
Part of the calibration is based on absolute centered moments of the ghyp distribution. These are calculated numerically using ghyp.moment
.
The problem is that the optimizer searches the whole space (it searches in $\mathbb{R}$ and in the objective function I transform the parameters to their domain, i.e. probabilities to $(0,1)$ and non-negative parameters to $\mathbb{R}^+$) and finds values such that I get the error message
Error in integrate(internal.moment, -Inf, Inf, tmp.order = order[i],
lambda = object@lambda, : the integral is probably divergent
E.g. I get the error in this parameter setting:
my.ghyp =ghyp(lambda = -1.570151, mu = 0.006935, sigma = 0.001719412,
gamma = -0.006574129, alpha.bar = 923391)
ghyp.moment(my.ghyp,order=1,absolute=TRUE,central=TRUE)
while it works, if I increase $\sigma$ slightly
my.ghyp =ghyp(lambda = -1.570151, mu = 0.006935, sigma = 0.003,
gamma = -0.006574129, alpha.bar = 923391)
ghyp.moment(my.ghyp,order=1,absolute=TRUE,central=TRUE)
EDIT: In the paper mentioned the absolute moments of $X$, ie. $|X|$, is used for the calibration for $X\sim \text{GHYP}$. This has to be done numerically. If I reformulate the calibration using $X^2$ can I then avoid a numerical procedure and get something explicite or some recursion?
EDIT: I have found the paper Moments of the generalized hyperbolic distribution. There one can find expressions using fractions of Bessel functions that can be calculated in a nummerically stable way for moments up to order four. I will use this.