pop.predict(end.year = 2100, start.year = 1950, present.year = 2015, wpp.year = 2015, 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, fixed.pasfr = FALSE, my.locations.file = NULL, 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=FALSE, then a projection is performed for all countries that are not included in the existing projection. Names of countries are matched to those in the UNlocations dataset (or in the dataset loaded from my.locations.file if used).output.dir and replace.output=TRUE, everything in the directory will be deleted.NULL are shown in brackets):
present.year) [popM, popF].
mxM, mxF] (see also argument fixed.mx).
sexRatio]
percentASFR] (see also argument fixed.pasfr).
vwBaseYear].
migrationM, migrationF]. If not available, the migration schedules are reconstructed from total migration counts derived from migration using the age.specific.migration function.
convert.e0.trajectories, file ascii_trajectories.csv). Required columns are LocID, Year, Trajectory, and e0. If this element is not NULL, the argument e0F.sim.dir is ignored. If both e0F.file and e0F.sim.dir are NULL, data from the corresponding wpp package is taken, namely the median projections as one trajectory and the low and high variants (if available) as second and third trajectory.
convert.e0.trajectories, file ascii_trajectories.csv). Required columns are LocID, Year, Trajectory, and e0. If this element is not NULL, the argument e0M.sim.dir is ignored. As in the female case, if both e0M.file and e0M.sim.dir are NULL, data from the corresponding wpp package is taken.
convert.tfr.trajectories, file ascii_trajectories.csv). Required columns are LocID, Year, Trajectory, and TF. If this element is not NULL, the argument tfr.sim.dir is ignored. If both tfr.file and tfr.sim.dir are NULL, data from the corresponding wpp package is taken (median and the low and high variants as three trajectories). Alternatively, this argument can be the keyword median_ in which case only the wpp median is taken.
e0F.file is NULL.
e0F.sim.dir directory. The argument is only used if e0M.file is NULL.
tfr.file is NULL.
migM and migF items. It has a similar format as e.g. e0M.file with columns LocID, Year, Trajectory, Age and Migration. The Age column must have values 0-4, 5-9, 10-14, ..., 95-99, 100+.
nr.traj, the value is adjusted to the maximum of available trajectories of the components. For those that have less trajectories than the adjusted number, the available trajectories are re-sampled, so that all components have the same number of trajectories.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, it is assumed the dataset on percent age-specific fertility rate (percentASFR) include data for projection years and they are then used instead of computing it on the fly.UNlocations dataset. It must have the same structure.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 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 the following 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), 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 prediction.rda. It is updated every time a country projection is finished.
To access a previously stored prediction object, use get.pop.prediction.
P. Gerland, A. E. Raftery, H. Sevcikova, N. Li, D. Gu, T. Spoorenberg, L. Alkema, B. K. Fosdick, J. L. Chunn, N. Lalic, G. Bay, T. Buettner, G. K. Heilig, J. Wilmoth (2014). World Population Stabilization Unlikely This Century. Science 346:234-237.
H. Sevcikova, N. Li, V. Kantorova, P. Gerland and A. E. Raftery (2015). Age-Specific Mortality and Fertility Rates for Probabilistic Population Projections. arXiv:1503.05215. http://arxiv.org/abs/1503.05215
pop.trajectories.plot, pop.pyramid, get.pop.prediction, age.specific.migration
## Not run:
# 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)
# ## End(Not run)Run the code above in your browser using DataLab