The functions plot/tabulate the posterior distribution of TFR trajectories for a given country, or for all countries, including their median and given probability intervals.
tfr.trajectories.plot(tfr.pred, country, pi = c(80, 95),
half.child.variant = TRUE, nr.traj = NULL,
adjusted.only = TRUE, typical.trajectory = FALSE,
mark.estimation.points = FALSE,
xlim = NULL, ylim = NULL, type = 'b', xlab = 'Year', ylab = 'TFR',
main = NULL, lwd = c(2, 2, 2, 2, 2, 1),
col=c('black', 'green', 'red', 'red', 'blue', '#00000020'),
show.legend = TRUE, add = FALSE, …)
tfr.trajectories.plot.all(tfr.pred,
output.dir = file.path(getwd(), 'TFRtrajectories'),
output.type = "png", main = NULL, verbose = FALSE, …)
tfr.trajectories.table(tfr.pred, country, pi = c(80, 95),
half.child.variant = TRUE)
Object of class bayesTFR.prediction
.
Name or numerical code of a country.
Probability interval. It can be a single number or an array.
If TRUE
the United Nations variant of “+/-0.5
child” (relative to the median) is shown.
Number of trajectories to be plotted. If NULL
, all trajectories are plotted, otherwise they are thinned evenly.
Logical. By default, if the projection median is adjusted using e.g. tfr.median.set
, the function plots the adjusted median. If adjusted.only=FALSE
the original (non-adjusted) median is plotted as well.
Logical. If TRUE
one trajectory is shown that has the smallest distance to the median.
Logical. If TRUE
, points that were not used in the estimation (phase I) are shown in lighter color than points in phase II and III.
Graphical parameters passed to the plot
function.
Vector of six elements giving the line width and color for: 1. observed data, 2. imputed missing data, 3. median, 4. quantiles, 5. half-child variant, 6. trajectories.
Logical controlling whether the legend should be drawn.
Logical controlling whether the trajectories should be plotted into a new graphic device (FALSE
) or into an existing device (TRUE
). One can use this argument to plot trajectories from multiple countries into one graphics.
Additional graphical parameters. In addition, for tfr.trajectories.plot.all
, …
contains any of the arguments of tfr.trajectories.plot
.
Directory into which resulting graphs are stored.
Type of the resulting files. It can be “png”, “pdf”, “jpeg”, “bmp”, “tiff”, or “postscript”.
Main title for the plot(s). In tfr.trajectories.plot.all
any occurence of the string “XXX” is replaced by the country name.
Logical switching log messages on and off.
tfr.trajectories.plot
plots posterior distribution of TFR trajectories for a given country. tfr.trajectories.table
gives the same output as a table. tfr.trajectories.plot.all
creates a set of 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.
# NOT RUN {
sim.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
pred <- get.tfr.prediction(sim.dir)
tfr.trajectories.plot(pred, country="Burkina Faso", pi=c(80, 95))
tfr.trajectories.table(pred, country="Burkina Faso", pi=c(80, 95))
# }
Run the code above in your browser using DataLab