Learn R Programming

sparr (version 0.2-2)

KBivQ: Standard bivariate quartic (biweight) kernel

Description

Evaluates the standard bivariate quartic (biweight) kernel function at specified values, for either the spherical or product derivation of the function.

Usage

KBivQ(X,type="spher")

Arguments

X
A numeric vector of length 2 or a data frame with 2 columns.
type
A character string. lr{ "spher" (default) selects spherical method of calculating the bivariate quartic kernel function "prod" uses the product approach to calculating the function }

Value

  • A single numeric value if X is a vector, or nrow(X) values if X is a data frame, giving the result of the standard bivariate quartic kernel at the specified coordinate(s) for the elected function derivation type.

Details

If X is a vector of length 2, then the two components X[1] and X[2] are taken to be the x and y coordinates respectively. For multiple evaluations at differing coordinates, X must be a data frame with X[,1] and X[,2] as the corresponding pairs of x and y coordinates respectively. Unlike the bivariate Gaussian kernel, it is necessary to specify the method of extending the univariate quartic kernel to the bivariate case; this can be done in two different ways, one way resulting in a slightly different kernel to the other. An explanation of these `spherical' and `product' approaches is given in Wand and Jones (1995).

References

Wand, M.P. and Jones, C.M. (1995), Kernel Smoothing, Chapman & Hall, London.

Examples

Run this code
KBivQ(c(0.1,0.4))

x <- y <- seq(-0.9,0.9,length=50)
z.spher <- KBivQ(data.frame(cbind(sort(rep(x,50)), rep(y,50))))
z.prod <- KBivQ(data.frame(cbind(sort(rep(x,50)), rep(y,50))), "prod")

par(mfrow=c(1,2))
contour(x, y, matrix(z.spher, 50, 50, byrow = TRUE),
 main = "bivariate quartic kernel (spherical)")
contour(x, y, matrix(z.prod, 50, 50, byrow=TRUE),
 main = "bivariate quartic kernel (product)")

Run the code above in your browser using DataLab