View source: R/plot_functions.R
| e0.trajectories.plot | R Documentation |
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.
e0.trajectories.plot(e0.pred, country, pi = c(80, 95), both.sexes = FALSE,
nr.traj = NULL, adjusted.only = TRUE, typical.trajectory = FALSE,
traj.index = NULL, show.mean = FALSE, show.median = TRUE,
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, ...)
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 |
traj.index |
Vector of trajectory indices to show. If not given, the trajectories are selected using equidistant spacing. |
show.mean, show.median |
Logical indicating if the mean or/and the median of the distribution should be shown. |
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. |
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.
Hana Sevcikova
bayesLife.prediction
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.