kernel_transform: Shifting Kernels to a Coefficient and applying a Bandwidth.

Description Usage Arguments Details Value See Also Examples

View source: R/kernel_transform.R

Description

kernel_transform is shifting and applying a bandwidth to a kernel.

Usage

1
kernel_transform(kernel, sample, bandwidth, subdivisions = 1000L)

Arguments

kernel

a kernel as S3 object of the class Kernel.

sample

numeric scalar; the observation.

bandwidth

numeric scalar; the bandwidth.

subdivisions

positive numeric scalar; subdivisions parameter internally passed to integrate_primitive.

Details

The validation of the returned estimator as IntegrableFunction relies on the function integrate_primitive, thus the subdivisions parameter.

Value

The transformed (shifted and scaled) kernel as valid S3 object of class Kernel.

See Also

Kernel for more information about kernels.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# shifting the gaussian kernel
shifted_gaussian <- kernel_transform(gaussian, 2, 1)
# stretching the gaussian kernel
stretched_gaussian <- kernel_transform(gaussian, 0, 2)
x <- seq(from = -5, to = 5, length.out = 1000)

plot(x, gaussian$fun(x),
     xlim=c(-5,5), ylim=c(0,1),
     main="Kernels", xlab="", ylab="",
     col="black", type="l")
lines(x, shifted_gaussian$fun(x), col="red")
lines(x, stretched_gaussian$fun(x), col="blue")
legend("topright",
       legend=c("gaussian", "shifted_gaussian","stretched_gaussian"),
       col=c("black","red", "blue"), lty=1, cex=0.8)

hericks/KDE documentation built on Aug. 22, 2020, 12:04 a.m.