Description Usage Arguments Details Value See Also Examples
View source: R/kernel_transform.R
kernel_transform
is shifting and applying a bandwidth to a kernel.
1 | kernel_transform(kernel, sample, bandwidth, subdivisions = 1000L)
|
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 |
The validation of the returned estimator as
IntegrableFunction
relies on the function
integrate_primitive
, thus the subdivisions
parameter.
The transformed (shifted and scaled) kernel as valid S3 object of
class Kernel
.
Kernel
for more information about kernels.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.