| 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] (ORCID: <https://orcid.org/0000-0001-8582-3652>) |
| Maintainer: | Almut E. D. Veraart <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.3 |
| Built: | 2026-10-11 08:54:55 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)
discrete_fourier_sin_cos
discrete_fourier_sin_cos(x, a, b, tau)discrete_fourier_sin_cos(x, a, b, tau)
x |
argument for which the acf will be computed (this can be a vector) |
a |
vector of coefficients a_0,...a_n |
b |
vector of coefficients b_1,...b_n |
tau |
period of function |
Computes the Fourier approximation of a function using the sin-cos representation for given coefficients a_0,...a_n, b_1, ...b_n and rounds the values to a grid of width 1
Fourier approximation or vector of Fourier approximations evaluated in x
Fits an exponential periodic trawl function to equidistant time series data
fit_exp_periodic_trawl( x, m = 1, tau, GMMlag = 50, Delta = 1, plotacf = FALSE, lags = 100 )fit_exp_periodic_trawl( x, m = 1, tau, GMMlag = 50, Delta = 1, plotacf = FALSE, lags = 100 )
x |
vector of equidistant time series data |
m |
the order of the Fourier approximation of the periodic function |
tau |
the period, if not provided it will be estimated |
GMMlag |
lag length used in the GMM estimation, the default is 50 |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The parameter is estimated using the smoothed periodogram,
the parameter is estimated by GMM.
lambda: the parameter in the exponential trawl,
tau: the period ,
a: the vector of the Fourier coefficients,
b: the vector of the Fourier coefficients.
Fits an exponential trawl function to equidistant time series data
fit_exp_sin_trawl(x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100)fit_exp_sin_trawl(x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100)
x |
vector of equidistant time series data |
GMMlag |
lag length used in the GMM estimation, the default is 10 |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The
Lebesgue measure of the corresponding trawl set is given by .
Both parameters and are estimated by GMM.
lambda: the memory parameter in the exponential trawl
Fits an exponential trawl function to equidistant time series data
fit_exp_sin_trawl_periodfixed( x, tau = 1, GMMlag, Delta = 1, plotacf = FALSE, lags = 100 )fit_exp_sin_trawl_periodfixed( x, tau = 1, GMMlag, Delta = 1, plotacf = FALSE, lags = 100 )
x |
vector of equidistant time series data |
tau |
period in the sine function, the default is 1 |
GMMlag |
lag length used in the GMM estimation, the default is tau |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The
Lebesgue measure of the corresponding trawl set is given by .
lambda: the memory parameter in the exponential trawl
Fits an exponential trawl function to equidistant time series data
fit_exp_sin_trawl_periodogram( x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100 )fit_exp_sin_trawl_periodogram( x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100 )
x |
vector of equidistant time series data |
GMMlag |
lag length used in the GMM estimation, the default is 10 |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The
Lebesgue measure of the corresponding trawl set is given by .
The period parameter is estimated using the smoothed periodogram and the
trawl paramter is estimated using GMM.
lambda: the memory parameter in the exponential trawl
Fits a supGamma periodic trawl function to equidistant time series data
fit_LM_periodic_trawl( x, m = 1, tau, GMMlag = 50, Delta = 1, plotacf = FALSE, lags = 100 )fit_LM_periodic_trawl( x, m = 1, tau, GMMlag = 50, Delta = 1, plotacf = FALSE, lags = 100 )
x |
vector of equidistant time series data |
m |
the order of the Fourier approximation of the periodic function |
tau |
the period, if not provided it will be estimated |
GMMlag |
lag length used in the GMM estimation, the default is 50 |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The parameter is estimated using the smoothed periodogram,
the other parameters are estimated by GMM.
alpha: the parameter in the supGamma trawl,
H: the parameter in the supGamma trawl,
tau: the period , a: the vector of the Fourier coefficients,
b: the vector of the Fourier coefficients.
Fits a LM periodic trawl function to equidistant time series data
fit_LM_sin_trawl(x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100)fit_LM_sin_trawl(x, GMMlag = 10, Delta = 1, plotacf = FALSE, lags = 100)
x |
vector of equidistant time series data |
GMMlag |
lag length used in the GMM estimation, the default is 10 |
Delta |
interval length of the time grid used in the time series, the default is 1 |
plotacf |
binary variable specifying whether or not the empirical and fitted autocorrelation function should be plotted |
lags |
number of lags to be used in the plot of the autocorrelation function |
The trawl function is parametrised by the parameter
as follows:
The
Lebesgue measure of the corresponding trawl set is given by .
Both parameters and are estimated by GMM.
lambda: the memory parameter in the exponential trawl
fourier_sin_cos
fourier_sin_cos(x, a, b, tau)fourier_sin_cos(x, a, b, tau)
x |
argument for which the acf will be computed (this can be a vector) |
a |
vector of coefficients a_0,...a_n |
b |
vector of coefficients b_1,...b_n |
tau |
period of function |
Computes the Fourier approximation of a function using the sin-cos representation for given coefficients a_0,...a_n, b_1, ...b_n
Fourier approximation or vector of Fourier approximations evaluated in x
kernel_generic_trawl_acf
kernel_generic_trawl_acf(p, g, x)kernel_generic_trawl_acf(p, g, x)
p |
kernel function to be used in the weighted trawl process |
g |
trawl function |
x |
argument for which the acf will be computed (this can be a vector) |
We numerically approximate the acf for a given periodic function p and a given trawl function g
acf or vector of acfs evaluated in x
my_p <- function(x){sin(x)} my_g <- function(x){exp(-x)} kernel_generic_trawl_acf(my_p, my_g, 1) kernel_generic_trawl_acf(my_p, my_g, c(1,2,3,4))my_p <- function(x){sin(x)} my_g <- function(x){exp(-x)} kernel_generic_trawl_acf(my_p, my_g, 1) kernel_generic_trawl_acf(my_p, my_g, c(1,2,3,4))
kernel_generic_trawl_acf_incrtol
kernel_generic_trawl_acf_incrtol(p, g, x)kernel_generic_trawl_acf_incrtol(p, g, x)
p |
kernel function to be used in the weighted trawl process |
g |
trawl function |
x |
argument for which the acf will be computed (this can be a vector) |
We numerically approximate the acf for a given periodic function p and a given trawl function g We allow for an increased tolerance level in the integral computations.
acf or vector of acfs evaluated in x
kernel_trawl_acf
kernel_trawl_acf(p, trawlfct, trawlfct_par, x)kernel_trawl_acf(p, trawlfct, trawlfct_par, x)
p |
kernel function to be used in the weighted trawl process |
trawlfct |
the trawl function used (Exp, supIG or LM) |
trawlfct_par |
parameter vector of trawl function |
x |
argument for which the acf will be computed (this can be a vector) |
We numerically approximate the acf for a given periodic function p and a given trawl function g
acf or vector of acfs evaluated in x
kernel_trawl_acf_exp_periodic
kernel_trawl_acf_exp_periodic(x, lambda, a, b, tau)kernel_trawl_acf_exp_periodic(x, lambda, a, b, tau)
x |
argument for which the acf will be computed (this can be a vector) |
lambda |
parameter in the trawl function |
a |
vector of Fourier coefficients |
b |
vector of Fourier coefficients |
tau |
period in the sine function |
We compute the acf of a weighted trawl process with exponential trawl function and periodic function
acf or vector of acfs evaluated in x
kernel_trawl_acf_exp_sin
kernel_trawl_acf_exp_sin(x, lambda, tau)kernel_trawl_acf_exp_sin(x, lambda, tau)
x |
argument for which the acf will be computed (this can be a vector) |
lambda |
parameter in the exponential trawl function |
tau |
period in the sine function |
We compute the acf of a weighted trawl process with exponential trawl function and periodic function given by the sine function
acf or vector of acfs evaluated in x
kernel_trawl_acf_LM_periodic
kernel_trawl_acf_LM_periodic(x, alpha, H, a, b, tau)kernel_trawl_acf_LM_periodic(x, alpha, H, a, b, tau)
x |
argument for which the acf will be computed (this can be a vector) |
alpha |
parameter in the trawl function |
H |
parameter in the trawl function |
a |
vector of Fourier coefficients |
b |
vector of Fourier coefficients |
tau |
period in the sine function |
We compute the acf of a weighted trawl process with supGamma trawl function and periodic function
acf or vector of acfs evaluated in x
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, adjust_neg = FALSE, adjust_variance = FALSE )LebA_slice_est( data, Delta, h, biascor = FALSE, adjust_neg = FALSE, adjust_variance = 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 |
adjust_neg |
A binary variable determining whether negative estimates of the trawl function should be set to 0, the default is FALSE |
adjust_variance |
A binary variable determining whether a variance adjustment should be used, 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 Leb(A), Leb(A intersection A_h), Leb(A\ A_h).
LebA_slice_est_approx(esttrawl, Delta, h, adjust_neg = FALSE)LebA_slice_est_approx(esttrawl, Delta, h, adjust_neg = FALSE)
esttrawl |
Vector containing estimated trawl function. |
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 |
adjust_neg |
A binary variable determining whether negative estimates of the trawl function should be set to 0, 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, reduced_percentiles = FALSE)my_results(x, sd = 1, digits = 3, reduced_percentiles = FALSE)
x |
Numeric vector of data values |
sd |
Optional parameter giving the standard deviation of the normal distribution used for computing the coverage probabilities. Default is 1. |
digits |
Optional parameter specifying to how many digits the results should be rounded. Default is 3. |
reduced_percentiles |
Optional logical parameter specifying whether only the upper three levels of 90 Default is FALSE. |
This function returns the sample mean, sample standard deviation and the coverage probabilities at levels 75 (or just 90 standard normal quantiles. Coverage probability is calculated as the proportion of |x| values that fall within the specified quantile range.
A numeric vector containing:
Sample mean
Sample standard deviation
Coverage probabilities at the specified levels
When reduced_percentiles=FALSE: returns 8 values(mean, sd, 6 coverage levels) When reduced_percentiles=TRUE: returns 5 values (mean, sd, 3 coverage levels)
#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 |
Numeric vector of data used to compute the derivative of the trawl function |
Delta |
Numeric value specifying the width Delta of the observation grid |
lag |
Integer specifying the lag until which the trawl function derivative should be estimated. Default is 100. |
This function first estimates the trawl function
using nonpar_trawlest, then computes the derivative using
finite differences:
for .
Numeric vector of length lag containing the estimated
derivative values
.
nonpar_trawlest for the underlying trawl function
estimation
##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 |
Numeric vector of data used to compute the derivative of the trawl function |
Delta |
Numeric value specifying the width Delta of the observation grid |
lag |
Integer specifying the lag until which the trawl function derivative should be estimated. Default is 100. |
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)
This function implements bias correction for the nonparametric trawl estimation proposed in Sauri and Veraart (2022).
trawl_est(data, Delta)trawl_est(data, Delta)
data |
Data to be used in the trawl function estimation. |
Delta |
Width of the grid on which we observe the data |
This function performs bias correction on the nonparametric trawl
function estimates obtained using the methodology of Sauri and Veraart (2022).
The bias correction is implemented by estimating the derivative of the trawl
function and applying the correction ,
where is the estimated derivative at lag .
Suppose the data is observed on the grid 0, Delta, 2Delta, ..., (n-1)Delta. Given the path contained in data, the function returns both the original and bias-corrected estimates of the trawl function.
The bias correction is based on the theoretical result that the leading bias term in nonparametric trawl function estimation is proportional to Delta times the derivative of the true trawl function.
trawlfct Returns the original nonparametric trawl function estimate
obtained from nonpar_trawlest.
trawlfct_biascor Returns the bias-corrected trawl function estimate,
computed as the original estimate minus the bias correction term
.
nonpar_trawlest, trawl_deriv_mod
#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.5 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 result <- trawl_est(path, Delta) original_estimate <- result$trawlfct[1:30] bias_corrected <- result$trawlfct_biascor[1:30] # True exponential values for the same lags lags <- 0:(length(original_estimate)-1) true_vals <- a(lags * Delta) # Plot all three plot(lags, original_estimate, type = "l", col = "blue", lwd = 2, xlab = "Lag index", ylab = "Trawl function estimate", main = "Trawl function: Original vs bias-corrected vs true", ylim = range(c(original_estimate, bias_corrected, true_vals), na.rm = TRUE)) lines(lags, bias_corrected, col = "red", lwd = 2, lty = 2) lines(lags, true_vals, col = "black", lwd = 2, lty = 3) legend("topright", legend = c("Original", "Bias-corrected", "True exponential"), col = c("blue", "red", "black"), lty = c(1, 2, 3), lwd = 2)#Simulation of a Gaussian trawl process with exponential trawl function n<-2000 Delta<-0.5 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 result <- trawl_est(path, Delta) original_estimate <- result$trawlfct[1:30] bias_corrected <- result$trawlfct_biascor[1:30] # True exponential values for the same lags lags <- 0:(length(original_estimate)-1) true_vals <- a(lags * Delta) # Plot all three plot(lags, original_estimate, type = "l", col = "blue", lwd = 2, xlab = "Lag index", ylab = "Trawl function estimate", main = "Trawl function: Original vs bias-corrected vs true", ylim = range(c(original_estimate, bias_corrected, true_vals), na.rm = TRUE)) lines(lags, bias_corrected, col = "red", lwd = 2, lty = 2) lines(lags, true_vals, col = "black", lwd = 2, lty = 3) legend("topright", legend = c("Original", "Bias-corrected", "True exponential"), col = c("blue", "red", "black"), lty = c(1, 2, 3), lwd = 2)
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)