Learn R Programming

kobe (version 1.3.2)

kobeDens: kobeDens

Description

Calculates the Densities of obervation in a 2D cell using Two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel, evaluated on a square grid.

Usage

kobeDens(x, y, h = c(bandwidth.nrd(x), bandwidth.nrd(y)), n = 11, lims = c(range(x), range(y)), na.rm = FALSE)

Arguments

x
a vector
y
a vector
n
Number of grid points in each direction. Can be scalar or a length-2 integer vector.
h
vector of bandwidths for x and y directions. Defaults to normal reference bandwidth (see bandwidth.nrd). A scalar value will be taken to apply to both directions.
lims
The limits of the rectangle covered by the grid as c(xl, xu, yl, yu).
na.rm
logical; if true, any NA and NaN's are removed from x before calculations

Value

a data.frame with three variables x, 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.

Examples

Run this code
## Not run: 
#    y=rnorm(20)
#    x  =rnorm(20)
#    kobeDens(x,y)## End(Not run)

Run the code above in your browser using DataLab