{bayesTFR}R Documentation

TFR World Map


Generate world maps of the total fertility rate for given projection period and quantile, using different techniques: and use rworldmap, tfr.ggmap uses ggplot2, and creates an interactive map via GoogleVis. In addition to TFR, all these functions allow to project country specific Phase II MCMC parameters into the world maps.

Usage, quantile = 0.5, 
    year = NULL, = NULL, adjusted = FALSE,
    projection.index = 1, device = "", main = NULL, 
    resolution=c("coarse","low","less islands","li","high"),
    device.args = NULL, data.args = NULL, ...)

tfr.ggmap(pred, quantile = 0.5, 
    year = NULL, = NULL, adjusted = FALSE,
    projection.index = 1, main = NULL, data.args = NULL, 
    viridis.option = "B", nr.cats = 10, same.scale = FALSE, 
    plot = TRUE, = NULL, plot.size = 4, ...), year = NULL, quantile = 0.5, pi = 80, = NULL, adjusted = FALSE, ...), output.dir, output.type = "png", 
    tfr.range = NULL, nr.cats = 50, same.scale = TRUE, 
    quantile = 0.5, file.prefix='TFRwrldmap_', ...), tfr.range = NULL, 
    nr.cats = 50, same.scale = TRUE, quantile = 0.5, ...)



Object of class bayesTFR.prediction.


Quantile for which the map should be generated. It must be equal to one of the values in dimnames(pred$quantiles[[2]]), i.e. 0, 0.025, 0.05, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.9, 0.95, 0.975, 1. Value 0.5 corresponds to the median.


Year to be plotted. It can be a year within a projection period or a year within an estimation period. In the latter case, the observed data are plotted. If not given, projection.index determines the projection year.

Name of a country-specific parameter to be plotted. If NULL, the TFR is plotted. Allowed values are any of those returned by tfr.parameter.names.cs.extended() and ‘lambda’ (see Details).


Logical indicating if the measure to be plotted is based on adjusted TFRs.


Index of the projection to be displayed. It is only relevant if year is NULL. projection.index=1 means the present year, projection.index=2 means the first projection period after present year, etc..


Device for displaying the map. It is passed to the mapDevice function of the rworldmap package. If it is equal to ‘dev.cur’, the current device is used. Otherwise, it can be ‘’, ‘png’, ‘pdf’ etc.


Title for the map. If it is NULL, a default title is constructed from the projection year and quantile.


Map resolution as implemented in getMap. High resolution requires the rworldxtra package.


List of additional arguments to be passed to the mapDevice function of the rworldmap package.


List of additional arguments to be passed to the underlying data retrieving function.


Argument option passed to the ggplot2::scale_fill_viridis_c function indicating the colormap. Available are ‘magma’ (or ‘A’), ‘inferno’ (or ‘B’, default), ‘plasma’ (or ‘C’), ‘viridis’ (or ‘D’) and ‘cividis’ (or ‘E’).


Number of color categories.


Logical controlling if maps for all projection years of this prediction object should be on the same color scale.


Logical indicating if a plot should be shown. If FALSE, the function only returns the ggplot object.

Name of a file to save the plot. If NULL nothing is saved. The type of the file is determined by its extension. Only used if plot is TRUE.


Height of the plotting device in inches. The width is automatically set using the aspect ratio of 2.36. Only used if plot is TRUE.


Directory into which resulting maps are stored.


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


Range of the total fertility rate to be displayed. It is of the form c(tfr.min, tfr.max). By default, the whole range is considered. Note that countries with values outside of the given range will appear white.


Prefix for file names.


Arguments passed to the mapCountryData function of the rworldmap package. In case of these are passed to the underlying data retrieving function (the same as data.args). In case of tfr.ggmap which uses ggplot2 they are passed to the geom_sf function.


Probability interval to be shown when a country is selected in an interactive map. The corresponding quantiles must be available (see argument quantile above).

Details creates a single map for a given projection period and quantile using the rworldmap package. generates a sequence of such maps, namely one for each projection period. If the package fields is installed, a color bar legend at the botom of the map is created.

Function can be used in combination with (Note that is called from inside of It sets breakpoints for the color scheme using quantiles of a fitted gamma distribution.

Function tfr.ggmap is similar to, but used the ggplot2 package in combination with the geom_sf function.

Function creates an interactive map using the googleVis package and opens it in an internet browser. It also generates a table of TFRs that can be sorted by columns interactively in the browser.

By default,, tfr.ggmap and produce maps of TFRs. Alternatively, the functions can be used to plot country-specific Phase II MCMC parameters into a world map. They are given by the argument In addition to the MCMC parameters, if'lambda', the period of the end of TFR decline (i.e. start of Phase III) is computed for each country and projected into the map. In such a case, for we recommend to adjust the color scale in e.g. using the arguments catMethod='pretty' and numCats=20 (see mapCountryData).

Value returns a list with elements:


The object of class bayesTFR.prediction used in the function.


Value of the argument quantile.


If the argument same.scale is TRUE, this element contains breakpoints for categorization. It is generated from a fitted gamma distribution. Otherwise, it is NULL.


Number of categories.


Subset of the rainbow palette, starting from dark blue and ending at red.


Additional arguments passed to the function.


Hana Sevcikova, Patrick Gerland, Adrian Raftery


## Not run: 
sim.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
pred <- get.tfr.prediction(sim.dir=sim.dir)

# Using ggplot2
tfr.ggmap(pred, year = 2100)

# Using rworldmap
# Uses heat colors and seven categories by default
# Uses more colors with more suitable categorization
params <-"", params)
# Another projection year on the same scale"", c(list(year=2043), params))

# Using Google Vizualization tool

## End(Not run)

[Package bayesTFR version 7.4-2 Index]