Defines a distance metric for the AGS

ags_dist(x, y, landw = 10^6, kreisw = 10^3, gemw = 1, ceiling = 99999999)

Arguments

x, y

vectors of AGS values

landw

weight of the Bundesland (Land) integers

kreisw

weight of the Kreis (district) integers

gemw

weight of the Gemeinde (municipality) integers

ceiling

truncate all distances at this value

Value

A numerical vector.

Details

The distance metric is defined as

abs(x[1:2]- y[1:2])*landw + abs(x[3:5]- y[3:5])*kreisw + abs(x[6:8]- y[6:8])*gemw,

where z[a:b] means all digits between a and b for integer z.

With the default weights, this sum is the absolute difference between x and y.

Examples

ags_dist(14053,14059)
#> [1] 6