DLcurve.plot {bayesTFR}R Documentation

Plotting Posterior Distribution of the Double Logistic Function


The functions for plotting and retrieving the posterior distribution of the double logistic function used in the simulation of Phase II. Plots include the median and given probability intervals of the distribution.


DLcurve.plot(mcmc.list, country, burnin = NULL, pi = 80, tfr.max = 10, 
    nr.curves = NULL, predictive.distr = FALSE, ylim = NULL, 
    xlab = 'TFR (reversed)', ylab = 'TFR decrement', main = NULL, 
    show.legend = TRUE, col=c('black', 'red', "#00000020"), ...)
DLcurve.plot.all(mcmc.list = NULL, sim.dir = NULL, 
    output.dir = file.path(getwd(), 'DLcurves'),
    output.type = "png", burnin = NULL, verbose = FALSE, ...)
tfr.world.dlcurves(x, mcmc.list, burnin=NULL, countryUc=NULL, ...)

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



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


Name or code of a country. The code can be either numeric or 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.


Maximum TFR to be shown in the plot.


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

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


For the plotting functions, there are additional graphical parameters. For DLcurve.plot.all, ... contains also arguments pi, tfr.max and nr.curves. For the tfr.*.dlcurves functions, these are arguments passed to the underlying functions (predictive.distr and return.sigma for obtaining a sample of the standard deviation of the error term ).


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.


TFR values for which the double logistic should be computed.


Country to use the parameter U_c from (start of the fertility transition). If it is not given, the middle point of the prior distribution is used.


DLcurve.plot plots double logistic curves for the given country. DLcurve.plot.all creates such plots for all countries and stores them in output.dir. Parameters inputting the double logistic function are either thinned traces created by the tfr.predict function (if mcmc.list is an object of class bayesTFR.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 tfr.world.dlcurves returns the DL curves of the hierarchical distribution, conditioned on the starting point of the fertility transition in a given country (given by the countryUc argument). Function tfr.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”.


tfr.world.dlcurves and tfr.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. If the argument return.sigma is set to TRUE, the return value is a list with the first element being the DL values and the second element being a matrix of the standard deviation of the DL error term sigma_eps.


Hana Sevcikova, Leontine Alkema


## Not run: 
sim.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
mcmc.set <- get.tfr.mcmc(sim.dir=sim.dir)
DLcurve.plot(country="Burkina Faso", mcmc.set, burnin=15)

# add the median of the hierarchical DL curves
x <- seq(0, 10, length=100)
world <- tfr.world.dlcurves(x, mcmc.set, burnin=15, countryUc="Burkina Faso")
qw <- apply(world, 2, median) 
lines(x, qw, col='blue')

## End(Not run)

[Package bayesTFR version 7.4-2 Index]