Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/projection_functions.R
This is a simple wrapper for the _C_ function of the same name
which performs population projection by the cohort component
method (see the documentation for ccmpp
). The _C_
function can be loaded for use in _C_ source code via
#include ccmppAPI
. The arguments are documented here for
both functions. Argument types for _C_ are given in parentheses in
the argument list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ccmpp_c(
out_pop_fem,
out_pop_male,
srb,
fert,
surv_fem,
surv_male,
surv_fem_0,
surv_male_0,
mig_fem,
mig_male,
bline_fem,
bline_male,
n_proj_steps,
n_age_pop,
step_wid
)
|
out_pop_fem |
( |
out_pop_male |
( |
srb |
( |
fert |
( |
surv_fem |
( |
surv_male |
( |
surv_fem_0 |
( |
surv_male_0 |
( |
mig_fem |
( |
mig_male |
( |
bline_fem |
( |
bline_male |
( |
n_proj_steps |
( |
n_age_pop |
( |
step_wid |
( |
The _C_ code is accessed via .C
hence all arguments
are passed via pointers. In particular, the first two arguments
are containers for the output. They must be vectors of length
n_age_pop
which can be coerced via
as.double
. The values of the elements are
unimportant as they will be overwritten with the output; e.g., you
could supply the same value to out_pop_fem
as
bline_fem
(and similarly for the male versions), as in the
example.
In R, a two-element list containig the first two
arguments with their (n_age_pop
+ 1), (n_age_pop
+ 2), ..., elements replaced with the projected counts for
females and males, respectiely. The _C_ function returns
nothing (void
) but has the side effect of similarly
replacing element in the first two arguments.
Mark C Wheldon
ccmpp
, a more friendly wrapper for
the same underlying _C_ function that takes arguments as R
lists and does some optional input checks.
Other CCMPP backend functions:
ccmpp_r()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | data("Thailand_demog")
raw <-
with(Thailand_demog, {
ccmpp_c(out_pop_fem = matrix(rep(thai_base_pop_counts$female, 9), ncol = 9),
out_pop_male = matrix(rep(thai_base_pop_counts$male, 9), ncol = 9),
srb = thai_srb,
fert = thai_fert_rates,
surv_fem = thai_surv_props$female[-1,],
surv_male = thai_surv_props$male[-1,],
surv_fem_0 = thai_surv_props$female[1,],
surv_male_0 = thai_surv_props$male[1,],
mig_fem = thai_mig_props$female,
mig_male = thai_mig_props$male,
bline_fem = thai_base_pop_counts$female,
bline_male = thai_base_pop_counts$male,
n_proj_steps = ncol(thai_fert_rates), #8
n_age_pop = nrow(thai_base_pop_counts$female), #17
step_wid = 5
)})
(nicer <- list(female = matrix(raw[[1]], ncol = 9),
male = matrix(raw[[2]], ncol = 9)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.