mig_resid | R Documentation |
Estimate net migration using residual methods: stock change, time even flow and cohort even flow
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
)
pop_m_mat |
A |
pop_f_mat |
A |
sr_m_mat |
A |
sr_f_mat |
A |
asfr_mat |
A |
srb_vec |
A |
ages |
A |
ages_asfr |
A |
years_pop |
Years used in the column names of population. If
|
years_sr |
Years used in the column names of survival rates. If
|
years_asfr |
Years used in the column names of age-specific fertility
rate. If |
years_srb |
Years used in the column names of sex-ratio at birth. If
|
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 |
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.
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.
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.
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.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.