2014-02-14 04:46:32 +00:00
|
|
|
# Method of moments with a twist for GAL distribution
|
|
|
|
#
|
|
|
|
# Author: Francois Pelletier
|
|
|
|
#
|
|
|
|
# LGPL 3.0
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
|
|
#' Method of moments with a twist for GAL distribution
|
|
|
|
#'
|
|
|
|
#' Estimating the parameters of GAL distribution using a
|
|
|
|
#' twist on method of moments by Seneta (2004)
|
|
|
|
#' @param data Sample
|
|
|
|
#' @param type Choose between "mu" or "kappa" parametrization
|
|
|
|
#' @param log Logical for log-parameters
|
|
|
|
#' @return a vector of estimated parameters
|
2014-03-06 02:44:52 +00:00
|
|
|
#' @export startparamGAL
|
2014-02-14 04:46:32 +00:00
|
|
|
#' @author Francois Pelletier
|
|
|
|
startparamGAL <- function(data,type="mu",log=FALSE)
|
|
|
|
{
|
|
|
|
if(type=="mu")
|
|
|
|
{
|
|
|
|
mom <- c(mean(data),var(data),moments::skewness(data),moments::kurtosis(data)-3)
|
|
|
|
tau <- 3/(mom[4])
|
|
|
|
sigma <- sqrt(mom[2]/(2*tau))
|
|
|
|
mu <- mom[3]*sigma*sqrt(2/(3*(mom[4])))
|
|
|
|
theta <- mom[1]-tau*mu
|
|
|
|
if(log==FALSE)
|
2014-03-06 02:44:52 +00:00
|
|
|
return(c(theta,sigma,mu,tau))
|
2014-02-14 04:46:32 +00:00
|
|
|
else
|
2014-03-06 02:44:52 +00:00
|
|
|
return(log(c(theta,sigma,mu,tau)))
|
2014-02-14 04:46:32 +00:00
|
|
|
}
|
|
|
|
if(type=="kappa")
|
|
|
|
{
|
2014-03-06 02:44:52 +00:00
|
|
|
return(changetypeGAL(startparamGAL(data,type="mu",log),type="kappa",target="mu",log))
|
2014-02-14 04:46:32 +00:00
|
|
|
}
|
|
|
|
}
|