Last data update: 2014.03.03

R: Weighting functions
weightingR Documentation

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.

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.

Value

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

Author(s)

Julian Gehring

Maintainer: Julian Gehring <julian.gehring@fdm.uni-freiburg.de>

See Also

Package: les-package

Class: Les

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

Examples

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)
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(les)
Loading required package: fdrtool
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/les/weighting.Rd_%03d_medium.png", width=480, height=480)
> ### Name: weighting
> ### Title: Weighting functions
> ### Aliases: weighting triangWeight rectangWeight gaussWeight epWeight
> ### Keywords: htest smooth
> 
> ### ** Examples
> 
> 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)
+ }
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>