Learn R Programming

les (version 1.22.0)

weighting: Weighting functions

Description

Set of functions to compute spatial weights between probes.

Usage

triangWeight(distance, win) rectangWeight(distance, win) gaussWeight(distance, win) epWeight(distance, win)

Arguments

distance
Numeric vector specifying the distance of probes from the central probe. Negative values refer to probes upstream, positive values to probes downstream.
win
Integer specifying maximum size of window.

Value

A numeric vector with weights for each probe in the window.

Details

The functions 'triangWeight', 'rectangWeight', 'epWeight' and 'gaussWeight' provide a triangular, rectangular, Epanechnikov and Gaussian weighting window, respectively. The weighting function can be specified by the 'weightingFunction' argument in the 'estimate' method.

This way it is also possible to use custom weighting functions. In general they have to be called the same way as the functions mentioned before and have to return a vector of weights of the same length as the argument 'distance'. For more details on how to use own weighting functions please refer to the vignette of this package. Please note that the returned weights do not have to be normalized since this is done at the computation of the weighted cumulative density.

See Also

Package: les-package

Class: Les Methods and functions: Les estimate threshold regions ci chi2 export plot

Examples

Run this code
distance <- seq(-50, 50)
win <- 50

weight <- triangWeight(distance, win)
plot(distance, weight, type="l", main="triangWeight")

weight <- rectangWeight(distance, win)
plot(distance, weight, type="l", main="rectangWeight")

weight <- gaussWeight(distance, win)
plot(distance, weight, type="l", main="gaussWeight")

weight <- epWeight(distance, win)
plot(distance, weight, type="l", main="epWeight")

## simple example for a custom weighting function
ownWeighting <- function(distance, win)  {
    weight <- as.integer(abs(distance) < win)
    return(weight)
}

Run the code above in your browser using DataLab