Vignette: Simulation of (weighted) trawl processes"

knitr::opts_chunk$set(echo = TRUE)

Definition of a (weighted) trawl process

The ambit package can be used to simulate univariate (weighted) trawl processes of the form $$ Y_t =\int_{(-\infty,t]\times \mathbb{R}} p(t-s)\mathbb{I}_{(0, a(t-s))}(x)L(dx,ds), \mbox{ for } t \ge 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.

Choice of the trawl function

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(-\lambda x), \qquad \mathrm{for \,} x \geq 0.$$

$$a(x)=(1+2x\gamma^{-2})^{-1/2}\exp(\delta \gamma(1-(1+2x\gamma^{-2})^{1/2})), \qquad \mathrm{for \,} x \geq 0.$$

$$a(x) = (1+x/\alpha)^{-H}, \qquad \mathrm{for \,} x \geq 0.$$

Alternatively, the user can use the function sim_weighted_trawl_gen which requires specifying a monotonic trawl function $a(\cdot)$.

Choice of kernel/weight

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.

Choice of Lévy bases

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:

Support on $(0, \infty)$

Support on $\mathbb{R}$

Support on $\mathbb{N}_0={0, 1, \ldots}$

$$ L(A)\sim \mathrm{NegBin}(\mathrm{Leb}(A)m, \theta). $$

Examples

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


Try the ambit package in your browser

Any scripts or data that you put into this service are public.

ambit documentation built on Aug. 19, 2022, 5:19 p.m.