Example 7.19: find the closest pair of observations

December 28, 2009

Suppose we need to find the closest pair of observations on some variable x. For example, we might be concerned that some data had been accidentally duplicated. We return the ID’s of the two closest observations, and their distance from each other. In both languages, we’ll first create the data, then sort it, recognizing that the smallest difference must come between two adjacent observations,

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , ,

Comments are closed.