Description Usage Arguments Value Examples
A cohort component projection model based on a closed population,
N(t+5) = L[t, t+1] ≤ft( N(t) + \frac{1}{2} M[t, t+1] \right) + \frac{1}{2} M[t, t+1]
where the Leslie matrix, eqnL, is created given user defined age specific fertility and survivorship rates.
1 2 3 4 5 6 7 8 9 | ccp_net0(n = NULL, x = NULL, p = NULL, Nx_f = NULL, Nx_m = NULL,
sx_f = NULL, sx_m = NULL, fx = NULL, sn_f = NULL, sn_m = NULL,
sex_ratio = 1/(1 + 1.05), Mx_f = NULL, Mx_m = NULL,
tidy_output = TRUE, age_lab = x, gender_lab = c("Female", "Male"), ...)
ccp_net(n = NULL, x = NULL, p = NULL, Nx_f = NULL, Nx_m = NULL,
sx_f = NULL, sx_m = NULL, fx = NULL, sn_f = NULL, sn_m = NULL,
sex_ratio = 1/(1 + 1.05), Mx_f = NULL, Mx_m = NULL,
tidy_output = TRUE, age_lab = x, gender_lab = c("Female", "Male"), ...)
|
n |
Numeric value for the number of projection steps. |
x |
Vector containing a character string of age group labels. |
p |
Numeric value for step size of the population projection. |
Nx_f, Nx_m |
Vectors containing numeric values of the initial female and male population size in each age group ( |
sx_f, sx_m, fx, Mx_f, Mx_m |
Vectors containing numeric values of the age specific female and male survival and fertility rates and female and male net migration counts. If If |
sn_f, sn_m, sex_ratio |
Numeric value of the female and male survivorship of new-born babies from birth to the end of the interval and the sex ratio at birth of new-born babies. If If |
tidy_output |
Logical value to indicate if projection output should be in a tidy data format ( |
age_lab, gender_lab |
Vector containing a character string of age and gender group labels. Only used if projection output is in a tidy data format. See |
... |
Additional arguments passed to |
Projected populations by age and gender for n
future steps, given the fertility and survivorship rates and net migration counts. Depending on the tidy_output
value the projections will be returned as either a matrix or a tibble. Both versions contain the initial population sizes given in Nx
.
ccp_net0
produces population projections based strictly on constant future rates.
ccp_net
produces population projections based non-constant future rates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | library(dplyr)
df0 <- sweden1993 %>%
# set male net migration to the same as female
mutate(Mx_m = Mx_f)
# matrix output
ccp_net0(n = 5, x = df0$x, p = 5,Nx_f = df0$Nx_f, Nx_m = df0$Nx_m,
sx_f = df0$sx_f, sx_m = df0$sx_m,
fx = df0$fx, sn_f = df0$Lx_f[1]/(5*100000), sn_m = df0$Lx_m[1]/(5*100000),
Mx_f = df0$Mx_f, Mx_m = df0$Mx_m,
tidy_output = FALSE)
# tidy data frame output
ccp_net0(n = 5, x = df0$x, p = 5,Nx_f = df0$Nx_f, Nx_m = df0$Nx_m,
sx_f = df0$sx_f, sx_m = df0$sx_m,
fx = df0$fx, sn_f = df0$Lx_f[1]/(5*100000), sn_m = df0$Lx_m[1]/(5*100000),
Mx_f = df0$Mx_f, Mx_m = df0$Mx_m,
year0 = 1993, age_lab = df0$age)
# setting up non-constant future male net migrant counts
MM <- matrix(df0$Mx_m, nrow = length(df0$Mx_m), ncol = 5)
MM <- sweep(MM, 2, seq(from = 1, to = 1.5, length = 5), "*")
# net migration increase
colSums(MM)
# run projection with increasing net migration, fx and sx remains constant
ccp_net(n = 5, x = df0$x, p = 5, Nx_f = df0$Nx_f, Nx_m = df0$Nx_m,
sx_f = df0$sx_f, sx_m = df0$sx_m,
fx = df0$fx, sn_f = df0$Lx_f[1]/(5*100000), sn_m = df0$Lx_m[1]/(5*100000),
Mx_f = df0$Mx_f, Mx_m = MM,
tidy_output = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.