Learn R Programming

crimelinkage (version 0.0.4)

compareCrimes: Creates evidence variables by calculating ‘distance’ between crime pairs

Description

Calculates spatial and temporal distance, difference in categorical, and absolute value of numerical crime variables

Usage

compareCrimes(Pairs, crimedata, varlist, binary = TRUE, longlat = FALSE, show.pb = FALSE, ...)

Arguments

Pairs
(n x 2) matrix of crimeIDs
crimedata
data.frame of crime incident data. There must be a column named crimedata that refers to the crimeIDs given in Pairs. Other column names must correspond to what is given in varlist list.
varlist
a list with elements named: crimeID, spatial, temporal, categorical, and numerical. Each element should be a vector of the column names of crimedata corresponding to that feature:
  • crimeID: crime ID for the crimedata that is matched to Pairs
  • spatial: X,Y coordinates (in long,lat or Cartesian) of crimes
  • temporal: DT.FROM, DT.TO of crimes. If times are uncensored, then only DT.FROM needs to be provided.
  • categorical: (optional) categorical crime variables
  • numerical: (optional) numerical crime variables
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

Value

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.

References

Porter, M. D. (2014). A Statistical Approach to Crime Linkage. arXiv preprint arXiv:1410.2285.. http://arxiv.org/abs/1410.2285

Examples

Run this code
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)

Run the code above in your browser using DataLab