View source: R/corrected_standard_estimator.R
| corrected_est | R Documentation |
This function computes the standard autocovariance estimator and applies kernel correction to it,
\widehat{C}_{T}^{(a)}(h) = \widehat{C}(h) a_{T}(h),
where a_{T}(h) := a(h / N_{T}).
It uses a kernel a(\cdot) which decays or vanishes to zero (depending on the type of kernel) where a(0) = 1.
The rate or value at which the kernel vanishes is N_{T}, which is recommended to be of order 0.1 N, where N is the length of the observation window, however, one may need to play with this value.
corrected_est(
X,
kernel_name = c("gaussian", "exponential", "wave", "rational_quadratic", "spherical",
"circular", "bessel_j", "matern", "cauchy"),
kernel_params = c(),
N_T = 0.1 * length(X),
pd = TRUE,
maxLag = length(X) - 1,
x = 0:length(X),
type = c("autocovariance", "autocorrelation"),
meanX = mean(X),
custom_kernel = FALSE
)
X |
A vector representing observed values of the time series. |
kernel_name |
The name of the kernel_ec function to be used. Possible values are: gaussian, exponential, wave, rational_quadratic, spherical, circular, bessel_j, matern, cauchy. |
kernel_params |
A vector of parameters of the kernel function. See kernel_ec for parameters.
In the case of gaussian, wave, rational_quadratic, spherical and circular, |
N_T |
The range at which the kernel function vanishes at. Recommended to be |
pd |
Whether a positive-definite estimate should be used. Defaults to |
maxLag |
An optional parameter that determines the maximum lag to compute the estimated autocovariance function at. Defaults to |
x |
A vector of lag indices. Defaults to the sequence |
type |
Compute either the 'autocovariance' or 'autocorrelation'. Defaults to 'autocovariance'. |
meanX |
The average value of |
custom_kernel |
If a custom kernel is to be used or not. Defaults to |
The aim of this estimator is gradually bring the estimated values to zero through the use of a kernel multiplier. This can be useful when estimating an
autocovariance function that is short-range dependent as estimators can have large fluctuations as the lag increases, or to deal with the wave artefacts for large lags, see Bilchouris and Olenko (2025).
This estimator can be positive-definite depending on whether the choice of \widehat{C}(\cdot) and a are chosen to be positive-definite or not.
A CovEsts S3 object (list) with the following values
acfA numeric vector containing the autocovariance/autocorrelation estimates.
lagsA numeric vector containing the lag indices used to compute the estimates on.
est_typeThe type of estimate, namely 'autocorrelation' or 'autocovariance', this depends on the type parameter.
est_usedThe estimator function used, in this case, 'corrected_est'.
Yaglom, AM (1987). Correlation Theory of Stationary and Related Random Functions. Volume I: Basic Results. Springer New York. https://doi.org/10.1007/978-1-4612-4628-2
Bilchouris, A. & Olenko, A (2025). On Nonparametric Estimation of Covariogram. Austrian Statistical Society (Vol. 54, Issue 1). https://doi.org/10.17713/ajs.v54i1.1975
X <- c(1, 2, 3)
corrected_est(X, "gaussian")
X <- rnorm(1000)
Y <- c(X[1], X[2])
for(i in 3:length(X)) { Y[i] <- X[i] - 0.3*X[i - 1] - 0.6*X[i - 2] }
plot(Y)
plot(corrected_est(Y, "bessel_j",
kernel_params=c(0, 1), N_T=0.2*length(Y)))
# Custom kernel
my_kernel <- function(x, theta, params) {
stopifnot(theta > 0, length(x) >= 1, all(x >= 0))
return(sapply(x, function(t) ifelse(t == 0, 1,
ifelse(t == Inf, 0,
(sin((t^params[1]) / theta) / ((t^params[1]) / theta)) * cos((t^params[2]) / theta)))))
}
plot(corrected_est(Y,
my_kernel, kernel_params=c(2, 0.25), custom_kernel = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.