Learn R Programming

bayesTFR (version 6.1-2)

get.thinned.tfr.mcmc: 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 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)

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.

Value

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

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 lead 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.

See Also

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

Examples

Run this code
# 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.
unlink(sim.dir, recursive=TRUE)
# }

Run the code above in your browser using DataLab