index_distance: Summary indices of migration distance

Description Usage Arguments Value Source Examples

View source: R/index_distance.R

Description

Summary indices of migration distance

Usage

1
2
3
4
5
6
7
8
9
index_distance(
  m = NULL,
  d = NULL,
  orig_col = "orig",
  dest_col = "dest",
  flow_col = "flow",
  dist_col = "dist",
  long = TRUE
)

Arguments

m

A matrix or data frame of origin-destination flows. For matrix the first and second dimensions correspond to origin and destination respectively. For a data frame ensure the correct column names are passed to orig_col, dest_col and flow_col.

d

A matrix or data frame of origin-destination distances. For matrix the first and second dimensions correspond to origin and destination respectively. For a data frame ensure the correct column names are passed to orig_col, dest_col and dist_col. Region names should match those in 'm'.

orig_col

Character string of the origin column name (when m is a data frame rather than a matrix)

dest_col

Character string of the destination column name (when m is a data frame rather than a matrix)

flow_col

Character string of the flow column name (when m is a data frame rather than a matrix)

dist_col

Character string of the distance column name (when dist is a data frame rather than a matrix)

long

Logical to return a long data frame with index values all in one column

Value

A tibble with 3 summary measures where

mean

Mean migration distance from Bell et. al. (2002) - not discussed in text but given in Table 6

median

Mean migration distance from Bell et. al. (2002)

decay

Distance decay parameter obtained from a Poisson regression model ('flow ~ orig + dest + log(dist)')

Source

Bell, M., Blake, M., Boyle, P., Duke-Williams, O., Rees, P. H., Stillwell, J., & Hugo, G. J. (2002). Cross-national comparison of internal migration: issues and measures. Journal of the Royal Statistical Society: Series A (Statistics in Society), 165(3), 435–464. https://doi.org/10.1111/1467-985X.00247

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# single year
index_distance(
  m = subset(korea_reg, year == 2020), 
  d = korea_dist
)

library(dplyr)
library(tidyr)
library(purrr)
# multiple years
korea_reg %>%
  nest(m = c(orig, dest, flow)) %>%
  mutate(d = list(korea_dist)) %>%
  mutate(i = map2(.x = m, .y = d, 
                  .f = ~index_distance(m = .x, d = .y, long = FALSE))) %>%
  select(-m, -d) %>%
  unnest(i)

migest documentation built on July 25, 2021, 9:07 a.m.