Skip to contents

Displaces point locations by bounded random noise and reports how much the spatial signal moved. Each point is shifted to a uniformly random location inside a disc of radius r centred on it. Uniformity over the disc requires the radial draw rho = r sqrt(u1) with theta = 2 pi u2 for independent uniforms u1, u2 – taking rho = r u1 would over-concentrate points near the centre, which is exactly the failure mode that makes a mask look stronger than it is. The displaced point is (x + rho cos(theta), y + rho sin(theta)).

Usage

Sdcdis(coords, noise_radius, seed = 1)

Arguments

coords

Point coordinates, n rows by 2 columns (x, y).

noise_radius

Maximum displacement r, non-negative.

seed

Seed for the shared minstd stream. Default 1.

Value

List with estimate (mean realised displacement), masked, displacement, mean_displacement, max_displacement, rms_displacement, expected_displacement, expected_rms, centre_shift, mean_pairwise_before, mean_pairwise_after, mean_pairwise_change, noise_radius, n, seed, method.

Details

Under this mask E[rho] = 2 r / 3 and E[rho^2] = r^2 / 2, so both the mean and the RMS displacement have closed forms the sample values can be checked against; they are returned as expected_displacement and expected_rms.

The mask preserves the mean centre in expectation but not exactly; the realised shift of the mean centre is reported, as is the change in mean pairwise distance, the quantity most spatial analyses actually depend on. Allshouse et al. evaluate exactly this trade-off between re-identification risk and analytic distortion.

The uniform stream is the Lehmer minstd generator shared with every other arm of this package, so a given seed reproduces the same mask in R and in Python bit for bit.

References

Allshouse, W. B., Fitch, M. K., Hampton, K. H., Gesink, D. C., Doherty, I. A., Leone, P. A., Serre, M. L. & Miller, W. C. (2010). Geomasking sensitive health data and privacy protection: an evaluation using an E911 database. Geocarto International 25(6), 443-452. doi:10.1080/10106049.2010.496496

Examples

set.seed(1)
Sdcdis(matrix(runif(20), 10, 2), noise_radius = 0.1)
#> $estimate
#> [1] 0.06614535
#> 
#> $masked
#>            [,1]      [,2]
#>  [1,] 0.2659167 0.2062160
#>  [2,] 0.4323722 0.1277339
#>  [3,] 0.6092494 0.7784279
#>  [4,] 0.8506836 0.4270074
#>  [5,] 0.1995924 0.7186096
#>  [6,] 0.8705936 0.4866152
#>  [7,] 0.9725714 0.6465966
#>  [8,] 0.5840698 0.9862493
#>  [9,] 0.7226981 0.3771439
#> [10,] 0.1451359 0.7596984
#> 
#> $displacement
#>  [1] 0.000474109 0.077546928 0.098384740 0.071761816 0.051274376 0.029924533
#>  [7] 0.076303977 0.076936258 0.093628730 0.085218058
#> 
#> $mean_displacement
#> [1] 0.06614535
#> 
#> $max_displacement
#> [1] 0.09838474
#> 
#> $rms_displacement
#> [1] 0.07220633
#> 
#> $expected_displacement
#> [1] 0.06666667
#> 
#> $expected_rms
#> [1] 0.07071068
#> 
#> $centre_shift
#> [1] 0.01563187
#> 
#> $mean_pairwise_before
#> [1] 0.5460864
#> 
#> $mean_pairwise_after
#> [1] 0.5256255
#> 
#> $mean_pairwise_change
#> [1] -0.02046092
#> 
#> $noise_radius
#> [1] 0.1
#> 
#> $n
#> [1] 10
#> 
#> $seed
#> [1] 1
#> 
#> $method
#> [1] "Geomasking by uniform displacement within a disc (Allshouse et al. 2010)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"