kernelwts function

Kernel Weighting function

Kernel Weighting function

This function will calculate the appropriate kernel weights for a vector. This is useful when, for instance, one wishes to perform local regression.

kernelwts(X, center, bw, kernel = "triangular")

Arguments

  • X: input x values. This variable represents the axis along which kernel weighting should be performed.
  • center: the point from which distances should be calculated.
  • bw: the bandwidth.
  • kernel: a string indicating the kernel to use. Options are "triangular" (the default), "epanechnikov", "quartic", "triweight", "tricube", "gaussian", and "cosine".

Returns

A vector of weights with length equal to that of the X input (one weight per element of X).

Examples

require(graphics) X<-seq(-1,1,.01) triang.wts<-kernelwts(X,0,1,kernel="triangular") plot(X,triang.wts,type="l") cos.wts<-kernelwts(X,0,1,kernel="cosine") plot(X,cos.wts,type="l")

Author(s)

Drew Dimmery <drewd@nyu.edu >

  • Maintainer: Drew Dimmery
  • License: Apache License (== 2.0)
  • Last published: 2016-03-14

Useful links