Learn R Programming

bayesPop (version 4.2-2)

pop.predict: Probabilistic Population Projection

Description

The function generates trajectories of probabilistic population projection for all countries for which input data is available, or any subset of them.

Usage

pop.predict(end.year = 2100, start.year = 1950, present.year = 2010, 
    wpp.year = 2012, countries = NULL, 
    output.dir = file.path(getwd(), "bayesPop.output"),
    inputs = list(popM=NULL, popF=NULL, mxM=NULL, mxF=NULL, srb=NULL,
        pasfr=NULL, mig.type=NULL, migM=NULL, migF=NULL,
        e0F.file=NULL, e0M.file=NULL, tfr.file=NULL,
        e0F.sim.dir=NULL, e0M.sim.dir=NULL, tfr.sim.dir=NULL), 
    nr.traj = 1000, keep.vital.events = FALSE, 
    replace.output = FALSE, verbose = TRUE)

Arguments

end.year
End year of the projection.
start.year
First year of the historical data.
present.year
Year for which initial population data is to be used.
wpp.year
Year for which WPP data is used. The functions loads a package called wpp$x$ where $x$ is the wpp.year and uses the various datasets as default if the corresponding inputs element is missing (see below).
countries
Array of country codes or country names for which a projection is generated. If it is NULL, all available countries are used. If it is NA and there is an existing projection in output.dir and replace.output=FAL
output.dir
Output directory of the projection. If there is an existing projection in output.dir and replace.output=TRUE, everything in the directory will be deleted.
inputs
A list of file names where input data is stored. It contains the following elements (Unless otherwise noted, these are tab delimited ASCII files; Names of default datasets from the corresponding wpp package which are used if the corresponding e
nr.traj
Number of trajectories to be generated. If any of the simulations in e0M.file/e0M.sim.dir, e0F.file/e0F.sim.dir and tfr.file/tfr.sim.dir contains less trajectories than nr.traj, the number is set to the
keep.vital.events
Logical. If TRUE age- and sex-specific vital events of births and deaths are stored in the prediction object.
replace.output
Logical. If TRUE, everything in the directory output.dir is deleted prior to the prediction.
verbose
Logical controlling the amount of output messages.

Value

  • Object of class bayesPop.prediction with the following elements:
  • output.directoryFull path to the projections.
  • nr.trajThe actual number of trajectories of the projections.
  • quantilesThree-dimensional array of projection quantiles (countries x number of quantiles x projection periods). The second dimension corresponds to the following quantiles: $0,0.025,0.05,0.1,0.2,0.25,0.3,0.4,0.5,0.6,0.7,0.75,0.8,0.9,0.95,0.975,1$.
  • traj.mean.sdThree-dimensional array of projection mean and standard deviation (countries x 2 x projection periods). First and second matrix of the second dimension, respectively, is the mean and standard deviation, respectively.
  • quantilesM, quantilesFQuantiles of male and female projection, respectively. Same structure as quantiles.
  • traj.mean.sdM, traj.mean.sdFSame as traj.mean.sd corresponding to male and female projection, respectively.
  • quantilesMage, quantilesFageFour-dimensional array of age-specific quantiles of male and female projection, respectively (countries x age groups x number of quantiles x projection periods). The same quantiles are used as in quantiles.
  • quantilesPropMage, quantilesPropFageArray of age-specific quantiles of male and female projection, respectively, divided by the total population. The dimensions are the same as in quantilesMage.
  • estim.yearsVector of time for which historical data was used in the projections.
  • proj.yearsVector of projection time periods starting with the present period.
  • wpp.yearThe wpp year used.
  • inputsList of input data used for the projection.
  • countriesMatrix of countries for which projection exists. It contains two columns: code, name.
  • agesVector of age groups.
  • cacheThis component is added by get.pop.prediction and modified and used by pop.map and write.pop.projection.summary. It is an environment for caching and re-using results of expressions.

Details

The population projection is computed using the Cohort Component method and is based on an algorithm used by the United Nation Population Division. For each country, one projection is calculated for each trajectory of male and female life expectancy and TFR. This results in a set of trajectories of population projection which forms its posterior distribution. The trajectories of life expectancy and TFR can be given either in its binary form generated by the packages bayesLife and bayesTFR, respectively (as directories e0M.sim.dir, e0F.sim.dir, tfr.sim.dir of the inputs argument), or they can be given as ASCII tables in csv format, see above.

The projection is generated sequentially country by country. Results are stored in a sub-directory of output.dir called prediction. There is one binary file per country, called totpop_country$x$.rda, where $x$ is the country code. It contains six objects: totp, totpf, totpm (trajectories of total population, age-specific female and age-specific male, respectively), totp.hch, totpf.hch, totpm.hch (the UN half-child variant for total population, age-specific female and age-specific male, respectively). Optionally, if keep.vital.events is TRUE, there is an additional file per country, called vital_events_country$x$.rda, containing eight objects: btm, btf (trajectories for births by age of mothers for male and female child, respectively), deathsm, deathsf (trajectories for age-specific male and female deaths, respectively), btm.hch, btf.hch, deathsm.hch, deathsf.hch (the UN half-child variant for age- and sex-specific births and deaths). Furthermore, an object of class bayesPop.prediction is stored in the same directory in a file prediction.rda. It is updated every time a country projection is finished.

To access a previously stored prediction object, use get.pop.prediction.

References

A. E. Raftery, N. Li, H. Sevcikova , P. Gerland, G. K. Heilig (2012). Bayesian probabilistic population projections for all countries. Proceedings of the National Academy of Sciences 109:13915-13921.

See Also

pop.trajectories.plot, pop.pyramid, get.pop.prediction

Examples

Run this code
sim.dir <- tempfile()
# Countries can be given as a combination of numerical codes and names
pred <- pop.predict(countries=c("Netherlands", 218, "Madagascar"), nr.traj=3, 
           output.dir=sim.dir)
pop.trajectories.plot(pred, "Ecuador", sum.over.ages=TRUE)
unlink(sim.dir, recursive=TRUE)

Run the code above in your browser using DataLab