From 1e20a6a8090213294204f15bfed62c8e75acb510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Thu, 13 Feb 2014 23:46:32 -0500 Subject: [PATCH] =?UTF-8?q?ajout=20fonction=20caract=C3=A9ristique=20proce?= =?UTF-8?q?ssus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/cfLM.R | 46 ++++++++++++++++++++++++++++++++++++++++++++ R/startparamGAL.R | 37 +++++++++++++++++++++++++++++++++++ man/cfLM.Rd | 31 +++++++++++++++++++++++++++++ man/scaleGAL.Rd | 26 +++++++++++++++++++++++++ man/startparamGAL.Rd | 25 ++++++++++++++++++++++++ 5 files changed, 165 insertions(+) create mode 100644 R/cfLM.R create mode 100644 R/startparamGAL.R create mode 100644 man/cfLM.Rd create mode 100644 man/scaleGAL.Rd create mode 100644 man/startparamGAL.Rd diff --git a/R/cfLM.R b/R/cfLM.R new file mode 100644 index 0000000..fd2b89a --- /dev/null +++ b/R/cfLM.R @@ -0,0 +1,46 @@ +# Characteristic function of Laplace motion +# +# Author: Francois Pelletier +# +# LGPL 3.0 +############################################################################### + +#' Characteristic function of Laplace motion +#' @param u Transform variate +#' @param param Parameter vector +#' @param time Time of the process +#' @param type Choose between "mu" or "kappa" parametrization +#' @param log Logical for log-parameters +#' @param start Starting value of the process +#' @return Characteristic function value at point u for given parameter vector +#' +#' @author Francois Pelletier +cfLM <- function(u,param,time,type="mu",log=FALSE,start=0) +{ + testparGAL(param,type,log) + if(log) + { + if(type=="mu") + { + exp(1i*(start+exp(param[1])*time)*u)*(1+(exp(param[2])^2*u^2)/2-1i*exp(param[3])*u)^(-exp(param[4])*time) + } + if(type=="kappa") + { + exp(1i*(start+exp(param[1])*time)*u)*(1+(exp(param[2])^2*u^2)/2-(1/2*1i)* + exp(param[2])*sqrt(2)*(1/exp(param[3])-exp(param[3]))*u)^(-exp(param[4])*time) + } + } + else + { + if(type=="mu") + { + exp(1i*(start+param[1]*time)*u)*(1+(param[2]^2*u^2)/2-1i*param[3]*u)^(-param[4]*time) + } + if(type=="kappa") + { + exp(1i*(start+param[1]*time)*u)*(1+(param[2]^2*u^2)/2-(1/2*1i)* + param[2]*sqrt(2)*(1/param[3]-param[3])*u)^(-param[4]*time) + } + } +} + diff --git a/R/startparamGAL.R b/R/startparamGAL.R new file mode 100644 index 0000000..6768ca6 --- /dev/null +++ b/R/startparamGAL.R @@ -0,0 +1,37 @@ +# 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 +#' +#' @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) + c(theta,sigma,mu,tau) + else + log(c(theta,sigma,mu,tau)) + } + if(type=="kappa") + { + changetypeGAL(startparamGAL(data,type="mu",log),type="kappa",target="mu",log) + } +} diff --git a/man/cfLM.Rd b/man/cfLM.Rd new file mode 100644 index 0000000..f066e71 --- /dev/null +++ b/man/cfLM.Rd @@ -0,0 +1,31 @@ +\name{cfLM} +\alias{cfLM} +\title{Characteristic function of Laplace motion} +\usage{ +cfLM(u, param, time, type = "mu", log = FALSE, start = 0) +} +\arguments{ + \item{u}{Transform variate} + + \item{param}{Parameter vector} + + \item{time}{Time of the process} + + \item{type}{Choose between "mu" or "kappa" + parametrization} + + \item{log}{Logical for log-parameters} + + \item{start}{Starting value of the process} +} +\value{ +Characteristic function value at point u for given +parameter vector +} +\description{ +Characteristic function of Laplace motion +} +\author{ +Francois Pelletier +} + diff --git a/man/scaleGAL.Rd b/man/scaleGAL.Rd new file mode 100644 index 0000000..b540a87 --- /dev/null +++ b/man/scaleGAL.Rd @@ -0,0 +1,26 @@ +\name{scaleGAL} +\alias{scaleGAL} +\title{Apply scale and location transform to the GAL distribution} +\usage{ +scaleGAL(param, type = "kappa", location, scale) +} +\arguments{ + \item{param}{Parameter vector} + + \item{type}{Choose between "mu" or "kappa" + parametrization} + + \item{location}{Location shift (unitary)} + + \item{scale}{Scale shift (in standard deviations)} +} +\value{ +The transformed parameter vector +} +\description{ +Apply scale and location transform to the GAL distribution +} +\author{ +Francois Pelletier +} + diff --git a/man/startparamGAL.Rd b/man/startparamGAL.Rd new file mode 100644 index 0000000..15c378c --- /dev/null +++ b/man/startparamGAL.Rd @@ -0,0 +1,25 @@ +\name{startparamGAL} +\alias{startparamGAL} +\title{Method of moments with a twist for GAL distribution} +\usage{ +startparamGAL(data, type = "mu", log = FALSE) +} +\arguments{ + \item{data}{Sample} + + \item{type}{Choose between "mu" or "kappa" + parametrization} + + \item{log}{Logical for log-parameters} +} +\value{ +a vector of estimated parameters +} +\description{ +Estimating the parameters of GAL distribution using a twist +on method of moments by Seneta (2004) +} +\author{ +Francois Pelletier +} +