| e0.trajectories.plot {bayesLife} | R Documentation |
Posterior Distribution of Trajectories of Life Expectancy
Description
The functions plot/tabulate the posterior distribution of trajectories of the life expectancy for a given country, or for all countries, including their median and given probability intervals.
Usage
e0.trajectories.plot(e0.pred, country, pi = c(80, 95), both.sexes = FALSE,
nr.traj = NULL, adjusted.only = TRUE, typical.trajectory = FALSE,
xlim = NULL, ylim = NULL, type = "b",
xlab = "Year", ylab = "Life expectancy at birth", main = NULL,
lwd = c(2, 2, 2, 2, 1), col = c('black', 'green', 'red', 'red', '#00000020'),
col2 = c('gray39', 'greenyellow', 'hotpink', 'hotpink', '#00000020'),
pch = c(1, 2), show.legend = TRUE, add = FALSE, ...)
e0.trajectories.plot.all(e0.pred,
output.dir = file.path(getwd(), 'e0trajectories'),
output.type = "png", verbose = FALSE, ...)
e0.trajectories.table(e0.pred, country, pi = c(80, 95),
both.sexes = FALSE, ...)
Arguments
e0.pred |
Object of class |
country |
Name or numerical code of a country. It can also be given as ISO-2 or ISO-3 characters. |
pi |
Probability interval. It can be a single number or an array. If |
both.sexes |
Logical or the character “A”. If |
nr.traj |
Number of trajectories to be plotted. If |
adjusted.only |
Logical. By default, if the projection median is adjusted using e.g. |
typical.trajectory |
Logical. If |
xlim, ylim, type, xlab, ylab, main |
Graphical parameters passed to the |
lwd, col, col2 |
Vector of five elements giving the line width and color for: 1. observed data, 2. imputed missing data, 3. median, 4. quantiles, 5. trajectories. |
pch |
Vector of two elements specifying plotting symbols for the observed and imputed data, respectively. It is not used if |
show.legend |
Logical controlling whether the legend should be drawn. |
add |
Logical controlling whether the trajectories should be plotted into a new graphic device ( |
... |
Additional graphical parameters. In addition, for |
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
e0.trajectories.plot plots posterior distribution of trajectories of life expectancy for a given country. e0.trajectories.table gives the same output in a tabular format.
e0.trajectories.plot.all creates a set of such graphs (one per country) that are stored in output.dir.
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.
Author(s)
Hana Sevcikova
See Also
Examples
sim.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
pred <- get.e0.prediction(sim.dir)
e0.trajectories.table(pred, country = "Japan", pi = c(80, 95))
e0.trajectories.plot(pred, country = "Japan", pi = c(80, 95))
# plot multiple countries into one plot
e0.trajectories.plot(pred, "JP", col = rep("green", 5), nr.traj = 0,
pi = c(80), show.legend = FALSE, main = "")
e0.trajectories.plot(pred, "USA", col = rep("blue", 5),
add = TRUE, nr.traj = 0, pi = c(80), show.legend = FALSE)
legend("topleft", legend = c("Japan", "USA"), col = c("green", "blue"),
lty = 1, bty = "n")