ajout fonction caractéristique processus
This commit is contained in:
parent
6572808b1b
commit
1e20a6a809
5 changed files with 165 additions and 0 deletions
46
R/cfLM.R
Normal file
46
R/cfLM.R
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
R/startparamGAL.R
Normal file
37
R/startparamGAL.R
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue