Learn R Programming

gplm (version 0.7-4)

convol: Kernel convolution

Description

Calculates the convolution of data with a kernel function.

Usage

convol(x, h = 1, grid = NULL, y = 1, w = 1, p = 2, q = 2, product = TRUE, sort = TRUE)

Arguments

x
n x d matrix, data
h
scalar or 1 x d, bandwidth(s)
grid
m x d matrix, where to calculate the convolution (default = x)
y
n x c matrix, optional responses
w
scalar or n x 1 or 1 x m or n x m, optional weights
p
integer or text, see kernel.function
q
integer, see kernel.function
product
(if d>1) product or spherical kernel
sort
logical, TRUE if data need to be sorted

Value

m x c matrix

Details

The kernel convolution which is calculated is $\sum_i K_h(x_i - grid_{j})\,y_i\,w_{ij}$ for $i=1,...,n$ and $j=1,...,m$. The kernel function is determined by the kernel parameters p and q, see kernel.function. The default kernel is the biweight (quartic) kernel function. Note that the DLL requires the data matrix to be sorted by its first column.

See Also

kernel.function, kde, kreg

Examples

Run this code
  n <- 100
  x <- rnorm(n)
  convol(x,h=0.8,grid=-3:3)/n  ## estimates density of x at points -3:3

Run the code above in your browser using DataLab