run.tfr.mcmc (and possibly run.tfr3.mcmc) the function generates posterior trajectories for the total fertility rate for all countries of the world.tfr.predict(mcmc.set = NULL, end.year = 2100,
sim.dir = file.path(getwd(), "bayesTFR.output"),
replace.output = FALSE, start.year = NULL,
nr.traj = NULL, thin = NULL, burnin = 2000,
use.diagnostics = FALSE, use.tfr3 = TRUE, burnin3 = 10000,
mu = 2.1, rho = 0.8859, sigmaAR1 = 0.1016,
use.correlation = FALSE, save.as.ascii = 1000, output.dir = NULL,
low.memory = TRUE, seed = NULL, verbose = TRUE, ...)bayesTFR.prediction which is a list containing components:sigma_t is a vector of actual values of the standard deviation $s$ used for each projection.NA values.bayesTFR.mcmc.set used for this prediction, i.e. the burned, thinned, and collapsed MCMC chain.run.tfr.mcmc are used from all chains, from which the given burnin was discarded. They are evenly thinned to match nr.traj or using the thin argument. Such thinned parameter traces, collapsed into one chain, if they do not already exist, are stored on disk into the sub-directory thin and b the value of burnin (see create.thinned.tfr.mcmc).
If Phase III is projected using a BHM (i.e. if use.tfr3 is TRUE), parameter samples simulated via run.tfr3.mcmc are used from which burnin (given by burnin3) is discarded and the chains are evenly thinned in a way that the total size corresponds to the final size of the Phase II parameter samples. Countries for which there are no simulated country-specific Phase III parameters (e.g. because their TFR is still in Phase II or it is an aggregated region) use samples of the The projection is run for all missing values before the present year, if any. Medians over the trajectories are used as imputed values and the trajectories are discarded. The process then continues by projecting the future values where all generated trajectories are kept.
The resulting prediction object is saved into save.as.ascii is larger than 0, the function converts the given number of trajectories into a CSV file of a UN-specific format. They are selected by equal spacing (see function convert.tfr.trajectories for more details on the conversion). In addition, two summary files are created: one in a user-friendly format, the other using a UN-specific coding of the variants and time (see write.projection.summary for more details).
Raftery, A.E., Alkema, L. and Gerland, P. (2014).
Fosdick, B., Raftery, A.E. (2014).
run.tfr.mcmc, run.tfr3.mcmc, create.thinned.tfr.mcmc, convert.tfr.trajectories, write.projection.summary,
get.tfr.prediction, summary.bayesTFR.predictionsim.dir <- tempfile()
m <- run.tfr.mcmc(nr.chains=1, iter=10, output.dir=sim.dir, verbose=TRUE)
m3 <- run.tfr3.mcmc(sim.dir=sim.dir, nr.chains=2, iter=40, thin=1, verbose=TRUE)
pred <- tfr.predict(m, burnin=0, burnin3=10, verbose=TRUE)
summary(pred, country="Iceland")
unlink(sim.dir, recursive=TRUE)Run the code above in your browser using DataLab