The ambit
package can be used to simulate univariate
(weighted) trawl processes of the form Yt = ∫(−∞, t] × ℝp(t − s)𝕀(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), for x ≥ 0.
a(x) = (1 + 2xγ−2)−1/2exp (δγ(1 − (1 + 2xγ−2)1/2)), for x ≥ 0.
a(x) = (1 + x/α)−H, for x ≥ 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 𝔼(L′) = μ, Var(L′) = σ2 and c4(L′) = 0.
Cauchy distribution (“Cauchy”): L′ ∼ Cauchy(l, s), where l ∈ ℝ is the location parameter and s > 0 the scale parameter. The corresponding density is given by $$ f(x)=\frac{1}{\pi s(1+(x-l)/s)^2}, \quad x \in \mathbb{R}, $$ and the characteristic function is given by ψ(u) = liu − s|u|, u ∈ ℝ. Here we have L(A) ∼ Cauchy(lLeb(A), sLeb(A)).
Normal inverse Gaussian case (“NIG”): L′ ∼ NIG(μ, α, β, δ), where μ ∈ ℝ is the location parameter, α ∈ ℝ the tail heaviness parameter, β ∈ ℝ the asymmetry parameter and δ ∈ ℝ the scale parameter. We set $\gamma=\sqrt{\alpha^2-\beta^2}$. The corresponding density is given by $$ f(x)=\frac{\alpha \delta K_1(\alpha\sqrt{\delta^2+(x-\mu)^2})}{\pi\sqrt{\delta^2+(x-\mu)^2}} \exp(\delta \gamma+\beta(x-\mu)), \quad x \in \mathbb{R}. $$ Here K1 denotes the Bessel function of the third kind with index 1. The characteristic function is given by $$ \psi(u)=\exp(iu\mu+\delta(\gamma-\sqrt{\alpha^2-(\beta+iu)^2})), \quad u \in \mathbb{R}. $$ In this case, we have L(A) ∼ NIG(μLeb(A), α, β, δLeb(A)). Also, $\mathbb{E}(L')=\mu +\frac{\delta \beta}{\gamma}$, $\mathrm{Var}(L')=\frac{\delta \alpha^2}{\gamma^3}$ and $c_4(L')=\frac{3\alpha^2\delta(4\beta^2+\alpha^2)}{\gamma^7}$.
Poisson case (“Poisson”): L′ ∼ Poi(v) for v > 0. In this case, L(A) ∼ Poi(Leb(A)v). We note that 𝔼(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 $\mathrm{P}(L'=x)=\frac{1}{x!}\frac{\Gamma \left( m +x\right) }{\Gamma \left( m \right) }\left( 1-\theta \right)^{m }\theta^{x}$ for x ∈ {0, 1, …}. We note that 𝔼(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.
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")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
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