Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

spweights

Compute weights from distance matrix


Description

Function for computing a matrix of gaussian or fixed weights from distance matrix

Usage

spweights(distmat, h = NULL, kernel = "gaussian")

Arguments

distmat

a symmetric matrix of inter-site distances (in km).

h

parameter of the Gaussian distance decay function.

kernel

indicates the type of weighting function, either 'fixed' or 'gaussian'. Default is 'gaussian'.

Details

This function generates a weight matrix (required for the SPpermTest) function. When kernel=="fixed", the weight w_{ij} between site i and j is equal to 1 when their interdistance d_{ij} is below h, and equal to 0 when d_{ij}>h.When kernel=="gaussian", the weight is calculated with formula exp(-d_ij^2/h^2).

Value

An object of class spatialweights

Examples

lon <- c(11.3426,0.1278,0.1218)
lat <- c(44.4949,51.5074,52.2053)
library(sp)
d <- spDists(x=cbind(lon,lat),y=cbind(lon,lat))
spweights(d,h=100)
spweights(d,h=100,kernel="fixed")

rcarbon

Calibration and Analysis of Radiocarbon Dates

v1.4.2
GPL (>= 2)
Authors
Andrew Bevan [aut] (<https://orcid.org/0000-0001-7967-3117>), Enrico Crema [aut, cre] (<https://orcid.org/0000-0001-6727-5138>), R. Kyle Bocinsky [ctb], Martin Hinz [ctb], Philip Riris [ctb], Fabio Silva [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.