diff --git a/.project b/.project index f12df2d..edbc17e 100644 --- a/.project +++ b/.project @@ -14,6 +14,5 @@ de.walware.statet.base.StatetNature de.walware.statet.r.RNature - de.walware.statet.r.RPkgNature diff --git a/R/cgfEsscherGAL.R b/R/cgfEsscherGAL.R index 15adaef..c9e0f50 100644 --- a/R/cgfEsscherGAL.R +++ b/R/cgfEsscherGAL.R @@ -1,5 +1,5 @@ # Cumulant generating function of the -# Esscher transform with parameter 1 of GAL distribution +# Esscher transform of GAL distribution # # Author: Francois Pelletier # @@ -11,22 +11,37 @@ #' Esscher transform with parameter 1 of GAL distribution #' @param u Transform variate #' @param param Parameter vector +#' @param ess.param Esscher Transform Parameter #' @param eval.time Time of the process #' @param type Choose between "mu" or "kappa" parametrization #' @param log Logical for log-parameters #' @return Cumulant generating function value at point u for given parameter vector #' @export cgfEsscherGAL #' @author Francois Pelletier -cgfEsscherGAL <- function(u,param,eval.time=1,type="mu",log=FALSE) +cgfEsscherGAL <- function(u,param,ess.param=1,eval.time=1,type="mu",log=FALSE) { - if(type=="mu") + testparGAL(param,type,log) + if(log) { - return(log((exp(param[1]*(u+1))/(1-(1/2)*param[2]^2*(u+1)^2-param[3]*(u+1))^param[4])^eval.time/ - (exp(param[1])/(1-(1/2)*param[2]^2-param[3])^param[4])^eval.time)) + if(type=="mu") + { + return(log(exp(exp(param[1])*(u+ess.param))*(1-(1/2)*exp(param[2])^2*(u+ess.param)^2-exp(param[3])*(u+ess.param))^(-exp(param[4])))) + } + if(type=="kappa") + { + return(log(exp(exp(param[1])*(u+ess.param))*((exp(param[2])^2*(u+ess.param)^2)/2+(exp(param[3])*exp(param[2])*(u+ess.param))/sqrt(2)-(exp(param[2])*(u+ess.param))/(sqrt(2)*exp(param[3]))+1)^(-exp(param[4])))) + } } - if(type=="kappa") + else { - + if(type=="mu") + { + return(log(exp(param[1]*(u+ess.param))*(1-(1/2)*param[2]^2*(u+ess.param)^2-param[3]*(u+ess.param))^(-param[4]))) + } + if(type=="kappa") + { + return(log(exp(param[1]*(u+ess.param))*((param[2]^2*(u+ess.param)^2)/2+(param[3]*param[2]*(u+ess.param))/sqrt(2)-(param[2]*(u+ess.param))/(sqrt(2)*param[3])+1)^(-param[4]))) + } } } diff --git a/R/psaddleapproxEsscherGAL.R b/R/psaddleapproxEsscherGAL.R index 7522f8d..75e8e4e 100644 --- a/R/psaddleapproxEsscherGAL.R +++ b/R/psaddleapproxEsscherGAL.R @@ -20,7 +20,7 @@ psaddleapproxEsscherGAL <- function(x,param,eval.time=1,type="mu",log=FALSE) { s <- saddlepointEsscherGAL(x,param,eval.time,type,log) u <- s * sqrt(diffcgfEsscherGAL(s,2,param,eval.time,type,log)) - w <- sign(s)*sqrt(2*(s*x-cgfEsscherGAL(s,param,type,log))) + w <- sign(s)*sqrt(2*(s*x-cgfEsscherGAL(s,param,1,eval.time,type,log))) (x==round(mGAL(param,1,type,log),4))* (1/2 + diffcgfEsscherGAL(0,3,param,eval.time,type,log)/