mig_resid: Estimate net migration using residual methods: stock change,...

View source: R/mig_resid.R

mig_residR Documentation

Estimate net migration using residual methods: stock change, time even flow and cohort even flow

Description

Estimate net migration using residual methods: stock change, time even flow and cohort even flow

Usage

mig_resid(
  pop_m_mat,
  pop_f_mat,
  sr_m_mat,
  sr_f_mat,
  asfr_mat,
  srb_vec,
  ages = NULL,
  ages_asfr = NULL,
  years_pop = NULL,
  years_sr = NULL,
  years_asfr = NULL,
  years_srb = NULL,
  verbose = TRUE,
  method = c("stock", "cohort", "time")
)

mig_resid_stock(
  pop_m_mat,
  pop_f_mat,
  sr_m_mat,
  sr_f_mat,
  asfr_mat,
  srb_vec,
  ages = NULL,
  ages_asfr = NULL,
  years_pop = NULL,
  years_sr = NULL,
  years_asfr = NULL,
  years_srb = NULL,
  verbose = TRUE
)

mig_resid_cohort(
  pop_m_mat,
  pop_f_mat,
  sr_m_mat,
  sr_f_mat,
  asfr_mat,
  srb_vec,
  ages = NULL,
  ages_asfr = NULL,
  years_pop = NULL,
  years_sr = NULL,
  years_asfr = NULL,
  years_srb = NULL,
  verbose = TRUE
)

mig_resid_time(
  pop_m_mat,
  pop_f_mat,
  sr_m_mat,
  sr_f_mat,
  asfr_mat,
  srb_vec,
  ages = NULL,
  ages_asfr = NULL,
  years_pop = NULL,
  years_sr = NULL,
  years_asfr = NULL,
  years_srb = NULL,
  verbose = TRUE
)

Arguments

pop_m_mat

A numeric matrix with population counts. Rows should be ages and columns should be years. Only five year age groups are supported. See examples.

pop_f_mat

A numeric matrix with population counts. Rows should be ages and columns should be years. Only five year age groups are supported. See examples.

sr_m_mat

A numeric matrix with survival rates for males. Rows should be ages and columns should be years. ** This matrix should have one column less than pop_m_mat and pop_f_mat. For example, if the last year in these matrices is 2050, then the last year in sr_m_mat should be 2045. **

sr_f_mat

A numeric matrix with survival rates for females. Rows should be ages and columns should be years. ** This matrix should have one column less than pop_m_mat and pop_f_mat. For example, if the last year in these matrices is 2050, then the last year in sr_f_mat should be 2045. **.

asfr_mat

A numeric matrix with age specific fertility rates. Rows should be ages and columns should be years. ** This matrix should have one column less than pop_m_mat and pop_f_mat. For example, if the last year in these matrices is 2050, then the last year in asfr_mat should be 2045**. This row will usually have fewer age groups (rows) than in the population matrices or survival matrices, so the user needs to supply the specific ages in the ages_asfr argument.

srb_vec

A numeric vector of sex ratios at birth for every year. The years should be the same as the years in sr_m_mat, sr_f_mat, and asfr_mat.

ages

A numeric vector of ages used in the rows in pop_m_mat, pop_f_mat, sr_m_mat, sr_f_mat.

ages_asfr

A numeric vector of ages used in the rows in asfr_mat.

years_pop

Years used in the column names of population. If pop_m_mat or pop_f_mat doesn't have column names, these names are used. Otherwise ignored.

years_sr

Years used in the column names of survival rates. If sr_r_mat doesn't have column names, these names are used. Otherwise ignored.

years_asfr

Years used in the column names of age-specific fertility rate. If asfr_r_mat doesn't have column names, these names are used. Otherwise ignored.

years_srb

Years used in the column names of sex-ratio at birth. If srb_r_mat is not named, these names are used. Otherwise ignored.

verbose

Default set to TRUE. If TRUE, the function prints important operations carried out in the function like if years were trimmed from the data.

method

which residual migration method to use. This only works when using mig_resid and the possible options are 'stock', 'cohort' and 'time', with 'stock' being the default.

Details

  1. The stock method (mig_resid_stock) is the difference in stocks that survive between t and t+5, and the first age group is based on the difference with the surviving births by sex. It provides net migrants by lexis cohort parallelograms, and basically such info gets used as end-period migration since the migrants don't get exposed to mortality within the period.

  2. The time even flow (mig_resid_time) method uses the result from the first option, but splits it back into lexis period squares and assumes that half of the net migrants get exposed to the mortality risk during this period. Such info can get used as evenly distributed migration by period, but the assumptions lead to zig-zag age patterns that are highly implausible.

  3. The cohort even flow (mig_resid_cohort) method provides the most meaningful pattern of net migration by age consistent by cohort and assumes an evenly distribution within the 5-year period, and half of the migrants get exposed both fertility and mortality within this period.

