This vignette introduces some of the most common measures of some basic measures of the distance between plans. This offers a quick look at how similar or different a pair of plans are. See the vignette “Using `redistmetrics`

” for the bare-bones of the package.

We first load the `redistmetrics`

package and data from New Hampshire. For any function, the `shp`

argument can be swapped out for your data, `pop`

for your population, and the `plans`

argument can be swapped out for your redistricting plans (be it a single plan, a matrix of plans, or a `redist_plans`

object).

```
library(redistmetrics)
data(nh)
```

Note that, when computing distance between plans, you always want to provide more than one plan. For that reason, we will also load `nh_m`

, a matrix of plans for New Hampshire.

```
data(nh_m)
<- nh_m[, 1:4] nh_m
```

We subset it to its first four columns (the first four plans).

The recommended distance between plans is the variation of information. This considers the distance between plans by looking at the joint distributions of people across plans.

The Variation of Information can be computed with:

```
dist_info(plans = nh_m, shp = nh, total_pop = pop)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.000000 1.170495 1.381331 1.241767
#> [2,] 1.170495 0.000000 1.250428 1.339492
#> [3,] 1.381331 1.250428 0.000000 1.211885
#> [4,] 1.241767 1.339492 1.211885 0.000000
```

The Hamming distance is a simpler metric which just considers how many units are assigned to different districts between pairs of plans.

The Hamming distance can be computed with:

```
dist_ham(plans = nh_m)
#> [,1] [,2] [,3] [,4]
#> [1,] 0 76 190 211
#> [2,] 76 0 240 177
#> [3,] 190 240 0 233
#> [4,] 211 177 233 0
```

The Manhattan distance measures how many “blocks” you would need to move to get between plans. This is most useful in MCMC contexts, rather than general contexts.

The Manhattan distance can be computed with:

```
dist_man(plans = nh_m)
#> [,1] [,2] [,3] [,4]
#> [1,] 0 76 190 211
#> [2,] 76 0 240 177
#> [3,] 190 240 0 233
#> [4,] 211 177 233 0
```

The Euclidean distance measures the square root of the summed distances you would need to move to get between plans. This is most useful in MCMC contexts, rather than general contexts.

The Euclidean distance can be computed with:

```
dist_euc(plans = nh_m)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.000000 8.717798 13.78405 14.52584
#> [2,] 8.717798 0.000000 15.49193 13.30413
#> [3,] 13.784049 15.491933 0.00000 15.26434
#> [4,] 14.525839 13.304135 15.26434 0.00000
```