Title: | Simulation and Estimation of Ambit Processes |
---|---|
Description: | Simulation and estimation tools for various types of ambit processes, including trawl processes and weighted trawl processes. |
Authors: | Almut E. D. Veraart [aut, cre, cph]
|
Maintainer: | Almut E. D. Veraart <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2025-02-17 03:03:26 UTC |
Source: | https://github.com/cran/ambit |
This function computes the autocorrelation function associated with the exponential trawl function.
acf_Exp(x, lambda)
acf_Exp(x, lambda)
x |
The argument (lag) at which the autocorrelation function associated with the exponential trawl function will be evaluated |
lambda |
parameter in the exponential trawl |
The trawl function is parametrised by the parameter
as follows:
Its autocorrelation function is given by:
The autocorrelation function of the exponential trawl function evaluated at x
acf_Exp(1,0.1)
acf_Exp(1,0.1)
This function computes the autocorrelation function associated with the long memory trawl function.
acf_LM(x, alpha, H)
acf_LM(x, alpha, H)
x |
The argument (lag) at which the autocorrelation function associated with the long memory trawl function will be evaluated |
alpha |
parameter in the long memory trawl |
H |
parameter in the long memory trawl |
The trawl function is parametrised by the two parameters
and
as follows:
Its autocorrelation function is given by
The autocorrelation function of the long memory trawl function evaluated at x
acf_LM(1,0.3,1.5)
acf_LM(1,0.3,1.5)
This function computes the autocorrelation function associated with the supIG trawl function.
acf_supIG(x, delta, gamma)
acf_supIG(x, delta, gamma)
x |
The argument (lag) at which the autocorrelation function associated with the supIG trawl function will be evaluated |
delta |
parameter in the supIG trawl |
gamma |
parameter in the supIG trawl |
The trawl function is parametrised by the two parameters and
as follows:
It is assumed that and
are
not simultaneously equal to zero. Its autocorrelation function is given by:
The autocorrelation function of the supIG trawl function evaluated at x
acf_supIG(1,0.3,0.1)
acf_supIG(1,0.3,0.1)
Add slices and return vector of the sums of slices
AddSlices_Rcpp(slicematrix)
AddSlices_Rcpp(slicematrix)
slicematrix |
A matrix of slices. |
Returns the vector of the sums of the slices
Add slices and return vector of the weighted sums of slices
AddWeightedSlices_Rcpp(slicematrix, weightvector)
AddWeightedSlices_Rcpp(slicematrix, weightvector)
slicematrix |
A matrix of slices. |
weightvector |
A vector of weights. |
Returns the vector of the weighted sums of the slices
This function computes the theoretical asymptotic variance appearing in the CLT of the trawl process for a given trawl function and fourth cumulant.
asymptotic_variance(t, c4, varlevyseed = 1, trawlfct, trawlfct_par)
asymptotic_variance(t, c4, varlevyseed = 1, trawlfct, trawlfct_par)
t |
Time point at which the asymptotic variance is computed |
c4 |
The fourth cumulant of the Levy seed of the trawl process |
varlevyseed |
The variance of the Levy seed of the trawl process, the default is 1 |
trawlfct |
The trawl function for which the asymptotic variance will be computed (Exp, supIG or LM) |
trawlfct_par |
The parameter vector of the trawl function (Exp: lambda, supIG: delta, gamma, LM: alpha, H) |
As derived in Sauri and Veraart (2022), the asymptotic variance in the central limit theorem for the trawl function estimation is given by
for .
The integrals in the above formula are approximated numerically.
The function returns .
#Compute the asymptotic variance at time t for an exponential trawl with #parameter 2; here we assume that the fourth cumulant equals 1. av<-asymptotic_variance(t=1, c4=1, varlevyseed=1, trawlfct="Exp", trawlfct_par=2) #Print the av av$v #Print the four components of the asymptotic variance separately av$v1 av$v2 av$v3 av$v4 #Note that v=v1+v2+v3+v4 av$v av$v1+av$v2+av$v3+av$v4
#Compute the asymptotic variance at time t for an exponential trawl with #parameter 2; here we assume that the fourth cumulant equals 1. av<-asymptotic_variance(t=1, c4=1, varlevyseed=1, trawlfct="Exp", trawlfct_par=2) #Print the av av$v #Print the four components of the asymptotic variance separately av$v1 av$v2 av$v3 av$v4 #Note that v=v1+v2+v3+v4 av$v av$v1+av$v2+av$v3+av$v4
This function estimates the asymptotic variance which appears in the CLT for the trawl function estimation.
asymptotic_variance_est(t, c4, varlevyseed = 1, Delta, avector, N = NULL)
asymptotic_variance_est(t, c4, varlevyseed = 1, Delta, avector, N = NULL)
t |
The time point at which to compute the asymptotic variance |
c4 |
The fourth cumulant of the Levy seed of the trawl process |
varlevyseed |
The variance of the Levy seed of the trawl process, the default is 1 |
Delta |
The width Delta of the observation grid |
avector |
The vector |
N |
The optional parameter to specify the upper bound |
As derived in Sauri and Veraart (2022), the estimated asymptotic variance is given by
where
for
and
The estimated asymptotic variance
and its components
.
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the fourth cumulant of the trawl process c4_est <- c4est(Poi_data, my_delta) asymptotic_variance_est(t=1, c4=c4_est, varlevyseed=1, Delta=my_delta, avector=trawl)$v
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the fourth cumulant of the trawl process c4_est <- c4est(Poi_data, my_delta) asymptotic_variance_est(t=1, c4=c4_est, varlevyseed=1, Delta=my_delta, avector=trawl)$v
This function estimates the fourth cumulant of the trawl process.
c4est(data, Delta)
c4est(data, Delta)
data |
The data set used to estimate the fourth cumulant |
Delta |
The width Delta of the observation grid |
According to
Sauri and Veraart (2022), estimator based on
is given by
where
and
The function returns the estimated fourth cumulant of the Levy seed:
.
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the fourth cumulant of the trawl process c4est(Poi_data, my_delta)
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the fourth cumulant of the trawl process c4est(Poi_data, my_delta)
This function estimates the size of the trawl set given by Leb(A).
LebA_est(data, Delta, biascor = FALSE)
LebA_est(data, Delta, biascor = FALSE)
data |
Data to be used in the trawl function estimation. |
Delta |
Width of the grid on which we observe the data |
biascor |
A binary variable determining whether a bias correction should be computed, the default is FALSE |
Estimation of the trawl function using the methodology proposed in Sauri and Veraart (2022).
The estimated Lebesgue measure of the trawl set
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set without bias correction LebA1 <-LebA_est(Poi_data, my_delta) LebA1 #Estimate the trawl set with bias correction LebA2 <-LebA_est(Poi_data, my_delta, biascor=TRUE) LebA2 #Note that Leb(A)=1/my_lambda for an exponential trawl
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set without bias correction LebA1 <-LebA_est(Poi_data, my_delta) LebA1 #Estimate the trawl set with bias correction LebA2 <-LebA_est(Poi_data, my_delta, biascor=TRUE) LebA2 #Note that Leb(A)=1/my_lambda for an exponential trawl
This function estimates Leb(A), Leb(A intersection A_h), Leb(A\ A_h).
LebA_slice_est(data, Delta, h, biascor = FALSE)
LebA_slice_est(data, Delta, h, biascor = FALSE)
data |
Data to be used in the trawl function estimation. |
Delta |
Width of the grid on which we observe the data |
h |
Time point used in A intersection A_h and the setdifference A setdifference A_h |
biascor |
A binary variable determining whether a bias correction should be computed, the default is FALSE |
Estimation of the trawl function using the methodology proposed in Sauri and Veraart (2022).
LebA
LebAintersection
LebAsetdifference
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set and its two slices at time h=2 without bias correction est1 <- LebA_slice_est(Poi_data, my_delta, h=2) est1$LebA est1$LebAintersection est1$LebAsetdifference #Estimate the trawl set and its two slices at time h=2 without bias correction est2 <- LebA_slice_est(Poi_data, my_delta, h=2, biascor=TRUE) est2$LebA est2$LebAintersection est2$LebAsetdifference #Note that Leb(A)=1/my_lambda for an exponential trawl
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set and its two slices at time h=2 without bias correction est1 <- LebA_slice_est(Poi_data, my_delta, h=2) est1$LebA est1$LebAintersection est1$LebAsetdifference #Estimate the trawl set and its two slices at time h=2 without bias correction est2 <- LebA_slice_est(Poi_data, my_delta, h=2, biascor=TRUE) est2$LebA est2$LebAintersection est2$LebAsetdifference #Note that Leb(A)=1/my_lambda for an exponential trawl
This function estimates the ratios Leb(A intersection A_h)/Leb(A), Leb(A\ A_h)/Leb(A).
LebA_slice_ratio_est_acfbased(data, Delta, h)
LebA_slice_ratio_est_acfbased(data, Delta, h)
data |
Data to be used in the trawl function estimation. |
Delta |
Width of the grid on which we observe the data |
h |
Time point used in A intersection A_h and the setdifference A setdifference A_h |
Estimation of the trawl function using the methodology proposed in Sauri and Veraart (2022) which is based on the empirical acf.
LebAintersection_ratio: LebAintersection/LebA
LebAsetdifference_ratio: LebAsetdifference/LebA
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set and its two slices at time h=0.5 est <- LebA_slice_ratio_est_acfbased(Poi_data, my_delta, h=0.5) #Print the ratio LebAintersection/LebA est$LebAintersection_ratio #Print the ratio LebAsetdifference/LebA est$LebAsetdifference_ratio
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl set and its two slices at time h=0.5 est <- LebA_slice_ratio_est_acfbased(Poi_data, my_delta, h=0.5) #Print the ratio LebAintersection/LebA est$LebAintersection_ratio #Print the ratio LebAsetdifference/LebA est$LebAsetdifference_ratio
Returns the mean absolute error between two vectors
my_mae(x, y)
my_mae(x, y)
x |
vector |
y |
vector |
Mean absolute error between the two vectors x and y
#Simulate two vectors of i.i.d.~standard normal data set.seed(456) x <- rnorm(100) y <- rnorm(100) #Compute the mean absolute error between both vectors my_mae(x,y)
#Simulate two vectors of i.i.d.~standard normal data set.seed(456) x <- rnorm(100) y <- rnorm(100) #Compute the mean absolute error between both vectors my_mae(x,y)
Returns the mean squared error between two vectors
my_mse(x, y)
my_mse(x, y)
x |
vector |
y |
vector |
Mean square error between the two vectors x and y
#Simulate two vectors of i.i.d.~standard normal data set.seed(456) x <- rnorm(100) y <- rnorm(100) #Compute the mean squared error between both vectors my_mse(x,y)
#Simulate two vectors of i.i.d.~standard normal data set.seed(456) x <- rnorm(100) y <- rnorm(100) #Compute the mean squared error between both vectors my_mse(x,y)
Returns summary statistics
my_results(x, sd = 1, digits = 3)
my_results(x, sd = 1, digits = 3)
x |
data |
sd |
Optional parameter giving the standard deviation of the normal distribution used for computing the coverage probabilities |
digits |
Optional parameter to how many digits the results should be rounded, the default is three. |
This functions returns the sample mean, sample standard deviation and the coverage probabilities at level 75%, 80%, 85%, 90%, 95%, 99% compared to the standard normal quantiles.
The vector of the sample mean, sample standard deviation and the coverage probabilities at level 75%, 80%, 85%, 90%, 95%, 99% compared to the standard normal quantiles.
#Simulate i.i.d.~standard normal data set.seed(456) data <- rnorm(10000) #Display the sample mean, standard deviation and coverage probabilities: my_results(data)
#Simulate i.i.d.~standard normal data set.seed(456) data <- rnorm(10000) #Display the sample mean, standard deviation and coverage probabilities: my_results(data)
This function implements the nonparametric trawl estimation proposed in Sauri and Veraart (2022).
nonpar_trawlest(data, Delta, lag = 100)
nonpar_trawlest(data, Delta, lag = 100)
data |
Data to be used in the trawl function estimation. |
Delta |
Width of the grid on which we observe the data |
lag |
The lag until which the trawl function should be estimated |
Estimation of the trawl function using the methodology proposed in Sauri and Veraart (2022). Suppose the data is observed on the grid 0, Delta, 2Delta, ..., (n-1)Delta. Given the path contained in data, the function returns the lag-dimensional vector
In the case when lag=n, the n-1 dimensional vector
is returned.
ahat Returns the lag-dimensional vector
Here,
is estimated
based on the realised variance estimator.
a0_alt Returns the alternative estimator of a(0) using the same methodology as the one used for t>0. Note that this is not the recommended estimator to use, but can be used for comparison purposes.
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 PoiEx_trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Plot the estimated trawl function and superimpose the true one l_seq <- seq(from = 0,to = (my_lag-1), by = 1) esttrawlfct.data <- base::data.frame(l=l_seq[1:31], value=PoiEx_trawl[1:31]) p1 <- ggplot2::ggplot(esttrawlfct.data, ggplot2::aes(x=l,y=value))+ ggplot2::geom_point(size=3)+ ggplot2::geom_function(fun = function(x) acf_Exp(x*my_delta,my_lambda), colour="red", size=1.5)+ ggplot2::xlab("l")+ ggplot2::ylab(latex2exp::TeX("$\\hat{a}(\\cdot)$ for Poisson trawl process")) p1
##Simulate a trawl process ##Determine the sampling grid my_n <- 5000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(1726) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 PoiEx_trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Plot the estimated trawl function and superimpose the true one l_seq <- seq(from = 0,to = (my_lag-1), by = 1) esttrawlfct.data <- base::data.frame(l=l_seq[1:31], value=PoiEx_trawl[1:31]) p1 <- ggplot2::ggplot(esttrawlfct.data, ggplot2::aes(x=l,y=value))+ ggplot2::geom_point(size=3)+ ggplot2::geom_function(fun = function(x) acf_Exp(x*my_delta,my_lambda), colour="red", size=1.5)+ ggplot2::xlab("l")+ ggplot2::ylab(latex2exp::TeX("$\\hat{a}(\\cdot)$ for Poisson trawl process")) p1
This function computes the scaled realised quarticity of a time series for a given width of the observation grid.
rq(data, Delta)
rq(data, Delta)
data |
The data set used to compute the scaled realised quarticity |
Delta |
The width Delta of the observation grid |
According to
Sauri and Veraart (2022), the scaled realised quarticity for
is given by
The function returns the scaled realised quarticity RQ_n.
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Compute the scaled realised quarticity rq(Poi_data, my_delta)
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data<-ambit::sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Compute the scaled realised quarticity rq(Poi_data, my_delta)
This function simulates a weighted trawl process for various choices of the trawl function and the marginal distribution.
sim_weighted_trawl( n, Delta, trawlfct, trawlfct_par, distr, distr_par, kernelfct = NULL )
sim_weighted_trawl( n, Delta, trawlfct, trawlfct_par, distr, distr_par, kernelfct = NULL )
n |
number of grid points to be simulated (excluding the starting value) |
Delta |
grid-width |
trawlfct |
the trawl function a used in the simulation (Exp, supIG or LM) |
trawlfct_par |
parameter vector of trawl function (Exp: lambda, supIG: delta, gamma, LM: alpha, H) |
distr |
marginal distribution. Choose from "Gamma" (Gamma), "Gauss" (Gaussian), "Cauchy" (Cauchy), "NIG" (Normal Inverse Gaussian), Poi" (Poisson), "NegBin" (Negative Binomial) |
distr_par |
parameters of the marginal distribution: (Gamma: shape, scale; Gauss: mu, sigma (i.e. the second parameter is the standard deviation, not the variance); Cauchy: l, s; NIG: alpha, beta, delta, mu; Poi: v, NegBin: m, theta) |
kernelfct |
the kernel function p used in the ambit process |
This functions simulates a sample path from a weighted trawl process given by
for ,
and returns
.
path Simulated path
slice_sizes slice sizes used
S_matrix Matrix of all slices
kernelweights kernel weights used
#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.1 trawlfct="Exp" trawlfct_par <-0.5 distr<-"Gauss" distr_par<-c(0,1) #mean 0, std 1 set.seed(233) path <- sim_weighted_trawl(n, Delta, trawlfct, trawlfct_par, distr, distr_par)$path #Plot the path library(ggplot2) 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
#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.1 trawlfct="Exp" trawlfct_par <-0.5 distr<-"Gauss" distr_par<-c(0,1) #mean 0, std 1 set.seed(233) path <- sim_weighted_trawl(n, Delta, trawlfct, trawlfct_par, distr, distr_par)$path #Plot the path library(ggplot2) 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
This function simulates a weighted trawl process for a generic trawl function and various choices the marginal distribution. The specific trawl function to be used can be supplied directly by the user.
sim_weighted_trawl_gen( n, Delta, trawlfct_gen, distr, distr_par, kernelfct = NULL )
sim_weighted_trawl_gen( n, Delta, trawlfct_gen, distr, distr_par, kernelfct = NULL )
n |
number of grid points to be simulated (excluding the starting value) |
Delta |
grid-width |
trawlfct_gen |
the trawl function a used in the simulation |
distr |
marginal distribution. Choose from "Gamma" (Gamma), "Gauss" (Gaussian), "Cauchy" (Cauchy), "NIG" (Normal Inverse Gaussian), Poi" (Poisson), "NegBin" (Negative Binomial) |
distr_par |
parameters of the marginal distribution: (Gamma: shape, scale; Gauss: mu, sigma (i.e. the second parameter is the standard deviation, not the variance); Cauchy: l, s; NIG: alpha, beta, delta, mu; Poi: v, NegBin: m, theta) |
kernelfct |
the kernel function p used in the ambit process |
This functions simulates a sample path from a weighted trawl process given by
for ,
and returns
.
The user needs to ensure that trawlfct_gen is a monotonic function.
path Simulated path
slice_sizes slice sizes used
S_matrix Matrix of all slices
kernelweights kernel weights used
#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.1 trawlfct_par <-0.5 distr<-"Gauss" distr_par<-c(0,1) #mean 0, std 1 set.seed(233) a <- function(x){exp(-trawlfct_par*x)} path <- sim_weighted_trawl_gen(n, Delta, a, distr, distr_par)$path #Plot the path library(ggplot2) 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
#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.1 trawlfct_par <-0.5 distr<-"Gauss" distr_par<-c(0,1) #mean 0, std 1 set.seed(233) a <- function(x){exp(-trawlfct_par*x)} path <- sim_weighted_trawl_gen(n, Delta, a, distr, distr_par)$path #Plot the path library(ggplot2) 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
This function computes the infeasible test statistic appearing in the CLT for the trawl function estimation.
test_asymnorm(ahat, n, Delta, k, c4, varlevyseed = 1, trawlfct, trawlfct_par)
test_asymnorm(ahat, n, Delta, k, c4, varlevyseed = 1, trawlfct, trawlfct_par)
ahat |
The term |
n |
The number n of observations in the sample |
Delta |
The width Delta of the observation grid |
k |
The time point in |
c4 |
The fourth cumulant of the Levy seed of the trawl process |
varlevyseed |
The variance of the Levy seed of the trawl process, the default is 1 |
trawlfct |
The trawl function for which the asymptotic variance will be computed (Exp, supIG or LM) |
trawlfct_par |
The parameter vector of the trawl function (Exp: lambda, supIG: delta, gamma, LM: alpha, H) |
As derived in Sauri and Veraart (2022), the infeasible test statistic is given by
for .
The function returns the infeasible test statistic specified above.
test_asymnorm(ahat=0.9, n=5000, Delta=0.1, k=1, c4=1, varlevyseed=1, trawlfct="Exp", trawlfct_par=0.1)
test_asymnorm(ahat=0.9, n=5000, Delta=0.1, k=1, c4=1, varlevyseed=1, trawlfct="Exp", trawlfct_par=0.1)
This function computes the feasible statistics associated with the CLT for the trawl function estimation.
test_asymnorm_est( data, Delta, trawlfct, trawlfct_par, biascor = FALSE, k = NULL )
test_asymnorm_est( data, Delta, trawlfct, trawlfct_par, biascor = FALSE, k = NULL )
data |
The data set based on observations of
|
Delta |
The width Delta of the observation grid |
trawlfct |
The trawl function for which the asymptotic variance will be computed (Exp, supIG or LM) |
trawlfct_par |
The parameter vector of the trawl function (Exp: lambda, supIG: delta, gamma, LM: alpha, H) |
biascor |
A binary variable determining whether a bias correction should be computed, the default is FALSE |
k |
The optional parameter specifying the time point in
|
As derived in
Sauri and Veraart (2022), the feasible statistic, for , is given by
For , we have
where
We set in the case
when biascor==FALSE and
otherwise.
The function returns the vector of the feasible statistics
if no bias correction
is required and
if
bias correction is required if k is not provided, otherwise it returns the
value
. If the estimated asymptotic variance is <= 0,
the value of the test statistic is set to 999.
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Compute the test statistic for time t=0 ##Either one can use: test_asymnorm_est(Poi_data, my_delta, trawlfct="Exp", trawlfct_par=my_lambda)[1] #or: test_asymnorm_est(Poi_data, my_delta, trawlfct="Exp", trawlfct_par=my_lambda, k=0)
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Compute the test statistic for time t=0 ##Either one can use: test_asymnorm_est(Poi_data, my_delta, trawlfct="Exp", trawlfct_par=my_lambda)[1] #or: test_asymnorm_est(Poi_data, my_delta, trawlfct="Exp", trawlfct_par=my_lambda, k=0)
This function computes the feasible test statistic appearing in the CLT for the trawl function estimation.
test_asymnorm_est_dev( ahat, n, Delta, k, c4, varlevyseed = 1, trawlfct, trawlfct_par, avector )
test_asymnorm_est_dev( ahat, n, Delta, k, c4, varlevyseed = 1, trawlfct, trawlfct_par, avector )
ahat |
The estimated trawl function at time t: |
n |
The number of observations in the data set |
Delta |
The width Delta of the observation grid |
k |
The time point in |
c4 |
The fourth cumulant of the Levy seed of the trawl process |
varlevyseed |
The variance of the Levy seed of the trawl process, the default is 1 |
trawlfct |
The trawl function for which the asymptotic variance will be computed (Exp, supIG or LM) |
trawlfct_par |
The parameter vector of the trawl function (Exp: lambda, supIG: delta, gamma, LM: alpha, H) |
avector |
The vector |
As derived in Sauri and Veraart (2022), the feasible statistic is given by
.
The function returns the feasible statistic
if the estimated asymptotic variance is positive and 999 otherwise.
This function estimates the derivative of the trawl function using the empirical derivative of the trawl function.
trawl_deriv(data, Delta, lag = 100)
trawl_deriv(data, Delta, lag = 100)
data |
The data set used to compute the derivative of the trawl function |
Delta |
The width Delta of the observation grid |
lag |
The lag until which the trawl function should be estimated |
According to
Sauri and Veraart (2022), the derivative of the trawl function can
be estimated based on observations
by
for .
The function returns the lag-dimensional vector
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the derivative of the trawl function trawl_deriv <- trawl_deriv(Poi_data, my_delta, lag=100)
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the derivative of the trawl function trawl_deriv <- trawl_deriv(Poi_data, my_delta, lag=100)
This function estimates the derivative of the trawl function using the modified version proposed in Sauri and Veraart (2022).
trawl_deriv_mod(data, Delta, lag = 100)
trawl_deriv_mod(data, Delta, lag = 100)
data |
The data set used to compute the derivative of the trawl function |
Delta |
The width Delta of the observation grid |
lag |
The lag until which the trawl function should be estimated |
According to
Sauri and Veraart (2022), the derivative of the trawl function can
be estimated based on observations
by
for .
The function returns the lag-dimensional vector
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the derivative of the trawl function trawl_deriv <- trawl_deriv_mod(Poi_data, my_delta, lag=100)
##Simulate a trawl process ##Determine the sampling grid my_n <- 1000 my_delta <- 0.1 my_t <- my_n*my_delta ###Choose the model parameter #Exponential trawl function: my_lambda <- 2 #Poisson marginal distribution trawl my_v <- 1 #Set the seed set.seed(123) #Simulate the trawl process Poi_data <- sim_weighted_trawl(my_n, my_delta, "Exp", my_lambda, "Poi", my_v)$path #Estimate the trawl function my_lag <- 100+1 trawl <- nonpar_trawlest(Poi_data, my_delta, lag=my_lag)$a_hat #Estimate the derivative of the trawl function trawl_deriv <- trawl_deriv_mod(Poi_data, my_delta, lag=100)
Evaluates the exponential trawl function
trawl_Exp(x, lambda)
trawl_Exp(x, lambda)
x |
the argument at which the exponential trawl function will be evaluated |
lambda |
the parameter |
The trawl function is parametrised by parameter as
follows:
The exponential trawl function evaluated at x
trawl_Exp(-1,0.5)
trawl_Exp(-1,0.5)
Evaluates the long memory trawl function
trawl_LM(x, alpha, H)
trawl_LM(x, alpha, H)
x |
the argument at which the supOU/long memory trawl function will be evaluated |
alpha |
the parameter |
H |
the parameter |
The trawl function is parametrised by the two parameters
and
as follows:
If , then the resulting trawl
process has long memory, for
, it has short memory.
the long memory trawl function evaluated at x
trawl_LM(-1,0.5, 1.5)
trawl_LM(-1,0.5, 1.5)
Evaluates the supIG trawl function
trawl_supIG(x, delta, gamma)
trawl_supIG(x, delta, gamma)
x |
the argument at which the supIG trawl function will be evaluated |
delta |
the parameter |
gamma |
the parameter |
The trawl function is parametrised by the two parameters and
as follows:
It is assumed that and
are
not simultaneously equal to zero.
The supIG trawl function evaluated at x
trawl_supIG(-1,0.5,0.2)
trawl_supIG(-1,0.5,0.2)