Learn R Programming

bayesPop (version 5.2-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, 
    input.type = c('country', 'region'), name = input.type,
    inputs = list(e0F.sim.dir = NULL, e0M.sim.dir = "joint_", tfr.sim.dir = NULL), 
    my.location.file = NULL, verbose = FALSE, ...)
    
get.pop.aggregation(sim.dir = NULL, pop.pred = NULL, name = NULL, write.to.cache = TRUE)

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 country_code in the UNlocations dataset or in my.location.file (see below).
input.type
There are two methods for aggregating projections depending on the type of inputs, country- and region-based, 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 region-based method is selected. It is a list of inputs of probabilistic components of the projection: [object Object],[object Object],[object Object]
my.location.file
User-defined location file that can contain other agreggation groups than the default UN location file. It should have the same structure as the UNlocations dataset, see below.
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. Alternatively, pop.pred can be used. Either sim.dir or pop.pred must be given.
write.to.cache
Logical controlling if other functions are allowed to write the cache of this prediction object (see Details of get.pop.prediction).
...
Additional arguments.

Value

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

code

get.pop.aggregation

tabular

rlrrr

tab

name location_type agcode_98 agcode_99 1001 groupping1_groupA 98 -1 -1 1002 groupping1_groupB 98 -1 -1 1003 groupping2_groupA 99 -1 -1 1004 groupping2_groupB 99 -1 -1 276 Germany 4 1001 1003 250 France 4 1001 1004 258 Netherlands 4 1002 1003 380 Italy 4 1002 1004 1005 all 0 -1 -1

dQuote

  • country_code
  • country_code
  • location_type
  • agcode_98
  • agcode_99
  • location_type
  • location_type

sQuote

aggregations_name

Details

The dataset UNlocations or my.location.file is used to determine countries to be aggregated, in particular the field location_type of the entries with country_code given in the regions argument. One can aggregate over the following location types: Type 0 means aggregating all countries of the world (or in the file), type 2 is aggregating over continents, type 3 is aggregating over regions within continents, and any other integer (except 4) correponds to user-defined aggregations. Note that type 4 is reserved as a location type of countries and thus, all aggregations are performed over entries of this type. 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 UNlocations dataset. E.g., if regions=908 (Europe) which has location type 2 in the default UNlocations dataset, all countries are aggregated for which values of 908 are found in the area_code column. If the location type is other than 0, 2, 3 and 4, there must be a column in the file called agcode_$x$ with $x$ being the location type. This column is then used to match the countries to be aggregated.

Consider the following example. Say we want to pair four countries (Germany [DE], France [FR], Netherlands [NL], Italy [IT]) in two different ways, so we have two overlapping grouppings, each of which has two groups (A,B):

  1. group A = (DE, FR), group B = (NL, IT)
group A = (DE, NL), group B = (FR, IT)

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), 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:
UNlocations[is.element(UNlocations[,'country_code'], aggr$aggregated.countries[['900']]),]
unlink(sim.dir, recursive=TRUE)

Run the code above in your browser using DataLab