Learn R Programming

bayesLife (version 5.2-0)

get.thinned.e0.mcmc: Creating and Accessing Thinned MCMCs

Description

The function get.thinned.e0.mcmc accesses a thinned and burned version of the given MCMC set. create.thinned.e0.mcmc creates such set.

Usage

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

create.thinned.e0.mcmc(mcmc.set, thin = 1, burnin = 0, output.dir = NULL, verbose = TRUE)

Value

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

Arguments

mcmc.set

Object of class bayesLife.mcmc.set.

thin, burnin

Thinning interval and burnin used for creating or identifying the thinned object.

output.dir

Directory for storing the thinned object. By default it is stored into the same directory as mcmc.set.

verbose

Logical switching log messages on and off.

Author

Hana Sevcikova

Details

The function create.thinned.e0.mcmc is called from e0.predict and thus, the resulting object contains exactly the same MCMCs used for generating projections.

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 output.dir under the name thinned_mcmc_t_b where t is the value of thin and b the value of burnin.

See Also

bayesLife.mcmc.set, e0.predict

Examples

Run this code
if (FALSE) {
sim.dir <- tempfile()
m <- run.e0.mcmc(nr.chains = 2, iter = 60, thin = 2, output.dir = sim.dir, verbose = TRUE)
pr <- e0.predict(m, burnin = 40, predict.jmale = FALSE) # creates thinned MCMCs
mb <- get.thinned.e0.mcmc(m, thin = 2, burnin = 40)
summary(mb, meta.only = TRUE) # length 20 = 2chains x (60-40)iters./2thin

# the same chain as 
summary(pr$mcmc.set, meta.only = TRUE)

unlink(sim.dir, recursive=TRUE)}

Run the code above in your browser using DataLab