pop.predict.subnat {bayesPop} | R Documentation |
Subnational Probabilistic Population Projection
Description
Generates trajectories of probabilistic population projection for subregions of a given country.
Usage
pop.predict.subnat(end.year = 2060, start.year = 1950, present.year = 2020,
wpp.year = 2019, output.dir = file.path(getwd(), "bayesPop.output"),
locations = NULL, default.country = NULL, annual = FALSE,
inputs = list(
popM = NULL, popF = NULL,
mxM = NULL, mxF = NULL, srb = NULL,
pasfr = NULL, patterns = NULL,
migM = NULL, migF = NULL,
migMt = NULL, migFt = NULL, mig = NULL,
e0F.file = NULL, e0M.file = NULL, tfr.file = NULL,
e0F.sim.dir = NULL, e0M.sim.dir = NULL, tfr.sim.dir = NULL,
migMtraj = NULL, migFtraj = NULL, migtraj = NULL,
GQpopM = NULL, GQpopF = NULL, average.annual = NULL
),
nr.traj = 1000, keep.vital.events = FALSE,
fixed.mx = FALSE, fixed.pasfr = FALSE, lc.for.all = TRUE,
mig.is.rate = FALSE, replace.output = FALSE, verbose = TRUE)
Arguments
end.year |
End year of the projection. |
start.year |
First year of the historical data on mortality rates. It determines the length of the historical time series used in the Lee-Carter estimation. |
present.year |
Year for which initial population data is to be used. |
wpp.year |
Year for which WPP data is used. The function loads a package called wpp |
output.dir |
Output directory of the projection. |
locations |
Name of a tab-delimited file that contains definitions of the subregions. It has a similar structure as |
default.country |
Numerical code of a country to which the subregions belong to. It is used for extracting default datasets from the wpp package if some region-specific input datasets are missing. Alternatively, it can be also included in the |
annual |
Logical. If |
inputs |
A list of file names where input data is stored. Unless otherwise noted, these are tab delimited ASCII files with a mandatory column
|
nr.traj , keep.vital.events , fixed.mx , fixed.pasfr , lc.for.all , mig.is.rate , replace.output , verbose |
These arguments have the same meaning as in |
Details
Population projection for subnational units (regions) is performed by applying the cohort component method to subnational datasets on projected fertility (TFR), mortality and net migration, starting from given sex- and age-specific population counts. The only required inputs are the initial sex- and age-specific population counts in each region (popM
and popF
elements of the inputs
argument) and a file with a set of locations (argument locations
). If no other input datasets are given, those datasets are replaced by the corresponding "national" values, taken from the corresponding wpp package. The argument default.country
determines the country for those default "national" values. The default country can be also included in the locations
file as a record with location.type
being set to 0.
The TFR component can be given as a set of trajectories generated using the tfr.predict.subnat
function of the bayesTFR package (tfr.sim.dir
element). Alternatively, trajectories can be given in an ASCII file (tfr.file
).
Similarly, the $e_0$ component can be given as a set of trajectories using the e0.predict.subnat
function of the bayesLife package (e0F.sim.dir
element). If male projections are generated jointly (i.e. predict.jmale = TRUE
), set e0M.sim.dir = "joint_"
. Alternatively, trajectories can be given in an ASCII files (e0F.file
, e0M.file
).
Having a set of subnational TFR and $e_0$ trajectories, the cohort component method is applied to each of them to yield a distribution of future subnational population.
Projection of net migration can either be given as disaggregated sex- and age-specific datasets (migM
and migF
), or as sex totals (migMt
and migFt
), or as totals (mig
), or as sex- and age-specific trajectories (migMtraj
and migFtraj
), or as total trajectories (migtraj
). Alternatively, it can be given as shares between regions as columns in the patterns
dataset. These are: inmigrationM_share
, inmigrationF_share
, outmigrationM_share
, outmigrationF_share
. The sex specification and/or direction specification (in/out) can be omitted, e.g. it can be simply migration_share
. The function extracts the values of net migration projection on the national level and distributes it to regions according to the given shares. For positive (national) values, it uses the in-migration shares; for negative values it uses the out-migration shares. If the in/out prefix is omitted in the column names, the given migartion shares are used for both, positive and negative net migration projection. By default, if no migration datasets neither region-specific shares are given, the distribution between regions is proportional to the size of population. The age-specific schedules follow by default the Rogers-Castro age schedules. Note that when handling migration using shares as described here, it only affects the distribution of international migration into regions. It does not take into account between-region migration.
The package contains example datasets for Canada. Use these as templates for your own data. See Example below.
Value
Object of class bayesPop.prediction
containing the subnational projections. Note that this object can be used in the various bayesPop functions exactly the same way as an object with national projections. However, the meaning of the argument country
in many of these functions (e.g. in pop.trajectories.plot
) changes to an identification of the region (either as a numerical code or name as defined in the locations
file).
Acknowledgment
We are greatful to Patrice Dion from Statistics Canada for providing us with example data. Note that the example datasets included in the package are not official STATCAN data - they only serve the purpose of illustration and templates. Data for the time period 2015-2020 has been imputed by the author.
Author(s)
Hana Sevcikova
See Also
pop.predict
, tfr.predict.subnat
, pop.aggregate.subnat
Examples
## Not run:
# Subnational projections for Canada
#########
data.dir <- file.path(find.package("bayesPop"), "extdata")
# Use national data for tfr and e0
###
sim.dir <- tempfile()
pred <- pop.predict.subnat(output.dir = sim.dir,
locations = file.path(data.dir, "CANlocations.txt"),
inputs = list(popM = file.path(data.dir, "CANpopM.txt"),
popF = file.path(data.dir, "CANpopF.txt"),
tfr.file = "median_"
),
verbose = TRUE)
pop.trajectories.plot(pred, "Alberta", sum.over.ages = TRUE)
unlink(sim.dir, recursive=TRUE)
# Use subnational probabilistic TFR simulation
###
# Subnational TFR projections for Canada (from ?tfr.predict.subnat)
my.subtfr.file <- file.path(find.package("bayesTFR"), 'extdata', 'subnational_tfr_template.txt')
tfr.nat.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
tfr.reg.dir <- tempfile()
tfr.preds <- tfr.predict.subnat(124, my.tfr.file = my.subtfr.file,
sim.dir = tfr.nat.dir, output.dir = tfr.reg.dir, start.year = 2013)
# Use subnational probabilistic e0
###
# Subnational e0 projections for Canada (from ?e0.predict.subnat)
# (here using the same female and male data, just for illustration)
my.sube0.file <- file.path(find.package("bayesLife"), 'extdata', 'subnational_e0_template.txt')
e0.nat.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
e0.reg.dir <- tempfile()
e0.preds <- e0.predict.subnat(124, my.e0.file = my.sube0.file,
sim.dir = e0.nat.dir, output.dir = e0.reg.dir, start.year = 2018,
predict.jmale = TRUE, my.e0M.file = my.sube0.file)
# Population projections
sim.dir <- tempfile()
pred <- pop.predict.subnat(output.dir = sim.dir,
locations = file.path(data.dir, "CANlocations.txt"),
inputs = list(popM = file.path(data.dir, "CANpopM.txt"),
popF = file.path(data.dir, "CANpopF.txt"),
patterns = file.path(data.dir, "CANpatterns.txt"),
tfr.sim.dir = file.path(tfr.reg.dir, "subnat", "c124"),
e0F.sim.dir = file.path(e0.reg.dir, "subnat_ar1", "c124"),
e0M.sim.dir = "joint_"
),
verbose = TRUE)
pop.trajectories.plot(pred, "Alberta", sum.over.ages = TRUE)
pop.pyramid(pred, "Manitoba", year = 2050)
get.countries.table(pred)
# Aggregate to country level
aggr <- pop.aggregate.subnat(pred, regions = 124,
locations = file.path(data.dir, "CANlocations.txt"))
pop.trajectories.plot(aggr, "Canada", sum.over.ages = TRUE)
unlink(sim.dir, recursive = TRUE)
unlink(tfr.reg.dir, recursive = TRUE)
unlink(e0.reg.dir, recursive = TRUE)
## End(Not run)