Learn R Programming

pmpp (version 0.1.1)

kde2D: Compute a two-dimensional kernel density estimate

Description

The kernel is assumed to be Gaussian. Bandwidth matrix is diagonal. The two bandwidth parameters are chosen optimally without ever using/assuming any parametric model for the data or any "rules of thumb". Unlike many other procedures, this one is immune to accuracy failures in the estimation of multimodal densities with widely separated modes. This function in meant to be the R implementation of the MATLAB kde2d() function written and published by Z. I. Botev at: http://web.maths.unsw.edu.au/~zdravkobotev/

Usage

kde2D(data, n = 2^8, limits = NULL)

Arguments

data

N by 2 matrix with the two variables as columns

n

size of the n by n grid over which the density is computed

limits

limits of the bounding box over which the density is computed; format: c(lower_Xlim, upper_Xlim, lower_Ylim, upper_Ylim)

Value

A list with bandwidth, density and grids for the two dimensions.

References

Z. I. Botev, J. F. Grotowski and D. P. Kroese, "Kernel Density Estimation Via Diffusion", Annals of Statistics, 2010, Volume 38, Number 5, Pages 2916-2957