compareCrimes {crimelinkage} | R Documentation |
Calculates spatial and temporal distance, difference in categorical, and absolute value of numerical crime variables
compareCrimes(Pairs, crimedata, varlist, binary = TRUE, longlat = FALSE,
show.pb = FALSE, ...)
Pairs |
(n x 2) matrix of crimeIDs |
crimedata |
data.frame of crime incident data. There must be a column
named |
varlist |
a list with elements named: crimeID, spatial, temporal,
categorical, and numerical. Each element should be a vector of the column
names of
|
binary |
(logical) match/no match or all combinations for categorical data |
longlat |
(logical) are spatial coordinates in (long,lat)? |
show.pb |
(logical) show the progress bar |
... |
other arguments passed to hidden functions |
data.frame of various proximity measures between the two crimes
If spatial
data is provided: the euclidean distance
(if longlat = FALSE
) or Haversine great circle distance
(distHaversine
if longlat = TRUE
) is
returned (in kilometers).
If temporal
data is provided: the expected absolute time
difference is returned:
temporal - overall difference (in days) [0,max]
tod - time of day difference (in hours) [0,12]
dow - fractional day of week difference (in days) [0,3.5]
If categorical
data is provided: if binary = TRUE
then a
1 if the categories of each crime match and a 0 if they do not match. If
binary = FALSE
, then a factor of merged values (in form of f1:f2)
If numerical
data is provided: the absolute difference is
returned.
Porter, M. D. (2014). A Statistical Approach to Crime Linkage. arXiv preprint arXiv:1410.2285.. http://arxiv.org/abs/1410.2285
data(crimes)
pairs = t(combn(crimes$crimeID[1:4],m=2)) # make some crime pairs
varlist = list(
spatial = c("X", "Y"),
temporal = c("DT.FROM","DT.TO"),
categorical = c("MO1", "MO2", "MO3")) # crime variables list
compareCrimes(pairs,crimes,varlist,binary=TRUE)