*! version 1.3 16Nov2015 James J Feigenbaum
help jarowinkler

Title

jarowinkler -- Calculate the Jaro-Winkler distance between two string variables.

Syntax

jarowinkler
1
2
[, generate(newvar) jaroonly(newvar) pwinkler(x) ]

Description

jarowinkler calculates the distance between two string variables using the Jaro-Winkler distance metric. The distance metric is often used in record linkage to compare first or last names in different sources.
Jaro-Winkler modifies the standard Jaro distance metric by putting extra weight on string differences at the start of the strings to be compared. The metric is scaled between 0 (not similar at all) and 1 (exact match).

jarowinkler accepts two arguments, both of which must be string variables. Cases are standardized within the algorithm.

The distance is returned as a new variable with default name jarowinkler.

For more detail on the Jaro-Winkler method, see http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance and http://www.gabormelli.com/RKB/Jaro-Winkler_Distance_Function.
Jaro-Winkler implementation based on code from http://cs.anu.edu.au/~Peter.Christen/Febrl/febrl-0.4.01/stringcmp.py and https://github.com/miguelvps/c/blob/master/jarowinkler.c.

Options

generate(newvar) Create a new variable named newvar containing the Jaro-Winkler distance. If the generate() option is not used, a new variable will be created with default name jarowinkler.

jaroonly(newvar) Create a new variable named newvar containing the Jaro distance. If the jaroonly() option is not used, nothing will be created.

pwinkler(x) A constant scaling factor for how much the score is adjusted upwards for having common prefixes. p should not exceed 0.25, otherwise the distance can become larger than 1. The default value is Winkler's standard value of 0.1.

Examples

. sysuse census, clear

. jarowinkler state state2 , gen(dist_jw)

. sysuse census, clear

. jarowinkler state state2 , gen(dist_jw) jaroonly(dist_jaro)

. jarowinkler state state2 , gen(dist_jw2) pwinkler(0.2)

Saved results

jarowinkler saves the following in r():

Macros

r(jarowinkler) name of new Jaro Winkler string difference variable if created

r(jaroonly) name of new Jaro string difference variable if created

Acknowledgements

My thanks to a number of people for suggestions and bug-catching. Thanks to Adrian Sayers for suggesting the inclusion of Jaro distances and allowing the Jaro-Winkler scaling factor to vary. Thanks to Martin Goossen for alerting me to an error in the Stata 12 version of the code. Thanks to Alex Fouirnaies and Bruno Caprettini for alerting me to an issue in the calculation of distance for strings with no common characters. Thanks to Jacob Bor for alerting me to an issue when comparing single character strings.

Author

James Feigenbaum

Harvard University

jfeigenb@fas.harvard.edu

http://scholar.harvard.edu/jfeigenbaum

Also see

strdist,
soundex