Learn R Programming

physx (version 1.0)

kde2: 2D kernel density estimation

Description

Produces a 2D kernel density estimation on a 2D grid from a 2D point set, using adaptive smoothing and allowing for the data points to have weights.

Usage

kde2(
  x,
  y,
  w = NULL,
  s = 1,
  n = c(20, 20),
  xlim = range(x),
  ylim = range(y),
  sd.min = NULL,
  sd.max = NULL,
  reflect = "",
  cpp = TRUE
)

Arguments

x

N-element vector of x-coordinates or N-by-2 matrix of (x,y)-coordinates

y

N-element vector of y-coordinates (only used if x is a vector)

w

optional N-element vector with weights

s

characteristic smoothing length

n

scalar or 2-element vector specifying the number of equally space grid cells

xlim

2-element vector specifying the x-range

ylim

2-element vector specifying the y-range

sd.min

optional value, specifying the minimum blurring of any pixel, expressed in standard deviations in units of pixels

sd.max

optional value, specifying the maximum blurring of any pixel, expressed in standard deviations in units of pixels

reflect

vector of characters c('left','right','bottom','top') specifying the edges, where the data should be reflected

cpp

logical flag; if set to TRUE (default) a fast implementation in C++ is used.

Value

Returns a list of items

x

n-element vector of cell-center x-coordinates.

y

n-element vector of cell-center y-coordinates.

xbreak

(n+1)-element vector of cell-edge x-coordinates.

ybreak

(n+1)-element vector of cell-edge y-coordinates.

n

2D array of point counts.

m

2D array of weighted point counts (masses); only available if w is specified.

d

2D array of smoothed density field.

See Also

griddata2