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)wpp.year and uses the various datasets as default if the corresponding inputs element is missing (see below).NULL, all available countries are used. If it is NA and there is an existing projection in output.dir and replace.output=FALoutput.dir and replace.output=TRUE, everything in the directory will be deleted.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 TRUE age- and sex-specific vital events of births and deaths are stored in the prediction object.TRUE, everything in the directory output.dir is deleted prior to the prediction.bayesPop.prediction with the following elements:quantiles.traj.mean.sd corresponding to male and female projection, respectively.quantiles.quantilesMage.code, name.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.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 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 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
To access a previously stored prediction object, use get.pop.prediction.
pop.trajectories.plot, pop.pyramid, get.pop.predictionsim.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