2014-01-04 22:32:36 +00:00
|
|
|
# Centered moments of the GAL distribution
|
|
|
|
# Skewness and (adjusted) kurtosis of the GAL distribution
|
|
|
|
#
|
|
|
|
# Author: Francois Pelletier
|
|
|
|
#
|
|
|
|
# LGPL 3.0
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
#' Centered moments of the GAL distribution
|
|
|
|
#' @param order Order of raw moment
|
|
|
|
#' @param param Parameter vector
|
|
|
|
#' @param type Choose between "mu" or "kappa" parametrization
|
|
|
|
#' @param log Logical for log-parameters
|
|
|
|
#' @return A numeric value of the centered moment
|
2014-03-06 02:44:52 +00:00
|
|
|
#' @export cmGAL
|
2014-01-04 22:32:36 +00:00
|
|
|
#' @author Francois Pelletier
|
|
|
|
cmGAL <- function(order,param,type="mu",log=FALSE)
|
|
|
|
{
|
|
|
|
testparGAL(param,type,log)
|
|
|
|
if(log)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(cmGAL(order,exp(param),type,log=FALSE))
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(type=="mu")
|
|
|
|
{
|
|
|
|
if(order==2)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(param[4]*param[2]^2+param[4]*param[3]^2)
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
if(order==3)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(3*param[3]*param[4]*param[2]^2+2*param[3]^3*param[4])
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(order==4)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return((3*param[4]^2+3*param[4])*param[2]^4+(6*param[3]^2*param[4]^2+12*param[3]^2*param[4])*param[2]^2+3*param[3]^4*param[4]^2+6*param[3]^4*param[4])
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
stop("order must be 2,3 or 4")
|
|
|
|
}
|
|
|
|
if(type=="kappa")
|
|
|
|
{
|
|
|
|
if(order==2)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return((1/2)*param[4]*param[2]^2*(param[3]^4+1)/param[3]^2)
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
if(order==3)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return((1/2)*param[4]*param[2]^3*sqrt(2)*(1-param[3]^6)/param[3]^3)
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
if(order==4)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return((3/4)*param[4]*((param[4]+2)*param[3]^8+2*param[4]*param[3]^4+param[4]+2)*param[2]^4/param[3]^4)
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
stop("order must be 2,3 or 4")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#' Skewness of the GAL distribution
|
|
|
|
#' @param param Parameter vector
|
|
|
|
#' @param type Choose between "mu" or "kappa" parametrization
|
|
|
|
#' @param log Logical for log-parameters
|
|
|
|
#' @return A numeric value of the skewness
|
|
|
|
#'
|
|
|
|
#' @author Francois Pelletier
|
|
|
|
skewnessGAL <- function(param,type="mu",log=FALSE)
|
|
|
|
{
|
|
|
|
testparGAL(param,type,log)
|
|
|
|
if(log)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(skewnessGAL(exp(param),type,log=FALSE))
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(cmGAL(3,param,type) / (cmGAL(2,param,type)^(3/2)))
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#' (Adjusted) kurtosis of the GAL distribution
|
|
|
|
#' @param param Parameter vector
|
|
|
|
#' @param type Choose between "mu" or "kappa" parametrization
|
|
|
|
#' @param log Logical for log-parameters
|
|
|
|
#' @param adjust Logical to use the adjusted kurtosis
|
|
|
|
#' @return A numeric value of the kurtosis
|
|
|
|
#'
|
|
|
|
#' @author Francois Pelletier
|
|
|
|
kurtosisGAL <- function(param,type="mu",log=FALSE,adjust=TRUE)
|
|
|
|
{
|
|
|
|
testparGAL(param,type,log)
|
|
|
|
if(log)
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(kurtosisGAL(exp(param),type,log=FALSE))
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(cmGAL(4,param,type) / (cmGAL(2,param,type)^2) - 3*adjust)
|
2014-01-04 22:32:36 +00:00
|
|
|
}
|
|
|
|
}
|