Learn R Programming

bayesPop (version 0.2-2)

pop.trajectories.plot: Output of Probabilistic Population Projection

Description

The functions plot and tabulate the distribution of population projection for a given country, or for all countries, including the median and given probability intervals.

Usage

pop.trajectories.plot(pop.pred, country, pi = c(80, 95), 
    sex = c("both", "male", "female"), age = "all", sum.over.ages = FALSE, 
    half.child.variant = FALSE, nr.traj = NULL, typical.trajectory = FALSE,
    xlim = NULL, ylim = NULL, xlab = "Year", ylab = "Population projection", 
    main = NULL, dev.ncol = 5, lwd = c(2, 2, 2, 2, 1), 
    col = c('black', 'red', 'red', 'blue', 'gray'), show.legend = TRUE, ...)
    
pop.trajectories.plot.all(pop.pred, 
    output.dir=file.path(getwd(), "pop.trajectories"),
    output.type="png", verbose=FALSE, ...)
    
pop.trajectories.table(pop.pred, country, pi = c(80, 95), 
    sex = c("both", "male", "female"), age = "all",
    half.child.variant = FALSE)

Arguments

pop.pred
Object of class bayesPop.prediction.
country
Name or numerical code of a country.
pi
Probability interval. It can be a single number or an array.
sex
One of both (default), male or female. By default the male and female projections are summed up.
age
Either a character string all (default) or an integer vector of age indices. Value 1 corresponds to age 0-4, value 2 corresponds to age 5-9 etc. Last age goup is $130+$ which corresponds to index 27. The default value of all
sum.over.ages
Logical. If TRUE, the values are summed up over given age groups. Otherwise there is a separate plot for each age group.
half.child.variant
Logical. If TRUE the United Nations +/-0.5 child variant computed with fertility $+/- 0.5*$ TFR median and the median of life expectancy is shown.
nr.traj
Number of trajectories to be plotted. If NULL, all trajectories are plotted, otherwise they are thinned evenly.
typical.trajectory
Logical. If TRUE one trajectory is shown that has the smallest distance to the median.
xlim, ylim, xlab, ylab, main
Graphical parameters passed to the plot function.
dev.ncol
Number of column for the graphics device if sum.over.ages is FALSE. If the number of age groups is smaller than dev.ncol, the number of columns is automatically decreased.
lwd, col
Vector of five elements giving the line width and color for: 1. observed data, 2. median, 3. quantiles, 4. half-child variant, 5. trajectories.
show.legend
Logical controlling whether the legend should be drawn.
...
Additional graphical arguments. Function pop.trajectories.plot.all accepts also any arguments of pop.trajectories.plot (except country).
output.dir
Directory into which resulting graphs are stored.
output.type
Type of the resulting files. It can be png, pdf, jpeg, bmp, tiff, or postscript.
verbose
Logical switching log messages on and off.

Details

pop.trajectories.plot plots trajectories of population projection for a given country. pop.trajectories.table gives the same output as a table. pop.trajectories.plot.all creates a set of graphs (one per country) that are stored in output.dir. The projections can be visualized separately for each sex and age groups, or summed up over both sexes and/or given age groups. This is controlled by the arguments sex, age and sum.over.ages. The median and given probability intervals are computed using all available trajectories. Thus, nr.traj does not influence those values - it is used only to control the number of trajectories plotted.

See Also

bayesPop.prediction, summary.bayesPop.prediction, pop.pyramid

Examples

Run this code
sim.dir <- file.path(.find.package("bayesPop"), "ex-data", "Pop")
pred <- get.pop.prediction(sim.dir)
pop.trajectories.plot(pred, country="Malaysia", pi=c(80, 95))
pop.trajectories.table(pred, country="Malaysia", pi=c(80, 95))

Run the code above in your browser using DataLab