KernWeight {LocalCop}R Documentation

Calculate local likelihood kernel weights.

Description

Calculate local likelihood kernel weights.

Usage

KernWeight(x, x0, band, kernel = KernEpa, band_type = "constant")

Arguments

x

Vector of observed covariate values.

x0

Scalar covariate value at which local likelihood estimation is performed.

band

Kernel bandwidth parameter (positive scalar). See Details.

kernel

Kernel function to use. Should accept a numeric vector parameter and return a non-negative numeric vector of the same length. See KernFun().

band_type

A character string specifying the type of bandwidth: either "constant" or "variable". See Details.

Details

For the constant bandwidth of size band = h, the weights are calculated as

wgt = kernel((x-x0) / h) / h

where kernel is the kernel function. For bandwidth type "variable", a fixed fraction band of observations is used, i.e,

h = sort( abs(x-x0) )[ floor(band*length(x)) ]

Value

A vector of nonnegative kernel weights of the same length as x.

Examples

x <- sort(runif(20))
x0 <- runif(1, min = min(x), max= max(x))
KernWeight(x, x0, band=0.3, kernel = KernEpa, band_type = "constant")
KernWeight(x, x0, band=0.3, kernel = KernEpa, band_type = "variable")

[Package LocalCop version 0.0.1 Index]