Learn R Programming

astro (version 1.2)

akde2d: Two-Dimensional Kernel Density Estimation (Astro)

Description

Two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel, evaluated on a square grid. The function 'akde2d' (astro:kde2d) is a wrapper around the 'kde2d' function within the 'MASS' package. This function adds additional output to that function.

Usage

akde2d(x, y, n = 25, lims = c(range(x), range(y)), levels = seq(0,0.9,by=0.1), ...)

Arguments

x
x coordinate of data
y
y coordinate of data
n
number of grid points in each direction. Can be scalar or a length-2 integer vector
lims
the limits of the rectangle covered by the grid as 'c(xl, xu, yl, yu)'
levels
output levels containing the given percentiles of the data
...
arguments to be passed to 'kde2d' in the 'MASS' package

Value

A list of four components.
x,y
the x and y coordinates of the grid points, vectors of length 'n'
z
an 'n[1]' by 'n[2]' matrix of the estimated density: rows correspond to the value of 'x', columns to the value of 'y'
l
percentile levels containing given fractions of the data

Details

Characters in the string will be stripped 'outside in', from left-to-right in the order they are given in the argument. See examples below for more detail.

References

Venables, W. N. and Ripley, B. D. (2002) _Modern Applied Statistics with S._ Fourth edition. Springer.

See Also

The astronomy package: astro.

Examples

Run this code
# See 'kde2d' for further examples.

Run the code above in your browser using DataLab