post_thin: Perform post-MCMC thinning

Description Usage Arguments Details Value Note Examples

View source: R/post_thin.R

Description

Removes iterations from each chain of a mcmc.list object at quasi-evenly spaced intervals. Post-MCMC thinning is useful for developing long-running post-processing code with a smaller but otherwise identical mcmc.list.

Usage

1
post_thin(post, keep_percent, keep_iters)

Arguments

post

A mcmc.list object.

keep_percent

Proportion (between 0 and 1) of samples to keep from each chain. Setting keep_percent = 0.2 will remove approximately 80 percent of the samples.

keep_iters

Number of samples to keep from each chain.

Details

The samples will be removed at as evenly spaced intervals as possible, however, this is not perfect. It is therefore recommended to use the full posterior for final post-processing calculations, but this should be fine for most development of long-running code.

If both keep_percent and keep_iters are supplied, an error will be returned requesting that only one be used.

Value

A mcmc.list object, identical to post, but with fewer samples of each node.

Note

Iteration numbers are reset after thinning the samples. So if running post_dim() on output passed through post_thin(), you cannot trust the burn-in or thinning counts. Again, this is not an issue for developing post-processing code.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# load example mcmc.list
data(cjs)

# take note of original dimensions
post_dim(cjs)

# keep ~20% of the samples
cjs_thin1 = post_thin(cjs, keep_percent = 0.2)

# note burn-in and thin intervals no longer correct!
# but desired outcome achieved - identical object but smaller
post_dim(cjs_thin1)

# keep 30 samples per chain
cjs_thin2 = post_thin(cjs, keep_iters = 30)
post_dim(cjs_thin2)

postpack documentation built on June 3, 2021, 1:07 a.m.