View source: R/corrected_standard_estimator.R
| kernel_est | R Documentation |
This function applies kernel correction to an estimated autocovariance function,
\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.
kernel_est(
estCov,
kernel_name = c("gaussian", "exponential", "wave", "rational_quadratic", "spherical",
"circular", "bessel_j", "matern", "cauchy"),
kernel_params = c(),
N_T = 0.1 * length(estCov),
maxLag = length(estCov) - 1,
x = 0:length(estCov),
type = c("autocovariance", "autocorrelation"),
custom_kernel = FALSE
)
## S3 method for class 'CovEsts'
kernel_est(
estCov,
kernel_name = c("gaussian", "exponential", "wave", "rational_quadratic", "spherical",
"circular", "bessel_j", "matern", "cauchy"),
kernel_params = c(),
N_T = 0.1 * length(estCov$acf),
maxLag = length(estCov$acf) - 1,
x = estCov$lags,
type = c("autocovariance", "autocorrelation"),
custom_kernel = FALSE
)
## Default S3 method:
kernel_est(
estCov,
kernel_name = c("gaussian", "exponential", "wave", "rational_quadratic", "spherical",
"circular", "bessel_j", "matern", "cauchy"),
kernel_params = c(),
N_T = 0.1 * length(estCov),
maxLag = length(estCov) - 1,
x = 0:length(estCov),
type = c("autocovariance", "autocorrelation"),
custom_kernel = FALSE
)
estCov |
A vector whose values are an estimate autocovariance function. |
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 |
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'. |
custom_kernel |
If a custom kernel is to be used or not. Defaults to |
A vector whose values are the kernel corrected autocovariance estimates or 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, inherited from the argument estCov.
est_typeThe type of estimate, namely 'autocorrelation' or 'autocovariance', this depends on the argument type.
est_usedThe estimator function used, in this case, 'kernel_est'.
If a numeric vector is given for the argument estCov, then a numeric vector output is given, and if a CovEsts S3 object is given, a CovEsts object is given as output.
kernel_est(CovEsts): Method for CovEsts objects.
kernel_est(default): Method for numeric vectors.
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] }
cov_est <- standard_est(Y)
plot(cov_est)
plot(kernel_est(cov_est,
"bessel_j", kernel_params=c(0, 1), N_T=0.2*length(Y)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.