Learn R Programming

bayesPop (version 2.0-2)

pop.aggregate: Aggregation of Population Projections

Description

Aggregation of existing countries' population projections into projections of given regions, and accessing such aggregations.

Usage

pop.aggregate(pop.pred, regions, 
    method = c('independence', 'regional'), name = method,
    inputs = list(e0F.sim.dir = NULL, e0M.sim.dir = "joint_", tfr.sim.dir = NULL), 
    verbose = FALSE)
    
get.pop.aggregation(sim.dir, name = NULL)

Arguments

pop.pred
Object of class bayesPop.prediction containing country-specific population projections.
regions
Vector of numerical codes of regions. It should correspond to values in the column area_code in the LOCATIONS dataset.
method
There are two methods for aggregating projections, independence and regional, see Details.
name
Name of the aggregation. It becomes a part of a directory name where aggregation results are stored.
inputs
This argument is only used when the regional method is selected. It is a list of inputs of probabilistic components of the projection: [object Object],[object Object],[object Object]
verbose
Logical switching log messages on and off.
sim.dir
Simulation directory where aggregation is stored. It is the same directory used for creating the pop.pred object.

Value

  • Object of class bayesPop.prediction containing the aggregated results. In addition it contains elements aggregation.method giving the method used, and aggregated.countries which is a list of countries aggregated for each region.

Details

The dataset LOCATIONS is used to determine countries to be aggregated, in particular the field location_type of the area given in the regions argument. There are three location types over which one can aggregate: Type 0 means aggregating all countries of the world, type 2 is aggregating over continents, and type 3 is aggregating over regions within continents. For type 2, countries are matched using the area_code column; for type 3 the matching is done using the reg_code column of the LOCATIONS dataset. There are two methods available for generating aggregations of population projection: [object Object],[object Object] Aggregations can be performed for any area/region given in the LOCATIONS table. Their identifiers correspond to the column area_code. In case of the regional method, the same codes must be also included in predictions of life expectancy and TFR.

Results of the aggregations are stored in the same top directory as the pop.pred object, in a sudirectory called aggregations_name. They can be accessed using the function get.pop.aggregation. Note that multiple runs of this function with the same name will overwrite previous aggregations results of the same name.

See Also

pop.predict, tfr.predict.extra, e0.predict.extra

Examples

Run this code
sim.dir <- tempfile()
pred <- pop.predict(countries=c(528,218,450), nr.traj = 10, output.dir=sim.dir)
aggr <- pop.aggregate(pred, 900) # aggregating World (i.e. all countries available in pred)
pop.trajectories.plot(aggr, 900, sum.over.ages=TRUE)
# countries over which we aggregated:
LOCATIONS[is.element(LOCATIONS[,'country_code'], aggr$aggregated.countries[['900']]),]
unlink(sim.dir, recursive=TRUE)

Run the code above in your browser using DataLab