bayesPop (version 6.2-4)

write.pop.projection.summary: Writing Projection Summary Files

Description

The function creates ASCII files containing projection summaries, such as the median, the lower and upper bound of the 80 and 95% probability intervals, respectively.

Usage

write.pop.projection.summary(pop.pred, what = NULL, expression = NULL, 
    output.dir = NULL, …)

Arguments

pop.pred

Object of class bayesPop.prediction.

what

A character vector specifying what kind of projection to write. Total population is specified by “pop”. Vital events are specified by “births”, “deaths”, “sr” (survival rate), “fertility” and “pfertility” (percent fertility). Each of these strings can (some must) have a suffix “sex” and/or “age” if sex- and/or age-specific measure is desired. For example, “popage”, “birthssexage”, “deaths”, “deathssex”, are all valid values. Note that for survival, only “srsexage” is allowed. For percent fertility, only “pfertilityage” is allowed. Suffix “sex” cannot be used in combination with “fertility”. Moreover, “fertility” (without age) corresponds to the total fertility rate. If the argument is NULL, all valid combinations are used. The argument is not used if expression is given. Note that vital events can be only used if the prediction object contains vital events, i.e. if it was generated with the keep.vital.events argument being TRUE (see pop.predict).

expression

Expression defining the measure to be written. If it is not NULL, argument what is ignored. For expression syntax see pop.expressions. The country components of the expression should be given as “XXX”.

output.dir

Directory in which the resulting files will be stored. If NULL pop.pred$output.directory is used.

These are arguments used if expression is given: file.suffix defines the file suffix; expression.label (defaults to the expression) is put as the first line in the resulting file; logical include.observed determines if observed data should be included; integer digits defines the number of decimal places in the resulting file.

Details

There is one file created per value of what, or expression, called projection_summary_suffix.csv, where suffix is either what or, if an expression is given, the value of file.suffix. It is a comma-separated table with the following columns:

  • “country_name”: country name

  • “country_code”: country code

  • “variant”: name of the variant, such as “median”, “lower 80”, “upper 80”, “lower 95”, “upper 95”

  • period1: e.g. “2005-2010”: Given population measure for the first time period

  • period2: e.g. “2010-2015”: Given population measure for the second time period

  • … further time period columns

If expression is given, expression.label (by default the full expression) is written as the first line of the file starting with #. The file contains one line per country, and possibly sex and age.

See Also

pop.predict, pop.map, pop.expressions

Examples

Run this code
# NOT RUN {
outdir <- tempfile()
dir.create(outdir)
sim.dir <- file.path(find.package("bayesPop"), "ex-data", "Pop")
pred <- get.pop.prediction(sim.dir=sim.dir, write.to.cache=FALSE)

# proportion of 65+ years old to the whole population
write.pop.projection.summary(pred, expression="PXXX[14:27] / PXXX", file.suffix="age65plus", 
    output.dir=outdir, include.observed=TRUE, digits=2)
    
# various measures
write.pop.projection.summary(pred, what=c("pop", "popsexage", "popsex"),
    output.dir=outdir)

unlink(outdir, recursive=TRUE)
# }

Run the code above in your browser using DataLab