#' Get the coefficients of a kernel
#'
#' Function to get the coefficient associated to a kernel. Those
#' coefficients are then used to compute the different filters.
#'
#' @inheritParams localpolynomials
#' @param sd_gauss standard deviation for gaussian kernel. By default 0.25.
#'
#' @return \code{tskernel} object (see \link[stats]{kernel}).
#' @export
#'
#' @examples
#' get_kernel("Henderson", horizon = 3)
get_kernel <- function(kernel = c("Henderson","Uniform", "Triangular",
"Epanechnikov","Parabolic","Biweight", "Triweight","Tricube",
"Trapezoidal", "Gaussian"),
horizon,
sd_gauss = 0.25){
kernel = match.arg(kernel)
if(kernel == "Parabolic")
kernel = "Epanechnikov"
h <- as.integer(horizon)
if(kernel == "Gaussian"){
jkernel <- .jcall("jdplus/toolkit/base/core/data/analysis/DiscreteKernel",
"Ljava/util/function/IntToDoubleFunction;",
tolower(kernel), h, sd_gauss)
}else{
jkernel <- .jcall("jdplus/toolkit/base/core/data/analysis/DiscreteKernel",
"Ljava/util/function/IntToDoubleFunction;",
tolower(kernel), h)
}
coef = sapply(as.integer(seq.int(from = 0, to = horizon, by = 1)),
jkernel$applyAsDouble)
m = horizon
result <- list(coef = coef, m = m)
attr(result, "name") <- kernel
attr(result, "class") <- "tskernel"
result
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.