View source: R/plot_functions.R
pop.trajectories.plot | R Documentation |
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.
pop.trajectories.plot(pop.pred, country = NULL, expression = NULL, pi = c(80, 95),
sex = c("both", "male", "female"), age = "all", sum.over.ages = TRUE,
half.child.variant = FALSE, nr.traj = NULL, typical.trajectory = FALSE,
main = NULL, dev.ncol = 5, lwd = c(2, 2, 2, 2, 1),
col = c("black", "red", "red", "blue", "#00000020"), show.legend = TRUE,
ann = par("ann"), xshift = 0, ...)
pop.trajectories.plotAll(pop.pred,
output.dir=file.path(getwd(), "pop.trajectories"),
output.type="png", expression = NULL, verbose=FALSE, ...)
pop.trajectories.table(pop.pred, country = NULL, expression = NULL, pi = c(80, 95),
sex = c("both", "male", "female"), age = "all", half.child.variant = FALSE,
xshift = 0, ...)
pop.byage.plot(pop.pred, country = NULL, year = NULL, expression = NULL,
pi = c(80, 95), sex = c("both", "male", "female"),
half.child.variant = FALSE, nr.traj = NULL, typical.trajectory=FALSE,
xlim = NULL, ylim = NULL, xlab = "", ylab = "Population projection",
main = NULL, lwd = c(2,2,2,1), col = c("red", "red", "blue", "#00000020"),
show.legend = TRUE, add = FALSE, ann = par("ann"), type = "l", pch = NA,
pt.cex = 1, ...)
pop.byage.plotAll(pop.pred,
output.dir=file.path(getwd(), "pop.byage"),
output.type="png", expression = NULL, verbose=FALSE, ...)
pop.byage.table(pop.pred, country = NULL, year = NULL, expression = NULL,
pi = c(80, 95), sex = c("both", "male", "female"),
half.child.variant = FALSE)
pop.pred |
Object of class |
country |
Name or numerical code of a country. It can also be given as ISO-2 or ISO-3 characters. |
expression |
Expression defining the population measure to be plotted. For syntax see |
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. In a five year simulation, value 1 corresponds to age 0-4, value 2 corresponds to age 5-9 etc. Last age goup |
sum.over.ages |
Logical. If |
half.child.variant |
Logical. If TRUE the United Nations “+/-0.5 child” variant computed with fertility |
nr.traj |
Number of trajectories to be plotted. If |
typical.trajectory |
Logical. If |
xlim, ylim, xlab, ylab, main, ann, pt.cex |
Graphical parameters passed to the |
xshift |
Constant added to the x-axis (year). |
dev.ncol |
Number of column for the graphics device if |
lwd, col |
For the first three functions it is a vector of five elements giving the line width and color for: 1. observed data, 2. median, 3. quantiles, 4. half-child variant, 5. trajectories. For functions that show results by age it is a vector of four elements - as above without the first item (observed data). |
type, pch |
Currently works for plotting by age only. It is a vector of four elements giving the plot type and point type for: 1. median, 2. quantiles, 3. half-child variant, 4. trajectories. The last element of the array is recycled. |
show.legend |
Logical controlling whether the legend should be drawn. |
... |
Additional graphical arguments. Functions |
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. |
year |
Any year within the time period to be outputted. |
add |
Logical specifying if the plot should be added to an existing graphics. |
pop.trajectories.plot
plots trajectories of population projection by time for a given country.
pop.trajectories.table
gives the same output as a table. pop.trajectories.plotAll
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
.
pop.byage.plot
and pop.byage.table
plots/tabulate the posterior distribution by age for a given country and time period. pop.byage.plotAll
creates such plots for all countries.
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.
If plotting results of an expression and the function fails, to debug obtain values of that expression using the functions get.pop.ex
(for pop.trajectories.plot
) and get.pop.exba
(for pop.byage.plot
).
Hana Sevcikova
bayesPop.prediction
, summary.bayesPop.prediction
, pop.pyramid
, pop.expressions
, get.pop
sim.dir <- file.path(find.package("bayesPop"), "ex-data", "Pop")
pred <- get.pop.prediction(sim.dir)
pop.trajectories.plot(pred, country="Ecuador", pi=c(80, 95))
pop.trajectories.table(pred, country="ECU", pi=c(80, 95))
# female population of Ecuador in child bearing ages (by time)
pop.trajectories.plot(pred, expression="PEC_F[4:10]")
# Population by age in Netherands for two different years
pop.byage.plot(pred, country="Netherlands", year=2050)
pop.byage.plot(pred, expression="PNL{}", year=2000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.