Learn R Programming

migest (version 2.0.4)

index_intensity: Summary indices of migration intensity

Description

Summary indices of migration intensity

Usage

index_intensity(mig_total = NULL, pop_total = NULL, n = NULL, long = TRUE)

Value

A tibble with 2 summary measures where

cmp

Crude migration probability from Bell et. al. (2002), sometimes known as crude migration intensity, e.g. Bernard (2017)

courgeau_k

Intensity measure of Courgeau (1973)

Arguments

mig_total

Numeric value for the total number of migrations.

pop_total

Numeric value for the total population.

n

Numeric value for the number of regions used in the definition of migration for mig_total.

long

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

Examples

Run this code
# single year
library(dplyr)
m <- korea_gravity %>%
  filter(year == 2020,
         orig != dest)
m
p <- korea_gravity %>%
  filter(year == 2020) %>%
  distinct(dest, dest_pop)
p
index_intensity(mig_total = sum(m$flow), pop_total = sum(p$dest_pop*1e6), n = nrow(p))

# multiple years
library(tidyr)
library(purrr) 
mm <- korea_gravity  %>%
 filter(orig != dest) %>%
  group_by(year) %>%
  summarise(m = sum(flow))
mm

pp <- korea_gravity %>%
  group_by(year) %>%
  distinct(dest, dest_pop) %>%
  summarise(p = sum(dest_pop)*1e6,
            n = n_distinct(dest))
pp

library(purrr)
library(tidyr)
mm %>%
  left_join(pp) %>%
  mutate(i = pmap(
    .l = list(m, p, n),
    .f = ~index_intensity(mig_total = ..1, pop_total = ..2,n = ..3, long = FALSE)
  )) %>%
  unnest(cols = i)

Run the code above in your browser using DataLab