Learn R Programming

Laurae (version 0.0.0.9001)

kernel2d_est: MASS' Two-Dimensional Kernel Density Estimation

Description

Two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel, evaluated on a square grid. Originally from MASS package, this function was copied to avoid CRAN notes.

Usage

kernel2d_est(x, y, h, n = 25, lims = c(range(x), range(y)))

Arguments

x
Type: numeric vector. x coordinate of data.
y
Type: numeric vector. y coordinate of data.
h
Type: numeric vector. Vector of bandwidths for x and y directions. Defaults to normal reference bandwidth. A scalar value will be taken to apply to both directions.
n
Type: numeric vector. Number of grid points in each direction. Can be scalar or a length-2 integer vector.
lims
Type: numeric vector. The limits of the rectangle covered by the grid as c(xl, xu, yl, yu).

Value

A list of three elements.

Details

Return a list of three components:
x
The x coordinates of the grid points, vector of length n
y
The y coordinates of the grid points, vector 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.

Examples

Run this code
## Not run: ------------------------------------
# #?MASS::kde2d
## ---------------------------------------------

Run the code above in your browser using DataLab