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,
migMtraj = NULL, migFtraj = NULL),
nr.traj = 1000, keep.vital.events = FALSE, fixed.mx = 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.TRUE age- and sex-specific vital events of births and deaths as well as other objects are stored in the prediction object, see Details.TRUE, it is assumed the dataset of death rates (mxM and mxF) include data for projection years and they are then used instead of the life expectancy.TRUE, everything in the directory output.dir is deleted prior to the prediction.bayesPop.prediction with the following elements:output.dir.base.directory with the projections.quantiles.traj.mean.sd corresponding to male and female projection, respectively.quantiles.quantilesMage.inputs argument passed to the function.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.cache should be modified.pop.predict or pop.aggregate.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 number of trajectories for male and female life expectancy must match, as does for male and female migration.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), asfert (trajectories of age-specific fertility), mxm, mxf (trajectories of male and female age-specific mortality rates), migm, migf (if used, these are trajectories of male and female age-specific migration), btm.hch, btf.hch, deathsm.hch, deathsf.hch, asfert.hch, mxm.hch, mxf.hch (the UN half-child variant for age- and sex-specific births, deaths, fertility rates and mortality rates). 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