mig_resid is a general function able to call the three methods only by specifying the method argument. By default it is set to the stock method. See the examples section.

Value

A list with two matrices. One is for males (called mig_m) and the other for females (called mig_f). Both matrices contain net migration estimates by age/period using one of the three methods.

Examples


library(DemoTools)

# The data is loaded with DemoTools

################ Stock change method #####################

# Generic mig_resid method which allows to choose either stock,
# cohort or time method for five year ages groups

mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_five,
   pop_f_mat = pop_f_mat_five,
   sr_m_mat = sr_m_mat_five,
   sr_f_mat = sr_f_mat_five,
   asfr_mat = asfr_mat_five,
   srb_vec = srb_vec_five,
   ages = ages_five,
   ages_asfr = ages_asfr_five,
   # With the stock method
   method = "stock"
 )

# For single ages

mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_single,
   pop_f_mat = pop_f_mat_single,
   sr_m_mat = sr_m_mat_single,
   sr_f_mat = sr_f_mat_single,
   asfr_mat = asfr_mat_single,
   srb_vec = srb_vec_single,
   ages = ages_single,
   ages_asfr = ages_asfr_single,
   # With the stock method
   method = "stock"
 )

# Or directly the mid_resid_stock function
# (works for both single and five year age groups)

mig_res <-
 mig_resid_stock(
   pop_m_mat = pop_m_mat_five,
   pop_f_mat = pop_f_mat_five,
   sr_m_mat = sr_m_mat_five,
   sr_f_mat = sr_f_mat_five,
   asfr_mat = asfr_mat_five,
   srb_vec = srb_vec_five,
   ages = ages_five,
   ages_asfr = ages_asfr_five
 )

# Net migration for males using stock change method
mig_res$mig_m

# Net migration for females using stock change method
mig_res$mig_f


################ cohort even flow method  #####################

# We reuse the same data from before
# Either use the generic mig_resid choosing 'cohort'

# Five year age groups
mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_five,
   pop_f_mat = pop_f_mat_five,
   sr_m_mat = sr_m_mat_five,
   sr_f_mat = sr_f_mat_five,
   asfr_mat = asfr_mat_five,
   srb_vec = srb_vec_five,
   ages = ages_five,
   ages_asfr = ages_asfr_five,
   # With the cohort method
   method = "cohort"
 )

# Single ages
mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_single,
   pop_f_mat = pop_f_mat_single,
   sr_m_mat = sr_m_mat_single,
   sr_f_mat = sr_f_mat_single,
   asfr_mat = asfr_mat_single,
   srb_vec = srb_vec_single,
   ages = ages_single,
   ages_asfr = ages_asfr_single,
   # With the stock method
   method = "cohort"
 )

# Or directly the mid_resid_cohort function

mig_res <-
  mig_resid_cohort(
    pop_m_mat = pop_m_mat_five,
    pop_f_mat = pop_f_mat_five,
    sr_m_mat = sr_m_mat_five,
    sr_f_mat = sr_f_mat_five,
    asfr_mat = asfr_mat_five,
    srb_vec = srb_vec_five,
    ages = ages_five,
    ages_asfr = ages_asfr_five
  )

# Net migration for males using the cohort even flow method
mig_res$mig_m

# Net migration for females using the cohort even flow method
mig_res$mig_f

################ time even flow method  #####################

# We reuse the same data from before
# Either use the generic mig_resid with the 'time' method

# For five year age groups
mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_five,
   pop_f_mat = pop_f_mat_five,
   sr_m_mat = sr_m_mat_five,
   sr_f_mat = sr_f_mat_five,
   asfr_mat = asfr_mat_five,
   srb_vec = srb_vec_five,
   ages = ages_five,
   ages_asfr = ages_asfr_five,
   # With the time method
   method = "time"
 )

# For single ages
mig_res <-
 mig_resid(
   pop_m_mat = pop_m_mat_single,
   pop_f_mat = pop_f_mat_single,
   sr_m_mat = sr_m_mat_single,
   sr_f_mat = sr_f_mat_single,
   asfr_mat = asfr_mat_single,
   srb_vec = srb_vec_single,
   ages = ages_single,
   ages_asfr = ages_asfr_single,
   # With the stock method
   method = "stock"
 )

# Or directly the mid_resid_time function
# (works for both five and single year ages)

mig_res <-
  mig_resid_time(
    pop_m_mat = pop_m_mat_five,
    pop_f_mat = pop_f_mat_five,
    sr_m_mat = sr_m_mat_five,
    sr_f_mat = sr_f_mat_five,
    asfr_mat = asfr_mat_five,
    srb_vec = srb_vec_five,
    ages = ages_five,
    ages_asfr = ages_asfr_five
  )

# Net migration for males using the time even flow method
mig_res$mig_m

# Net migration for females using the time even flow method
mig_res$mig_f


timriffe/DemoTools documentation built on Oct. 14, 2024, 12:53 p.m.