The ambit
package can be used to simulate univariate
(weighted) trawl processes of the form Yt=∫(−∞,t]×Rp(t−s)I(0,a(t−s))(x)L(dx,ds), for t≥0. We refer to p as the
weight/kernel function, a as the
trawl function and L as the Lévy
basis.
If the function p is given by the identity function, Y is a trawl process, otherwise we refer to Y as a weighted trawl process.
This package only considers the case when the trawl function, denoted by a, is strictly monotonically decreasing.
The following implementations are currently included in the function
sim_weighted_trawl
:
a(x)=exp(−λx),forx≥0.
a(x)=(1+2xγ−2)−1/2exp(δγ(1−(1+2xγ−2)1/2)),forx≥0.
a(x)=(1+x/α)−H,forx≥0.
Alternatively, the user can use the function
sim_weighted_trawl_gen
which requires specifying a
monotonic trawl function a(⋅).
The user can choose a suitable weight function p. If no weight function is provided, then the function p(x)=1 for all x is chosen. I.e. the resulting process is a trawl process rather than a weighted trawl process.
The driving noise of the process is given by a homogeneous Lévy basis denoted by L with corresponding Lévy seed L′.
In the following, we denote by A a Borel set with finite Lebesgue measure.
The following infinitely divisible distributions are currently included in the implementation:
Gaussian case (“Gaussian”): L′∼N(μ,σ2). In this case, L(A)∼N(Leb(A)μ,Leb(A)σ2). We note that E(L′)=μ, Var(L′)=σ2 and c4(L′)=0.
Cauchy distribution (“Cauchy”): L′∼Cauchy(l,s), where l∈R is the location parameter and s>0 the scale parameter. The corresponding density is given by f(x)=1πs(1+(x−l)/s)2,x∈R, and the characteristic function is given by ψ(u)=liu−s|u|,u∈R. Here we have L(A)∼Cauchy(lLeb(A),sLeb(A)).
Normal inverse Gaussian case (“NIG”): L′∼NIG(μ,α,β,δ), where μ∈R is the location parameter, α∈R the tail heaviness parameter, β∈R the asymmetry parameter and δ∈R the scale parameter. We set γ=√α2−β2. The corresponding density is given by f(x)=αδK1(α√δ2+(x−μ)2)π√δ2+(x−μ)2exp(δγ+β(x−μ)),x∈R. Here K1 denotes the Bessel function of the third kind with index 1. The characteristic function is given by ψ(u)=exp(iuμ+δ(γ−√α2−(β+iu)2)),u∈R. In this case, we have L(A)∼NIG(μLeb(A),α,β,δLeb(A)). Also, E(L′)=μ+δβγ, Var(L′)=δα2γ3 and c4(L′)=3α2δ(4β2+α2)γ7.
Poisson case (“Poisson”): L′∼Poi(v) for v>0. In this case, L(A)∼Poi(Leb(A)v). We note that E(L′)=λ, Var(L′)=λ and c4(L′)=λ.
Negative binomial case (“NegBin”): L′∼NegBin(m,θ) for m>0,θ∈(0,1). I.e. the corresponding probability mass function is given by P(L′=x)=1x!Γ(m+x)Γ(m)(1−θ)mθx for x∈{0,1,…}. We note that E(L′)=mθ/(1−θ), Var(L′)=mθ/(1−θ)2 and c4(L′)=mθ(θ2+4θ+1)/(θ−1)4. Then,
L(A)∼NegBin(Leb(A)m,θ).
We demonstrate the simulation of various trawl processes.
library(ambit)
library(ggplot2)
We start off with a trawl with standard normal marginal distribution and exponential trawl function.
#Set the number of observations
n <-2000
#Set the width of the grid
Delta<-0.1
#Determine the trawl function
trawlfct="Exp"
trawlfct_par <-0.5
#Choose the marginal distribution
distr<-"Gauss"
#mean 0, std 1
distr_par<-c(0,1)
#Simulate the path
set.seed(233)
path <- sim_weighted_trawl(n, Delta, trawlfct, trawlfct_par, distr, distr_par)$path
#Plot the path
df <- data.frame(time = seq(0,n,1), value=path)
p <- ggplot(df, aes(x=time, y=path))+
geom_line()+
xlab("l")+
ylab("Trawl process")
p
#Plot the empirical acf and superimpose the theoretical one
#Plot the acf
my_acf <- acf(path, plot = FALSE)
my_acfdf <- with(my_acf, data.frame(lag, acf))
#Confidence limits
alpha <- 0.95
conf.lims <- c(-1,1)*qnorm((1 + alpha)/2)/sqrt(n)
q <- ggplot(data = my_acfdf, mapping = aes(x = lag, y = acf)) +
geom_hline(aes(yintercept = 0)) +
geom_segment(mapping = aes(xend = lag, yend = 0))+
geom_hline(yintercept=conf.lims, lty=2, col='blue') +
geom_function(fun = function(x) acf_Exp(x*Delta,trawlfct_par), colour="red", size=1.2)+
xlab("Lag")+
ylab("Autocorrelation")
q
The same trawl process can be obtained using the
sim_weighted_trawl_gen
instead as follows:
#Set the number of observations
n <-2000
#Set the width of the grid
Delta<-0.1
#Determine the trawl function
trawlfct_par <-0.5
a <- function(x){exp(-trawlfct_par*x)}
#Choose the marginal distribution
distr<-"Gauss"
#mean 0, std 1
distr_par<-c(0,1)
#Simulate the path
set.seed(233)
path <- sim_weighted_trawl_gen(n, Delta, trawlfct_gen=a, distr, distr_par)$path
#Plot the path
df <- data.frame(time = seq(0,n,1), value=path)
p <- ggplot(df, aes(x=time, y=path))+
geom_line()+
xlab("l")+
ylab("Trawl process")
p
#Plot the empirical acf and superimpose the theoretical one
#Plot the acf
my_acf <- acf(path, plot = FALSE)
my_acfdf <- with(my_acf, data.frame(lag, acf))
#Confidence limits
alpha <- 0.95
conf.lims <- c(-1,1)*qnorm((1 + alpha)/2)/sqrt(n)
q <- ggplot(data = my_acfdf, mapping = aes(x = lag, y = acf)) +
geom_hline(aes(yintercept = 0)) +
geom_segment(mapping = aes(xend = lag, yend = 0))+
geom_hline(yintercept=conf.lims, lty=2, col='blue') +
geom_function(fun = function(x) acf_Exp(x*Delta,trawlfct_par), colour="red", size=1.2)+
xlab("Lag")+
ylab("Autocorrelation")
q