e0.DLcurve.plot: Plotting Posterior Distribution of the Double Logistic...

e0.DLcurve.plotR Documentation

Plotting Posterior Distribution of the Double Logistic Function of Life Expectancy


The functions plot the posterior distribution of the double logistic function used in the simulation, including their median and given probability intervals.


e0.DLcurve.plot(mcmc.list, country, burnin = NULL, pi = 80, 
    e0.lim = NULL, nr.curves = 20, predictive.distr = FALSE, ylim = NULL, 
    xlab = "e(0)", ylab = "5-year gains", main = NULL, show.legend = TRUE, 
    col = c('black', 'red', "#00000020"), ...)
e0.DLcurve.plot.all(mcmc.list = NULL, sim.dir = NULL, 
    output.dir = file.path(getwd(), "DLcurves"),
    output.type = "png", burnin = NULL, verbose = FALSE, ...)
e0.parDL.plot(mcmc.set, country = NULL, burnin = NULL, lty = 2, 
    ann = TRUE, ...)
e0.world.dlcurves(x, mcmc.list, burnin = NULL, ...)

e0.country.dlcurves(x, mcmc.list, country, burnin = NULL, ...)



List of bayesLife.mcmc objects, an object of class bayesLife.mcmc.set or of class bayesLife.prediction. In case of e0.DLcurve.plot.all if it si NULL, it is loaded from sim.dir.


Object of class bayesLife.mcmc.set or bayesLife.prediction.


Name or numerical code of a country. It can also be given as ISO-2 or ISO-3 characters.


Number of iterations to be discarded from the beginning of parameter traces.


Probability interval. It can be a single number or an array.


It can be a tuple of the minimum and maximum life expectancy to be shown in the plot. If NULL, it takes the minimum of observed data and 40, and the maximum of observed data and 90.


Number of curves to be plotted. If NULL, all curves are plotted.


Logical. If TRUE, an error term is added to each trajectory.

ylim, xlab, ylab, main, lty

Graphical parameters passed to the plot function.


Logical determining if the legend should be shown.


Vector of colors in this order: 1. observed data points, 2. quantiles, 3. trajectories


Additional graphical parameters. In addition, any arguments from e0.DLcurve.plot except country can be passed to e0.DLcurve.plot.all.


Directory with the simulation results. Only relevant, if mcmc.list is NULL.


Directory into which resulting graphs are stored.


Type of the resulting files. It can be “png”, “pdf”, “jpeg”, “bmp”, “tiff”, or “postscript”.


Logical switching log messages on and off.


e0 values for which the double logistic should be computed.


Logical if parameters should be annotated.


e0.DLcurve.plot plots double logistic curves for the given country. e0.DLcurve.plot.all creates such plots for all countries and stores them in output.dir. Parameters passed to the double logistic function are either thinned traces created by the e0.predict function (if mcmc.list is an object of class bayesLife.prediction), or they are selected by equal spacing from the MCMC traces. In the former case, burnin is set automatically; in the latter case, burnin defaults to 0 since such object has already been “burned”. If nr.curves is smaller than 2000, the median and probability intervals are computed on a sample of 2000 equally spaced data points, otherwise on all plotted curves.

Function e0.parDL.plot draws the means of the DL parameters as vertical and horizontal lines. The lines are added to the current graphical device and annotated if ann is TRUE. If country is NULL, the mean of world parameters are drawn.

Function e0.world.dlcurves returns the DL curves of the hierarchical distribution. Function e0.country.dlcurves returns DL curves for a given country. If mcmc.list is a prediction object, burnin should not be given, as such object has already been “burned”.


e0.world.dlcurves and e0.country.dlcurves return a matrix of size N \times M where N is the number of trajectories and M is the number of values of x.


Hana Sevcikova


## Not run: 
sim.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
mcmc.set <- get.e0.mcmc(sim.dir = sim.dir)
e0.DLcurve.plot(mcmc.set, country = "Japan", burnin = 40)
e0.parDL.plot(mcmc.set, "Japan")

# add the median of the hierarchical DL curves
x <- seq(40, 90, length = 100)
world <- e0.world.dlcurves(x, mcmc.set, burnin = 40)
qw <- apply(world, 2, median) 
lines(x, qw, col = 'blue')

## End(Not run)

bayesLife documentation built on Sept. 16, 2023, 9:07 a.m.