kern2d(x, y, bw=<<see below>>, nx=25, ny=25, lims=c(range(x), range(y)), kernfun=dnorm)
x
.
x
or the
y
directions.
If only one number, then the same value will be repeated for both directions.
See the DETAILS section for its default.
25
.
25
.
dnorm
for the Gaussian kernel,
or
kernquart
for the quartic.
This can be any function that takes a one-dimensional vector
and returns its smoothed version.
x
,
y
respectively.
The returned value may be given to the function
image
for
a graphical display of intensity over the area enclosed by
boundary
.
The bandwidth parameter default value is determined using
Venables and Ripley's (1994) suggested "rule of thumb" for the Inter
Quantile Range
R
and the Gaussian kernel of bandwidth the standard
deviation,
bw <- 4*1.06*min(sqrt(var(x)), R/1.34)*length(x)^(-1/5)
Ideally, the user should try several values before deciding on an
useful bandwidth, perhaps starting with the default above.
This function is based on Venables and Ripley's
kde2d
function.
Venables, W. N. and Ripley, B. D. (1994). Modern Applied Statistics with S-Plus. Springer-Verlag, New York.
plot(geyser$duration, geyser$waiting, type="n") image(kern2d(geyser$duration, geyser$waiting)) points(geyser$duration, geyser$waiting)