get.thinned.tfr.mcmc {bayesTFR} R Documentation

## Creating and Accessing Thinned MCMCs

### Description

The function get.thinned.tfr.mcmc accesses a thinned and burned version of the given Phase II MCMC set. create.thinned.tfr.mcmc creates or updates such a set.

### Usage

get.thinned.tfr.mcmc(mcmc.set, thin = 1, burnin = 0)

create.thinned.tfr.mcmc(mcmc.set, thin = 1, burnin = 0,
output.dir = NULL, verbose = TRUE, uncertainty = FALSE,
update.with.countries = NULL)


### Arguments

 mcmc.set Object of class bayesTFR.mcmc.set of Phase II. thin, burnin Thinning interval and burnin used for creating or identifying the thinned object. output.dir Output directory. It is only used if the output goes to a non-standard directory. verbose Logical switching log messages on and off. uncertainty If users want to save the thinned estimated TFR in the new mcmc object, this parameter should be set TRUE. update.with.countries If an existing set is to be updated, this should be a vector of country indices for the update.

### Details

The function create.thinned.tfr.mcmc is called from tfr.predict and thus, the resulting object contains exactly the same MCMCs used for generating projections. In addition, it can be also called from tfr.diagnose if desired, so that the projection process can re-use such a set that leads to a convergence.

The thinning is done as follows: The given burnin is removed from the beginning of each chain in the original MCMC set. Then each chain is thinned by thin using equal spacing and all chains are collapsed into one single chain per parameter. They are stored in the main simulation directory under the name ‘thinned_mcmc_t_b’ where t is the value of thin and b the value of burnin.

If uncertainty=TRUE, the estimated TFR is thinned and saved as well.

### Value

Both functions return an object of class bayesTFR.mcmc.set. get.thinned.tfr.mcmc returns NULL if such object does not exist.

### Author(s)

Hana Sevcikova

bayesTFR.mcmc.set, tfr.predict, tfr.diagnose

### Examples

## Not run:
sim.dir <- tempfile()
m <- run.tfr.mcmc(nr.chains=2, iter=30, seed=1, output.dir=sim.dir, verbose=TRUE)
tfr.predict(m, burnin=15, use.tfr3=FALSE) # creates thinned MCMCs
mb <- get.thinned.tfr.mcmc(m, thin=1, burnin=15)
summary(mb, meta.only=TRUE) # length 30 = 2chains x (30-15)iters.