2.3 Kernel Weights

Kernel Weights applies kernel function to determine the distance decay in the derived continuous weights kernel. The kernel weights are defined as a function K(z) of the ratio between the distance dij from i to j, and the bandwidth hi, with z=dij/hi. The kernel functions include {triangular , uniform, quadratic , epanechnikov, quartic, gaussian}.

  • Uniform, K(z)=1/2 for |z|<1,

  • Triangular, K(z)=(1βˆ’|z|) for |z|<1,

  • Quadratic or Epanechnikov, K(z)=(3/4)(1βˆ’z^2) for |z|<1,

  • Quartic, K(z)=(15/16)(1βˆ’z^2)^2 for |z|<1|z|<1, and

  • Gaussian. K(z) = (2Ο€)^{1/2}exp(-z^2/2)

For more information, please read: https://geodacenter.github.io/workbook/4c_distance_functions/lab4c.html#kernel-weights

CONTENTS

  1. kernel_weights()

  2. kernel_knn_weights() -- fixed and adaptive bandwidth

There are two types of fixed bandwidths for kernel weights. One is the max-min distance used earlier (the largest of the nearest-neighbor distances): kernel_weights(). The other is the maximum distance for a given specification of k-nearest neighbors: kernel_knn_weights().

1. kernel_weights()

Synopsis

Short version

bytea kernel_weights(integer gid, geometry the_geom, 
    float dist_band, character varying kernel)

Full version

Arguments

Input Arguments

Type

Description

gid

integer

the feature id of geometry: e.g. gid, fid, ogcfid, cartodb_id

the_geom

geometry

the geometry (only points and polygons are supported)

dist_band

float

the distance band/threshold that makes sure each observation has at least one neighbor

kernel

character varying

a varchar value of kernel method, which has to be one of {'triangular', 'uniform', 'epanechnikov', 'quartic', 'gaussian'}

use_kernel_diagonals

boolean

if apply kernel on the diagonal of weights matrix. Default: FALSE.

power

float

the power/exponent corresponds to the number of times the base (dist_band) is used as a factor. Default: 1.

is_inverse

boolean

if apply inverse on distance value. Default: False.

is_arc

boolean

if compute arc distance between two observations. Default: FALSE.

is_mile

boolean

if convert distance unit from mile to kilometer(KM). Default: TRUE.

Return

Value

Description

bytea

the weights structure for each observation in binary format, which is defined in table 2.1.

Examples

2. kernel_knn_weights()

With knn set to a given value, the maximum distance between the selected k-nearest neighbors' pairs is used as a "fixed" bandwidth. However, a drawback of fixed bandwidth kernel weights is that the number of non-zero weights can vary considerably, especially when the density of the point locations is not uniform throughout space. The argument adaptive_bandwidth is provided to allow adaptive bandwidth in knn kernel weights: instead of a fixed distance bandwidth, the distance to the k-th nearest neighbor is used in the kernel function for each observation.

Synopsis

Short version

  • Fixed bandwidth

  • Adaptive bandwidth

Full version

Arguments

Input Arguments

Type

Description

gid

integer

the feature id of geometry: e.g. gid, fid, ogcfid, cartodb_id

the_geom

geometry

the geometry (only points and polygons are supported)

k

integer

the k nearest neighbors

kernel

character varying

a varchar value of kernel method, which has to be one of {'triangular', 'uniform', 'epanechnikov', 'quartic', 'gaussian'}

adaptive_bandwidth

boolean

if use adaptive bandwidth (distance to k-th nearest neighbor for each observation), or use max knn distance of all observations. Default: FALSE.

use_kernel_diagonals

boolean

if apply kernel on the diagonal of weights matrix. Default: FALSE.

power

float

the power/exponent corresponds to the number of times the base (dist_band) is used as a factor. Default: 1.

is_inverse

boolean

if apply inverse on distance value. Default: False.

is_arc

boolean

if compute arc distance between two observations. Default: FALSE.

is_mile

boolean

if convert distance unit from mile to kilometer(KM). Default: TRUE.

Return

Value

Description

bytea

the weights structure for each observation in binary format, which is defined in table 2.1.

Examples

Last updated

Was this helpful?